Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Don't used extra while condition block. Just used one condition block. Here is code:

import cv2 as cv

cap = cv.VideoCapture(0)
cap1 = cv.VideoCapture(1)
while True:
   ret, img = cap.read()
   ret1, img1 = cap1.read()
   img1 = cv.resize(img,(360,240))
   img2 = cv.resize(img1,(360,240))
   if cap:
       cv.imshow('img1',img)
   if cap1:
       cv.imshow('img2',img2)

   k = cv.waitKey(0) 
   if k == 27:
      break

cap.release()
cap1.release()
cv.destroyAllWindows()

Don't used extra while condition block. Just used one condition block. Here is code:

import cv2 as cv

cap = cv.VideoCapture(0)
cap1 = cv.VideoCapture(1)
while True:
   ret, img = cap.read()
   ret1, img1 = cap1.read()
   img1 = cv.resize(img,(360,240))
   img2 = cv.resize(img1,(360,240))
   if cap:
       cv.imshow('img1',img)
   if cap1:
       cv.imshow('img2',img2)

   k = cv.waitKey(0) 
   if k == 27:
      break

cap.release()
cap1.release()
cv.destroyAllWindows()

Updated: This may work for pc:

import cv2 as cv

cap = cv.VideoCapture(0)
cap1 = cv.VideoCapture(1)

if cap.isOpened()== False):
    print("Error camera 1 isn't connecting")
   if cap1.isOpened()== False):
       print("Error camera 2 isn't connecting")

while (cap.isOpened() or cap1.isOpened()):
   ret, img = cap.read()
   ret1, img1 = cap1.read()
   if ret == True:
       cv.imshow('Video 1',img)
       cv.imshow('Video 2',img1)

   if cv.waitKey(20) and 0xFF == ord('q'):
        break

cap.release()
cap1.release()
cv.destroyAllWindows()

Don't used extra while condition block. Just used one condition block. Here is code:

import cv2 as cv

cap = cv.VideoCapture(0)
cap1 = cv.VideoCapture(1)
while True:
   ret, img = cap.read()
   ret1, img1 = cap1.read()
   img1 = cv.resize(img,(360,240))
   img2 = cv.resize(img1,(360,240))
   if cap:
       cv.imshow('img1',img)
   if cap1:
       cv.imshow('img2',img2)

   k = cv.waitKey(0) 
   if k == 27:
      break

cap.release()
cap1.release()
cv.destroyAllWindows()

Updated: This may work for pc:

import cv2 as cv

cap = cv.VideoCapture(0)
cap1 = cv.VideoCapture(1)

if cap.isOpened()== False):
    print("Error camera 1 isn't connecting")
 

if cap1.isOpened()== False): print("Error camera 2 isn't connecting") connecting")

while (cap.isOpened() or cap1.isOpened()):
   ret, img = cap.read()
   ret1, img1 = cap1.read()
   if ret == True:
       cv.imshow('Video 1',img)
       cv.imshow('Video 2',img1)

   if cv.waitKey(20) and 0xFF == ord('q'):
        break

cap.release()
cap1.release()
cv.destroyAllWindows()

Don't used extra while condition block. Just used one condition block. Here is code:

import cv2 as cv

cap = cv.VideoCapture(0)
cap1 = cv.VideoCapture(1)
while True:
   ret, img = cap.read()
   ret1, img1 = cap1.read()
   img1 = cv.resize(img,(360,240))
   img2 = cv.resize(img1,(360,240))
   if cap:
       cv.imshow('img1',img)
   if cap1:
       cv.imshow('img2',img2)

   k = cv.waitKey(0) 
   if k == 27:
      break

cap.release()
cap1.release()
cv.destroyAllWindows()

Updated: This may work for pc:

import cv2 as cv

cap = cv.VideoCapture(0)
cap1 = cv.VideoCapture(1)

if cap.isOpened()== False):
    print("Error camera 1 isn't connecting")

if cap1.isOpened()== False): print("Error camera 2 isn't connecting")

connecting")

while (cap.isOpened() or cap1.isOpened()):
   ret, img = cap.read()
   ret1, img1 = cap1.read()
   if ret == True:
       cv.imshow('Video 1',img)
       cv.imshow('Video 2',img1)

   if cv.waitKey(20) and 0xFF == ord('q'):
        break

cap.release()
cap1.release()
cv.destroyAllWindows()