简体   繁体   English

PyOpenNI深度生成器刷新

[英]PyOpenNI Depth Generator refresh

I am capturing depth images from the Asus Xtion Live Pro using PyOpenNI . 我正在使用PyOpenNI从Asus Xtion Live Pro捕获深度图像。 Here's a short example of code: 这是一个简短的代码示例:

from openni import *
import numpy as np
import cv2
import time

context = Context()
context.init()

depth = DepthGenerator()
depth.create(context)
depth.set_resolution_preset(RES_VGA)
depth.fps = 30
context.start_generating_all()
context.wait_any_update_all()
frame = np.fromstring(depth.get_raw_depth_map_8(), "uint8").reshape(480, 640)
cv2.imwrite("image.png", frame)

This works fine, but if I want to get a stream flow of depth images with a loop every second, 效果很好,但是如果我想每秒获得一个带有循环的深度图像流,

while True:
   frame = np.fromstring(depth.get_raw_depth_map_8(), "uint8").reshape(480, 640)
   cv2.imwrite("image.png", frame)
   time.sleep(1)

the images are all the same, even though I am moving in front of the sensor. 即使我在传感器前面移动,图像也一样。 It seems that the Xtion does not refresh the acquisition of the environment. 看起来Xtion并没有刷新环境的获取。

I found the solution! 我找到了解决方案! You have to call: 您必须致电:

context.wait_any_update_all()
context.wait_and_update_all()
context.wait_one_update_all(Generator)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM