OpenKinect / libfreenect2

Open source drivers for the Kinect for Windows v2 device
2.08k stars 753 forks source link

color_depth_map cannot get a valid value #1072

Open VJoer opened 5 years ago

VJoer commented 5 years ago

hello,When I use apply() to return color_depth_map, I find that the array is all 0.

Below is my part of the code

` undistorted = Frame(512, 424, 4) registered = Frame(512, 424, 4) color_depth_map = np.empty(512*424, dtype = np.int32)

while True: frames = listener.waitForNewFrame()

if enable_rgb:
    color = frames["color"]
if enable_depth:
    ir = frames["ir"]
    depth = frames["depth"]

if enable_rgb and enable_depth:
    registration.apply(color, depth, undistorted, registered, color_depth_map.all())
elif enable_depth:
    registration.undistortDepth(depth, undistorted)

if enable_depth:
    cv2.imshow("ir", ir.asarray() / 65535.)
    cv2.imshow("depth", depth.asarray() / 4500.)
    cv2.imshow("undistorted", undistorted.asarray(np.float32) / 4500.)
    cv2.imshow("undistorted",  undistorted.asarray(np.float32) / 4500.)

if enable_rgb:
    img = cv2.resize(color.asarray(),(int(1920 / 3), int(1080 / 3)))
    cv2.imshow("color", img)
    # img = cv2.cvtColor(color.asarray(), cv2.COLOR_RGBA2RGB)
    # print(img.shape[2])
if enable_rgb and enable_depth:
    cv2.imshow("registered", registered.asarray(np.uint8))
    print(color_depth_map)

listener.release(frames)

key = cv2.waitKey(delay=1)
if key == ord('q'):
    break

` The color_depth_map I got is always 0. I am a beginner and I don't know how to solve it.