webcams.py 857 Bytes
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
# -*- coding: utf-8 -*-
"""
Spyder Editor

This is a temporary script file.
"""

import cv2

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

while(True):
    # Capture frame-by-frame
    ret, frame = cap.read()
    ret1, frame1 = cap1.read()
    # Our operations on the frame come here
    gray = cv2.cvtColor(frame, 0)
    gray1 = cv2.cvtColor(frame1, 0)
    # Display the resulting frame
    frame = cv2.resize(frame, None, fx = 0.5, fy = 0.5, interpolation = cv2.INTER_CUBIC)
    frame1 = cv2.resize(frame1, None, fx = 0.5, fy = 0.5, interpolation = cv2.INTER_CUBIC)
    final_frame = cv2.vconcat((frame, frame1))
    cv2.imshow('final_frame',final_frame)
    #cv2.imshow('frame1',gray1)
    
    if cv2.waitKey(1) & 0xFF == ord('q'):
        break
        cap.release()
        cv2.destroyAllWindows()

# When everything done, release the capture