#################################### ##FILL ME IN #################################### ## for a custom note with links: ## for the canned note of "This tutorial assumes that you have completed the previous tutorials:" just add the links ## note.0= ## descriptive title for the tutorial ## title = bagファイルから画像や動画に出力(エクスポート)する方法 ## multi-line description to be displayed in search ## description = このチュートリアルはbagファイルから画像のメッセージを連続したjpeg画像にエクスポートする方法を説明した後, OGG Theoraの動画フォーマットにエンコードする方法に発展します. ## the next tutorial description (optional) ## next = ## links to next tutorial (optional) ## next.0.link=[[ja/rosbag/Tutorials/Producing filtered bag files|フィルタされたbagファイルを生成する]] ## next.1.link= ## what level user is this tutorial for ## level= BeginnerCategory ## keywords = data, rosbag, record, play, info, bag, export, video #################################### <> <> ##startpage ## === Tutorial setup === === チュートリアルの準備 === ## This tutorial requires that you have previously recorded a bag file which contains image data you would like to export as jpeg images or video. Additionally, this tutorial requires that the image_view package has been built and a few video utilities are installed: このチュートリアルではjpeg画像もしくは動画にエクスポートするための画像データを含むbagファイルを過去に記録していることが必要になります. さらに, このチュートリアルはimage_viewパッケージがビルドされ, 多少の動画ユーティリティがインストールされていることも求められています. {{{#!shell roscd image_view rosmake image_view --rosdep-install sudo aptitude install mjpegtools }}} ## This will install the necessary tools to complete the tutorial. The rest of this tutorial will assume that you have a .bag file previously created that is named `test.bag` and that this bag file is stored in the `image_view` package directory. これでチュートリアルを完了するために必要なツールがインストールされます. このチュートリアルの残りの部分では, .bagファイルが過去に`test.bag`の名前で生成され, `image_view`パッケージのディレクトリに格納されていることを前提としています. ## === Exporting jpegs from bag file === === jpegをbagファイルからエクスポートする === ## To export jpeg images from a bag file first you will need to create a launch file which will dump the data. This example uses `/camera/image_raw` as the topic for the desired image data. This can be replaced as needed. jpeg画像をbagファイルからエクスポートするには, まずデータをダンプ(展開)するためのlaunchファイルを作成する必要があります. この例では, `/camera/image_raw`を要求する画像データのトピックとして使用しています. 必要に応じて, この部分は置き換えが可能です. {{{#!xml }}} ## The launch file can be started by running このlaunchファイルは以下のようにして実行することができます {{{#!shell roslaunch export.launch }}} ## This will dump the images name frame%04d.jpg into the folder ".ros" in your home directory. When the process has completed it will display a message similar to `process has finished cleanly.` at which point you should enter ctrl-C to end the launched program. これによって, 画像名frame%04d.jpgの形式でホームディレクトリの".ros"フォルダの中にダンプされます. 処理が完了すると, `process has finished cleanly.` のようなメッセージが表示され, Ctrl-Cで立ち上げたプログラムを終了させます. ## The images files can be easily to moved to where ever is convenient. 画像ファイルはどこでも扱いやすい場所に簡単に移動できます. {{{#!shell cd ~ mkdir test mv ~/.ros/frame*.jpg test/ }}} ## === Converting jpegs into an OGG Theora Video === === jpegをOGG Theoraフォーマットの動画に変換する === ## These instructions are based on the information found [[http://wiki.povray.org/content/HowTo:Encode_animations_as_Ogg_Theora_Video|here]], and have been tested and shown to work. この手順は[[http://wiki.povray.org/content/HowTo:Encode_animations_as_Ogg_Theora_Video|ここ]]から参照できる情報に基づいており, 動作確認がとれているものです. ## If your camera was running at 15 frames per second then you would execute the following in a shell for reasonable results. カメラが15フレーム毎秒で動作している場合, 適切な結果を得るためにシェルで以下のコマンドを実行します. {{{#!shell cd ~/test jpeg2yuv -I p -f 15 -j frame%04d.jpg -b 1 > tmp.yuv ffmpeg2theora --optimize --videoquality 10 --videobitrate 16778 -o output.ogv tmp.yuv }}} ## or generate MPEG video directly from jpegs. もしくは, MPEG動画をjpegから直接生成します. {{{#!shell cd ~/test mencoder "mf://*.jpg" -mf type=jpg:fps=15 -o output.mpg -speed 1 -ofps 30 -ovc lavc -lavcopts vcodec=mpeg2video:vbitrate=2500 -oac copy -of mpeg }}}