Python 如何在openkinect中停止和启动kinect?
我将openkinect与python绑定一起使用,并运行以下演示应用程序Python 如何在openkinect中停止和启动kinect?,python,kinect,openkinect,Python,Kinect,Openkinect,我将openkinect与python绑定一起使用,并运行以下演示应用程序 #!/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
#!/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
当我按escape时,该程序不会停止。所以我试着执行它如下
#!/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必须重新启动。我不能让它一直执行下去
谁能帮我一下吗。无需停止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键不能将keycode 27传递到
cv.WaitKey
请尝试打印上面的keycodek
,查看按下ESC键时会发生什么情况。无需停止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键不能将keycode 27传递给
cv.WaitKey
请尝试打印上面的keycodek
,看看当您按ESC键时会发生什么。使用“q”的int值而不是“q”使用“q”的int值而不是“q”
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 keycode