Answers for "open cv webcan output python"

7

how to read video in opencv python

import numpy as np
import cv2
cap = cv2.VideoCapture('videos/wa.avi')
while(cap.isOpened()):
  ret, frame = cap.read()
  gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
  cv2.imshow('frame',gray)
  if cv2.waitKey(1) & 0xFF == ord('q'):
    break

cap.release()
cv2.destroyAllWindows()
Posted by: Guest on June-18-2020
0

access webcam using opencv

import cv2

cap = cv2.VideoCapture(0)

while True:
  ret, frame = cap.read()
  
  cv2.imshow('webcam feed' , frame)
  if cv2.waitKey(1) & 0xFF == ord(' '):
    break
    
cap.release()
cv2.destroyAllWindows()

#by using the spacebar you will be able to finish the process of video capturing
#in opencv and the window will close
Posted by: Guest on October-04-2020

Python Answers by Framework

Browse Popular Code Answers by Language