1

我想使用 Xbox Kinect 360 在计算机屏幕上显示红外摄像机。下面的代码将打开一个新帧,但显示只是一个后帧,而不是 IR 视频馈送。如何让框架显示红外图像?

#!/usr/bin/python
import freenect
import cv2
def get_video():
    array,_ = freenect.sync_get_video(0,freenect.VIDEO_IR_10BIT)
    return array
if __name__ == "__main__":
    while 1:
        #get a frame from RGB camera
        frame = get_video()
        #display IR image
        cv2.imshow('IR image',frame)
        # quit program when 'esc' key is pressed
        k = cv2.waitKey(5) & 0xFF
        if k == 27:
            break
    cv2.destroyAllWindows()
4

1 回答 1

1

感谢罗伯特·普雷沃提供的线索!此代码返回显示 IR 图像的帧。

#!/usr/bin/python
import freenect
import numpy as np
import cv2

def get_video():
    array,_ = freenect.sync_get_video(0,freenect.VIDEO_IR_10BIT)
    return array
def pretty_depth(depth):
    np.clip(depth, 0, 2**10-1, depth)
    depth >>=2
    depth=depth.astype(np.uint8)
    return depth
if __name__ == "__main__":
    while 1:
        #get a frame from RGB camera
        frame = get_video()
        #display IR image
        frame = pretty_depth(frame)
        cv2.imshow('IR image',frame)

        # quit program when 'esc' key is pressed
        k = cv2.waitKey(5) & 0xFF
        if k == 27:
            break
    cv2.destroyAllWindows()
于 2016-10-24T21:49:24.830 回答