我正在尝试在我的PC和PIC18F4550之间进行通信,但是程序没有检测到它,而计算机正在设备管理器中显示它.
import usb.core
dev = usb.core.find(idVendor = 0x04D8, idProduct = 0xFEAA)
Run Code Online (Sandbox Code Playgroud)
检查USB设备的功能:
def find(find_all = False, backend = None, custom_match = None, **args):
def device_iter(k, v):
for dev in backend.enumerate_devices():
d = Device(dev, backend)
if _interop._reduce(lambda a, b: a and b,map(operator.eq,v,map(lambda i:getattr(d,i),k)),True)and (custom_match is None or custom_match(d)):
yield d
if backend is None:
import usb.backend.libusb1 as libusb1
import usb.backend.libusb0 as libusb0
import usb.backend.openusb as openusb
for m in (libusb1, openusb, libusb0):
backend = m.get_backend()
if backend is not …Run Code Online (Sandbox Code Playgroud) import cv2
ram_frames=30
cam = cv2.VideoCapture(0)
def get_image():
cap = cam.read()
return cap
for i in xrange(ramp_frames):
temp = get_image()
image = get_image()
cv2.imwrite('bin/color.jpg',image)
Run Code Online (Sandbox Code Playgroud)
我得到的错误是:
File "C:\modules\imlib.py", line 1035, in __init__
self.imin = self.WinWebCam()
File "C:\modules\imlib.py", line 1125, in WinWebCam
cv2.imwrite('bin/color.jpg',image)
TypeError: img is not a numerical tuple
Run Code Online (Sandbox Code Playgroud)
我做了一切正确我没有改变任何代码,当在一个单独的程序中执行它没有显示任何错误,但在我的代码中运行它显示错误.我复制的代码来自此链接