Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

how to open webcam with python

import cv2

cap = cv2.VideoCapture(0)

# Check if the webcam is opened correctly
if not cap.isOpened():
    raise IOError("Cannot open webcam")

while True:
    ret, frame = cap.read()
    frame = cv2.resize(frame, None, fx=0.5, fy=0.5, interpolation=cv2.INTER_AREA)
    cv2.imshow('Input', frame)

    c = cv2.waitKey(1)
    if c == 27:
        break

cap.release()
cv2.destroyAllWindows()
Comment

how to open webcam with python

import cv2

cap = cv2.VideoCapture(0)

# Check if the webcam is opened correctly
if not cap.isOpened():
    raise IOError("Cannot open webcam")

while True:
    ret, frame = cap.read()
    frame = cv2.resize(frame, None, fx=0.5, fy=0.5, interpolation=cv2.INTER_AREA)
    cv2.imshow('Input', frame)

    c = cv2.waitKey(1)
    if c == 27:
        break

cap.release()
cv2.destroyAllWindows()
Comment

PREVIOUS NEXT
Code Example
Python :: pylsp install 
Python :: conda create environment 
Python :: how to automatically copy an output to clipboard in python 
Python :: reset_index pandas 
Python :: matplotlib figsize 
Python :: python print exception message and stack trace 
Python :: NAN values count python 
Python :: python convert list to true falsebased on condition 
Python :: boucle for python 
Python :: python alphabet capital 
Python :: pandas remove timezone info 
Python :: pandas drop unnamed columns 
Python :: python date add days 
Python :: shutdown/restart windows with python 
Python :: webhook discord files 
Python :: python delete saved image 
Python :: how to shuffle dictionary python 
Python :: python reload module without restarting 
Python :: export data csv python 
Python :: get all environment variables python 
Python :: verify django has been installed 
Python :: how to check if column has na python 
Python :: translate sentences in python 
Python :: how to get size of folder python 
Python :: choice random word in python from a text file 
Python :: what to do in python when you get pygame.Surface object is not callable 
Python :: python underscore variable 
Python :: python youtube downloader mp3 
Python :: array of 1 to 100 python 
Python :: python show interpreter path 
ADD CONTENT
Topic
Content
Source link
Name
4+8 =