Ask Your Question
0

how to Save RGBD video from Kinect using OpenCV

asked 2018-10-06 06:22:28 -0600

KRK gravatar image

Hello Everyone,

I tried saving the depth video from the below code but I am not able to , could anyone help me as how can I save the Depth frames/video.

import freenect
import cv2
import numpy as np

def get_video():
     array,_ = freenect.sync_get_video()
     array = cv2.cvtColor(array,cv2.COLOR_RGB2BGR)
     return array

def get_depth():
    array,_ = freenect.sync_get_depth()
    array = array.astype(np.uint8)
    return array
if __name__ == "__main__":
   while 1:
       #get a frame from RGB camera
       frame = get_video()
       #get a frame from depth sensor
       depth = get_depth()
       #display RGB image
       cv2.imshow('RGB image',frame)
       #display depth image
       cv2.imshow('Depth image',depth)

       # quit program when 'esc' key is pressed
       k = cv2.waitKey(5) & 0xFF
        if k == 27:
            break
   cv2.destroyAllWindows()
edit retag flag offensive close merge delete

Comments

and the problem is ?

berak gravatar imageberak ( 2018-10-06 06:24:57 -0600 )edit

Must you use Python, or is C++ good? Also, which version of the Kinect are you using... Xbox 360 or Xbox One?

sjhalayka gravatar imagesjhalayka ( 2018-10-06 13:40:32 -0600 )edit

its XBOX 360.....and Python

KRK gravatar imageKRK ( 2018-10-06 16:49:51 -0600 )edit

You can try OpenEXR image file format.

I usually use this format when saving the depth map from Blender and when I want to read it with OpenCV.

Other file formats that allow saving 16 bits or more are good also.

Eduardo gravatar imageEduardo ( 2018-10-06 17:16:49 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
1

answered 2018-10-06 09:58:32 -0600

kbarni gravatar image

Depth image is generally 16 bit (unsigned short) data. Most image and video formats don't support this.

The best solution is to use compatible image formats, like TIF or PNG. I think imwrite supports CV_16U type for these formats (anyway, check the type of the depth matrix).

Another solution would be to dump the raw data into a binary file. A bit more work, but it will surely work.

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2018-10-06 06:22:28 -0600

Seen: 1,940 times

Last updated: Oct 06 '18

Related questions