我正在使用连接到raspberrypi3B +的两个摄像头进行图像处理。我收到一个错误“选择时间错误” .... enter image description here
from collections import deque
import numpy as np
import argparse
import imutils
import cv2
import time
from multiprocessing import Process, Queue
class opencv:
def __init__(self):
self.FrameWidth = 640
self.FrameHeight = 480
def rescale_frame(self, frame, percent=75):
width = int(frame.shape[1] * percent/ 100)
height = int(frame.shape[0] * percent/ 100)
dim = (width, height)
return cv2.resize(frame, dim, interpolation =cv2.INTER_AREA),width,height
def cam(self, video):
camera = cv2.VideoCapture(video)
camera.set(3, self.FrameWidth)
camera.set(4, self.FrameHeight)
while True:
(grab, frame) = camera.read()
frame,width,height = self.rescale_frame(frame, percent= 30) # pixcel 50%
cv2.circle(frame, (round(width/2), round(height/2)), 1, (0, 255, 255), 3)
cv2.imshow("Frame", frame)
key = cv2.waitKey(60) & 0xFF
if (key == 27):
break
if (key == ord('i')):
while True:
cv2.imshow("Frame", frame)
cv2.waitKey(0)
if key == ord('i'):
break
camera.release()
cv2.destroyAllWindows()
if __name__ == "__main__":
cam0 = opencv()
cam1 = opencv()
p1 = Process(target = cam0.cam, args = (0,))
p2 = Process(target = cam1.cam, args = (1,))
p1.start()
p2.start()
出什么问题了?电源问题? (我正在使用usb-hub向网络摄像头供电。)我尝试使用Pi-cam和网络摄像头运行相同的代码,并且可以正常工作,但我更喜欢使用网络摄像头,而不是Pi-cam(当时Pi-cam性能不不太好