连接6摄像头运行,开始运行正常,能够正常识别,但不小心线动了一下,视频窗口卡死,报错runtime error:
Traceback (most recent call last):
File "D:/20191031_tensorflow_yolov3/tensorflow-yolov3/test-使用locals()函数批量配置摄像头运行识别程序并画框.py", line 206, in <module>
YoloTest().dontla_evaluate_detect()
File "D:/20191031_tensorflow_yolov3/tensorflow-yolov3/test-使用locals()函数批量配置摄像头运行识别程序并画框.py", line 141, in dontla_evaluate_detect
for i in ctx.devices:
RuntimeError
后来添加了打印已连接摄像头个数的代码和打印摄像头序列号和接口号的代码,打印如下:
可看到,摄像头个数为6个,但打印第六个序列号时却未能正常打印
已经在官方github下提问了,等待消息
RuntimeError #5329
趁他们还未回复,先自己折腾一阵。
参考文章1:How do you reset a USB device from the command line?
参考文章2:python3 自动识别usb连接状态,即对usb重连的判断方法
无果。。。
又继续测试这个:usb之python(pyusb)
#!/usr/bin/python
# -*- coding:utf-8 -*-
import usb.util
import sys
#USB\VID_1C4F&PID_0051
dev = usb.core.find(idVendor= 0x1C4F, idProduct= 0x0051)
if dev is None:
raise ValueError('Device not found')
print(dev)
# set the active configuration. With no arguments, the first
# configuration will be the active one
cfg = dev.get_active_configuration()
运行后报错:
File "D:/20191031_tensorflow_yolov3/needed/test/test_Intel_realsense/test_191127_测试usb(已知摄像头序列号).py", line 13, in <module>
dev = usb.core.find(idVendor=0x1C4F, idProduct=0x0051)
File "D:\20191031_tensorflow_yolov3\python\lib\site-packages\usb\core.py", line 1263, in find
raise NoBackendError('No backend available')
usb.core.NoBackendError: No backend available
Process finished with exit code 1
参考Pyusb on windows 8.1 - no backend available - how to install libusb?
后来安装了pyusb
库,还是没法运行,想放弃了。。。
还是按照他的解释从 http://sourceforge.net/projects/libusb/files/libusb-1.0/libusb-1.0.20/libusb-1.0.20.7z/download 下载了libusb-1.0.20.7z
,解压然后拷贝一些文件:
I downloaded latest libusb windows binaries from here: http://sourceforge.net/projects/libusb/files/libusb-1.0/libusb-1.0.20/libusb-1.0.20.7z/download then I copied libusb1.dll according to this: when you are on 64-bit Windows, MS64\dll\libusb-1.0.dll must be copied into C:\Windows\System32 and (for running 32-bit applications that use libusb) MS32\dll\libusb-1.0.dll must be copied into C:\Windows\SysWOW64. and then I copied libusb1.lib from binaries to lib dir in python directory and now pyusb works for me. hope it helps.
我从此处下载了最新的libusb Windows二进制文件:http://sourceforge.net/projects/libusb/files/libusb-1.0/libusb-1.0.20/libusb-1.0.20.7z/download,然后根据此文件复制了libusb1.dll。 :在64位Windows上时,必须将MS64 \ dll \ libusb-1.0.dll复制到C:\ Windows \ System32和(对于运行使用libusb的32位应用程序)MS32 \ dll \ libusb-1.0.dll 必须复制到C:\ Windows \ SysWOW64。 然后将libusb1.lib从二进制文件复制到python目录中的lib dir,现在pyusb对我有用。 希望能帮助到你。
发现可以运行了,但是报错ValueError: Device not found
:
后续内容参考这个吧:python pyusb库使用教程【在window10系统上操作USB】(操作Intel Realsense D435)
看到这个,有点启发:
How to restart USB device(如何重启USB设备)
看看python是否能够调用设备控制台DevCon(Devcon.exe)【先挂起不管】
又看到这个,usb 设备 复位,作者在最后提到了libusb,遂下,libusb 1.0.22b8 ,将之前老版本的libusb删除,包括system32里的等等,但是这个貌似不太友好,找了半天也没找到教程在哪,只有这个:A cross-platform user library to access USB devices
确实太不友好了,看见github上有个libusb1
,看看那个是咋回事
貌似,使用python libusb1库也蛋疼,还是重新回到librealsense去找重置usb的答案吧。。。
提问后,Intel Realsense 官方客服人员MartyG小姐给出了回答,https://github.com/IntelRealSense/librealsense/issues/5345#issuecomment-559583087,让我参考这个#3329 (comment):
ctx = rs.context()
devices = ctx.query_devices()
for dev in devices:
dev.hardware_reset()
How to restart USB device(如何重启USB设备),尝试使用Devcon.exe工具
如何安全的下载Devcon.exe文件
下好后(要根据系统版本号下载哦),解压到一个文件夹里:
右键以管理员身份运行控制台:
参考这里输入命令:Devcon的用法
具体测试结果,请见:devcon的测试 尝试使用devcon命令重置Intel Realsense D435摄像头
发现使用devcon重启也还是不行,有一个摄像头都地址设定失败了。。。不知道怎么把它弄回来?
程序中也是,只要一遍历访问信息就会出错。。。
没办法,看来还是得启用PCIE了:
20190812_Intel Realsense D435 关于摄像头USB掉线问题问题汇总
设置了hardware_reset()并设置了重置后的睡眠时间为5秒,但运行时还是报错了:
D:\20191031_tensorflow_yolov3\python\python.exe D:/20191031_tensorflow_yolov3/tensorflow-yolov3/test-multicam.py
2019-11-30 12:46:21.906107: I tensorflow/core/platform/cpu_feature_guard.cc:141] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2
2019-11-30 12:46:22.838489: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1411] Found device 0 with properties:
name: GeForce GTX 1080 Ti major: 6 minor: 1 memoryClockRate(GHz): 1.6575
pciBusID: 0000:0e:00.0
totalMemory: 11.00GiB freeMemory: 9.10GiB
2019-11-30 12:46:22.996493: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1411] Found device 1 with properties:
name: GeForce GT 710 major: 3 minor: 5 memoryClockRate(GHz): 0.954
pciBusID: 0000:05:00.0
totalMemory: 2.00GiB freeMemory: 1.67GiB
2019-11-30 12:46:22.997060: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1461] Ignoring visible gpu device (device: 1, name: GeForce GT 710, pci bus id: 0000:05:00.0, compute capability: 3.5) with Cuda compute capability 3.5. The minimum required Cuda capability is 3.7.
2019-11-30 12:46:22.997586: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1490] Adding visible gpu devices: 0
2019-11-30 12:46:24.450762: I tensorflow/core/common_runtime/gpu/gpu_device.cc:971] Device interconnect StreamExecutor with strength 1 edge matrix:
2019-11-30 12:46:24.451066: I tensorflow/core/common_runtime/gpu/gpu_device.cc:977] 0 1
2019-11-30 12:46:24.451246: I tensorflow/core/common_runtime/gpu/gpu_device.cc:990] 0: N N
2019-11-30 12:46:24.451422: I tensorflow/core/common_runtime/gpu/gpu_device.cc:990] 1: N N
2019-11-30 12:46:24.451754: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1103] Created TensorFlow device (/job:localhost/replica:0/task:0/device:GPU:0 with 8789 MB memory) -> physical GPU (device: 0, name: GeForce GTX 1080 Ti, pci bus id: 0000:0e:00.0, compute capability: 6.1)
摄像头838212073161重置成功
摄像头836612072369重置成功
摄像头827312071726重置成功
摄像头838212073249重置成功
摄像头827312070790重置成功
摄像头826212070395重置成功
摄像头个数:6
serial number 1:838212073161;usb port:3.2
serial number 2:836612072369;usb port:2.1
serial number 3:827312071726;usb port:3.2
serial number 4:838212073249;usb port:3.2
serial number 5:827312070790;usb port:3.2
serial number 6:826212070395;usb port:3.2
Traceback (most recent call last):
File "D:/20191031_tensorflow_yolov3/tensorflow-yolov3/test-multicam.py", line 241, in <module>
YoloTest().dontla_evaluate_detect()
File "D:/20191031_tensorflow_yolov3/tensorflow-yolov3/test-multicam.py", line 174, in dontla_evaluate_detect
locals()['pipeline' + str(i)].start(locals()['config' + str(i)])
RuntimeError
Process finished with exit code 1