Ask Your Question
0

How to make depth stream video

asked 2015-11-04 05:05:32 -0500

shakith gravatar image

updated 2015-11-04 06:26:12 -0500

gvdhoorn gravatar image

I'm using the command

rosrun image_view video_recorder image:=/kinect2/sd/image_depth _encoding:=16UC1

to make depth stream video. However, it crashes with the following error:

Starting to record MJPG video at [512 x 424]@15fps. Press Ctrl+C to stop recording.
OpenCV Error: Assertion failed (image->depth == 8) in writeFrame, file /build/buildd/opencv-2.4.8+dfsg1/modules/highgui/src/cap_ffmpeg.cpp, line 238
terminate called after throwing an instance of 'cv::Exception'
  what():  /build/buildd/opencv-2.4.8+dfsg1/modules/highgui/src/cap_ffmpeg.cpp:238: error: (-215) image->depth == 8 in function writeFrame

Aborted (core dumped)

It doesnt work either with _encoding:=32FC1, 32SC1. If _encoding:=mono16 is used, it says unable to convert 16UC1 to mono16

Is it a problem with converting from ROS encodingto OpenCV encoding? Or is the video-writer only limited to color videos? This would be strange.

Thanks.

edit retag flag offensive close merge delete

Comments

Hi,

I know it was long time ago but did anyone found a solution? I am struggling trying to save the video stream from the depth camera.

pulver gravatar imagepulver ( 2019-06-03 09:26:18 -0500 )edit

I didn't spot this one the first time around, but I've just added an answer to it now.

PeteBlackerThe3rd gravatar imagePeteBlackerThe3rd ( 2019-06-03 11:53:58 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
1

answered 2019-06-03 11:53:40 -0500

The problem here is caused because depth images by convention are 16 bit monochrome images (1 unit encodes 1 mm of depth in most cases) but the video codecs being used in this case are only compatible with 8 bit color or mono image streams.

If you are producing this depth video with a view to using the video as sensor data and processing it into 3D information then you probably don't want to loose this resolution, however if you are producing the video just to view and are not too concerned about the exact values then there is an easy solution.

You'll want to make a simple ROS node which subscribes to the depth image topic, and converts each frame into an 8 bit mono or color image and publishes it. Then you can use the code to convert the depth camera topic into a form compatible with the video codecs.

There are many ways of doing the conversion itself. You can scale a color bar to the known depth range of your sensor, so that the pixel colors will be consistent between frames. Or you could normalise each frame individually so that the color bar is stretched to the depth range of that frame, but as the depth range of the images changes so will the coloring.

Hope this gives you some ideas.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2015-11-04 04:42:48 -0500

Seen: 1,140 times

Last updated: Jun 03