Я пытаюсь использовать этот код в моем Raspberry pi, но я могу видеть только изображение камеры, а на моем компьютере я уже вижу изображение двух USB-камер, кто-то знает, что происходит, вы можете помочь я?
import threading
class camThread(threading.Thread):
def __init__(self, previewName, camID):
threading.Thread.__init__(self)
self.previewName = previewName
self.camID = camID
def run(self):
print ("Starting " + self.previewName)
camPreview(self.previewName, self.camID)
def camPreview(previewName, camID):
cv2.namedWindow(previewName)
cam = cv2.VideoCapture(camID)
if cam.isOpened(): # try to get the first frame
rval, frame = cam.read()
else:
rval = False
while rval:
cv2.imshow(previewName, frame)
rval, frame = cam.read()
key = cv2.waitKey(20)
if key == 27: # exit on ESC
break
cv2.destroyWindow(previewName)
thread1 = camThread("Camera 1", 0)
thread2 = camThread("Camera 2", 1)
thread1.start()
thread2.start()
оболочка:
Python 3.7.3 (/usr/bin/python3)
>>> %Run cameraa.py
Starting Camera 1Starting Camera 2
/*error*/
>>> Xlib: charsets ISO8859-1:GR and ISO8859-1:GR have the same CT sequence
Xlib: charsets JISX0201.1976-0:GR and JISX0201.1976-0:GR have the same CT sequence
Xlib: charsets JISX0212.1990-0:GL and JISX0212.1990-0:GL have the same CT sequence
Xlib: charsets CNS11643.1986-1:GR and CNS11643.1986-1:GR have the same CT sequence
Xlib: charsets CNS11643.1992-3:GR and CNS11643.1992-3:GR have the same CT sequence
Xlib: charsets CNS11643.1992-5:GR and CNS11643.1992-5:GR have the same CT sequence
Xlib: charsets CNS11643.1992-7:GR and CNS11643.1992-7:GR have the same CT sequence
Xlib: charsets BIG5-E0:GL and BIG5-E0:GL have the same CT sequence
[ WARN:0] global /home/pi/opencv_build/opencv/modules/videoio/src/cap_v4l.cpp (893) open VIDEOIO(V4L2:/dev/video1): can't open camera by index
введите описание изображения здесь