我需要帮助...我需要在Python的1个窗口中放置4个摄像机...我已经完成了这段代码,但是在不同的窗口中有4个摄像机
import cv2
import numpy as np
cam = cv2.VideoCapture(0)
cap = cv2.VideoCapture(1)
cap2 = cv2.VideoCapture(2)
cap3 = cv2.VideoCapture(3)
while True:
ret, frame = cap.read()
ret, frame2 = cam.read()
ret, frame3 = cap2.read()
ret, frame4 = cap3.read()
cv2.namedWindow("frame", cv2.WINDOW_NORMAL)
cv2.namedWindow("frame2", cv2.WINDOW_NORMAL)
cv2.namedWindow("frame3", cv2.WINDOW_NORMAL)
cv2.namedWindow("frame4", cv2.WINDOW_NORMAL)
cv2.imshow('frame', frame)
cv2.imshow('frame2', frame2)
cv2.imshow('frame3', frame3)
cv2.imshow('frame4', frame4)
if cv2.waitKey(1) & 0xFF == ord('q'):
break
cap.release()
cam.release()
cap2.release()
cap3.release()
cv2.destroyAllWindows()
如果您能帮助我,我将不胜感激,我已经尝试了一个多月