Save depth video recorded with kinect360

2

I'm trying to save a video segment from the depth image of a 360 kinect, but when I watch that video, I get an error saying that the stream could not be demultiplexed. that I am unable to identify its origin. I have tried to change the fps and the screen resolution but I still have the same problem. The code is as follows:

import freenect
import cv2
import numpy as np

#function to get RGB image from kinect
def get_video():
    array,_ = freenect.sync_get_video()
    array = cv2.cvtColor(array,cv2.COLOR_RGB2BGR)
    return array

#function to get depth image from kinect
def get_depth():
    array,_ = freenect.sync_get_depth()
    array = array.astype(np.uint8)
    return array


fourcc = cv2.VideoWriter_fourcc(*'XVID')
out = cv2.VideoWriter('output.avi',fourcc, 20.0, (640,480))

if __name__ == "__main__":

    cont = 1
    dirframe = 'frame/'
    dirdepth = 'depth/'

    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)

    for i in xrange(479):
        for j in xrange(639):
            if depth[i][j]<=180 and depth[i][j]>=130: depth[i][j]=255
            else: depth[i][j]=0

        #display depth image

        cv2.imshow('Depth image',depth)

    #save depth video

    out.write(depth)

    #save images

    cv2.imwrite(dirframe+'frame'+str(cont)+'.png',frame)
        cv2.imwrite(dirdepth+'depth'+str(cont)+'.png',depth)

    cont = cont + 1

        # quit program when 'esc' key is pressed
        k = cv2.waitKey(5) & 0xFF
        if k == 27:
            break
    cv2.destroyAllWindows()
    
asked by Javier 22.03.2018 в 13:09
source

1 answer

0

Have you used matlab? Do you want to do something like this? link

    
answered by 28.03.2018 в 02:30