我正在做一个项目,我必须使用工业摄像头(型号ID:ImageSource DFK 33UX178),我必须在Raspberry PI(OS:Debian Raspberry PI Desktop)上访问它摄像机以前工作正常。但一旦我连接到Windows机器并使用默认的Windows camera应用程序调整其设置,然后尝试使用Raspberry PI OS访问,它就只能捕获黑色图像
下面是我尝试过的命令
命令:sudo fswebcam test.jpg Output of command 1
命令:sudo fswebcam-S 1000 test.jpg Output of command 2
此外,我尝试使用OpenCV脚本(如下所示),但它抛出了错误
import cv2
with cv2.VideoCapture(0) as camera:
ret = camera.set(3,640)
ret = camera.set(4,480)
try:
stream = io.BytesIO()
while(True):
t1 = cv2.getTickCount()
ret, frame = camera.read()
frame_rgb = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
frame_expanded = np.expand_dims(frame_rgb, axis=0)
start_time = time.time()
results = classify_image(interpreter, frame)
elapsed_ms = (time.time() - start_time) * 1000
label_id, prob = results[0]
stream.seek(0)
stream.truncate()
# camera.annotate_text = '%s %.2f\n%.1fms' % (labels[label_id], prob,
# elapsed_ms)
cv2.putText(frame, labels[label_id],(30,50),font,1,(255,255,0),2,cv2.LINE_AA)
cv2.imshow('Object detector', frame)
if cv2.waitKey(1) == ord('q'):
break
finally:
camera.release()
错误:
Traceback (most recent call last):
File "usb_api.py", line 4, in <module>
with cv2.VideoCapture(0) as camera:
AttributeError: __enter__
虽然命令“lsusb”检测摄像机如下所示,即“成像源欧洲有限公司”
Bus 002 Device 004: ID 199e:9082 The Imaging Source Europe GmbH
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 003: ID 046d:c52b Logitech, Inc. Unifying Receiver
Bus 001 Device 002: ID 2109:3431 VIA Labs, Inc. Hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
我对相机的功能有怀疑,所以我再次尝试使用windows机器,它可以正常工作
有人能帮我解决这个问题吗
多谢各位
目前没有回答
相关问题 更多 >
编程相关推荐