I'm using freenect2-python to read frames from kinectv2. Following is my code:
from freenect2 import Device, FrameType
import cv2
import numpy as np
def callback(type_, frame):
print(f'{type_}, {frame.format}')
if type_ is FrameType.Color: # FrameFormat.BGRX
rgb = frame.to_array().astype(np.uint8)
cv2.imshow('rgb', rgb[:,:,0:3])
device = Device()
while True:
device.start(callback)
if cv2.waitKey(1) & 0xFF == ord('q'):
device.stop()
break
The color frame format is FrameFormat.BGRX
, so I'm taking the first 3 channels to show the image. But it shows a blank black window.
I used PIL
but it opens a new window for each frame it receives. Is there a way to show frames in the same window in PIL
?
The
cv2.imshow
couldn't display anything because it was continuously getting updated with a new frame. I addedcv2.waitkey(100)
aftercv2.imshow
and it worked.