Reputation: 283
I would like to display on the computer screen the infra-red camera using an XBox Kinect 360. This code below will open a new frame but the display is just a back frame and not the IR video feed. How can I get the frame to display the IR image?
#!/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()
Upvotes: 1
Views: 3107
Reputation: 283
Thanks for the clues Robert Prevost! This code returns a frame showing the IR image.
#!/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()
Upvotes: 1