Answers for "python web camera make photo"

1

accessing camera with python

import cv2

vid = cv2.VideoCapture(0)

while True:

    ret, frame = vid.read()

    cv2.imshow('Controlling my computer camera', frame)

    if cv2.waitKey(4) & 0xFF == ord('q'):
        break


vid.release()
cv2.destroyAllWindows()
Posted by: Guest on June-30-2021
0

take pictures from webcam python

from cv2 import *
# initialize the camera
cam = VideoCapture(0)   # 0 -> index of camera
s, img = cam.read()
if s:    # frame captured without any errors
    namedWindow("cam-test",CV_WINDOW_AUTOSIZE)
    imshow("cam-test",img)
    waitKey(0)
    destroyWindow("cam-test")
    imwrite("filename.jpg",img) #save image
Posted by: Guest on October-01-2021

Python Answers by Framework

Browse Popular Code Answers by Language