Download video data from robot camera
Hello everyone,
I have collected sensor data from my parot uav model with the following commands
roscore
rostopic list
rosbag record -O subset /drone/imu
rostopic echo -b subset.bag -p /drone/imu > data.csv
When I tried the same method to download camera data as video or image sets, the downlodaded file can not be opened
rosbag record -O subset /drone/frontcamera/imageraw/compressed
rostopic echo -b subset.bag -p /drone/frontcamera/imageraw/compressed > data.mp4
What can be the reason for that? The image_raw files are being recorded as a .bag file, but I can't download and see it in my computer. Am I making a mistake with the video or image format I am trying to download?
Asked by jean01 on 2020-04-16 10:46:11 UTC
Answers
Edit: actually did a quick search and found this to be helpful: http://wiki.ros.org/rosbag/Tutorials/Exporting%20image%20and%20video%20data
It would be awesome if dealing with images could be so easy! Unfortunately that is not the case :/
A few things: 1) The */image_raw/compressed topic is actually of the rosmsg type sensor_msgs/CompressedImage.
lol@lel:~$ rosmsg info sensor_msgs/CompressedImage
std_msgs/Header header
uint32 seq
time stamp
string frame_id
string format
uint8[] data
The data field is the actual payload, which needs to be converted into a jpg/png as per the official structure: https://en.wikipedia.org/wiki/JPEG#Syntax_and_structure
One way to do this is to use the cv_bridge to subscribe to the image topic, and then save to jpg/png on every run of the callback. (really there should be a node to do this .. but I can't find one :/ if you find one, please share!)
Once you have all of those jpgs, then can you coallate them into an mp4 video https://stackoverflow.com/questions/22965569/convert-from-jpg-to-mp4-by-ffmpeg
I hope this helps. Good luck!
Asked by pring on 2020-04-25 15:20:47 UTC
Comments