2017-08-16 117 views
1

我有一個問題,在樹莓派上使用Kinect。 當我用libfreenect運行我的程序時,運行程序時出現錯誤,之後我再次執行了更多操作,突然系統有了工作,我的kinect喚醒並運行我的程序。 請幫忙。我的錯誤是:樹莓派有一個錯誤kinect

send_cmd: Input control transfer failed (18) 
freenect_fetch_reg_const_shift: send_cmd read 18 bytes (expected 8) 
freenect_camera_init(): Failed to fetch const shift for device 
Error: Invalid index [0] 
Error: Can't open device. 1.) is it plugged in? 2.) Read the README 
Traceback (most recent call last): 
    File "9605019hsn2.py", line 64, in <module> 
    depth = getDepthMap() 
    File "9605019hsn2.py", line 42, in getDepthMap 
    depth, timestamp = freenect.sync_get_depth() 
TypeError: 'NoneType' object is not iterable 

回答

0

顯然,freenect.sync_get_depth()回報None,當你嘗試存儲到這個depth, timestamp失敗,因爲None不迭代。

重構這個代碼,並做適當的錯誤處理:

d = freenect.sync_get_depth() 
if d is not None: 
    depth, timestamp = d 
else: 
    error()