r9y9/pylibfreenect2

how to read a frame map by frame

yzf123456 opened this issue · 2 comments

Hello,
I have already installed pylibfreenect2, and can open kinect 2 in Python. I want to read image information frame by frame, but I don't know how to write the code?Someone has relevant source code, I am very grateful.

r9y9 commented

Please see

while True:
frames = listener.waitForNewFrame()
color = frames["color"]
ir = frames["ir"]
depth = frames["depth"]
registration.apply(color, depth, undistorted, registered,
bigdepth=bigdepth,
color_depth_map=color_depth_map)
# NOTE for visualization:
# cv2.imshow without OpenGL backend seems to be quite slow to draw all
# things below. Try commenting out some imshow if you don't have a fast
# visualization backend.
cv2.imshow("ir", ir.asarray() / 65535.)
cv2.imshow("depth", depth.asarray() / 4500.)
cv2.imshow("color", cv2.resize(color.asarray(),
(int(1920 / 3), int(1080 / 3))))
cv2.imshow("registered", registered.asarray(np.uint8))
if need_bigdepth:
cv2.imshow("bigdepth", cv2.resize(bigdepth.asarray(np.float32),
(int(1920 / 3), int(1082 / 3))))
if need_color_depth_map:
cv2.imshow("color_depth_map", color_depth_map.reshape(424, 512))
listener.release(frames)
key = cv2.waitKey(delay=1)
if key == ord('q'):
break
.

@https://github.com/r9y9,Thank you very much for your answer.