我正在使用带有python绑定的openkinect,并运行以下演示应用程序...
#!/usr/bin/env python
import freenect
import cv
import frame_convert
cv.NamedWindow('Depth')
cv.NamedWindow('Video')
print('Press ESC in window to stop')
def get_depth():
return frame_convert.pretty_depth_cv(freenect.sync_get_depth()[0])
def get_video():
return frame_convert.video_cv(freenect.sync_get_video()[0])
while 1:
cv.ShowImage('Depth', get_depth())
cv.ShowImage('Video', get_video())
if cv.WaitKey(10) == 27:
break当我按下Ess键时,这个程序不会停止。因此,我尝试执行它,如下所示
#!/usr/bin/env python
import freenect
import cv
import frame_convert
cv.NamedWindow('Depth')
cv.NamedWindow('Video')
print('Press ESC in window to stop')
def get_depth():
return frame_convert.pretty_depth_cv(freenect.sync_get_depth()[0])
def get_video():
return frame_convert.video_cv(freenect.sync_get_video()[0])
for i in range(10):
cv.ShowImage('Depth', get_depth())
cv.ShowImage('Video', get_video())
if cv.WaitKey(10) == 27:
break只执行10次。
问题是程序永远不会停止并继续显示图像。我认为需要停止kinect。
我想要拍摄特定时间实例的深度图像。因此,这意味着kinect必须重新启动。我不能让它一直在执行。
有人能在这方面帮我一下吗?
发布于 2012-03-27 05:41:54
没有必要停止Kinect:似乎打破while的条件从未得到满足。这可能取决于平台、opencv版本和其他几个因素。尝试如下所示:
while 1:
cv.ShowImage('Depth', get_depth())
cv.ShowImage('Video', get_video())
k = cv.WaitKey(10) # k contains integer keycode
if chr(k) == 'q': # press q to exit
break要仔细检查为什么按ESC键没有将键码27传递给cv.WaitKey,请尝试打印上面的键码k,看看当您按ESC键时会发生什么。
发布于 2014-02-07 04:08:56
使用“q”的int值而不是“q”
发布于 2014-09-14 08:20:55
k=0
while k != 1048689: # key value of 'q' is 1048689
cv.ShowImage('Depth', get_depth())
cv.ShowImage('Video', get_video())
k = cv.WaitKey(10) # k contains integer keycodehttps://stackoverflow.com/questions/9826618
复制相似问题