Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

image capture from camera python

import cv2

cam = cv2.VideoCapture(0)

cv2.namedWindow("test")

img_counter = 0

while True:
    ret, frame = cam.read()
    if not ret:
        print("failed to grab frame")
        break
    cv2.imshow("test", frame)

    k = cv2.waitKey(1)
    if k%256 == 27:
        # ESC pressed
        print("Escape hit, closing...")
        break
    elif k%256 == 32:
        # SPACE pressed
        img_name = "opencv_frame_{}.png".format(img_counter)
        cv2.imwrite(img_name, frame)
        print("{} written!".format(img_name))
        img_counter += 1

cam.release()

cv2.destroyAllWindows()
Comment

PREVIOUS NEXT
Code Example
Python :: xarray add coordinate 
Python :: openpyxl read excel 
Python :: python list of dates between 
Python :: django form password field 
Python :: matplotlib grid in background 
Python :: pandas series to string without index 
Python :: spress warnings selenium python 
Python :: how to append to every second item in list python 
Python :: python converting float to binary 
Python :: plt line of best fit 
Python :: python get copied text 
Python :: how to create migrations in django 
Python :: select items from dataframe where value is null 
Python :: os.execl(sys.executable, sys.executable, *sys.argv) 
Python :: changing dtype of multiple columns to_datetime 
Python :: base64 decode python 
Python :: how to find if a value is even or odd in python 
Python :: remove all occurrences of a character in a list python 
Python :: How to use tqdm with pandas apply 
Python :: how to get variable from setings django 
Python :: drop columns pandas 
Python :: how to append rows to a numpy matrix 
Python :: pandas fillna with median of column 
Python :: decode url python 
Python :: python display object attributes 
Python :: django migrate using db 
Python :: last element in dictionary python 
Python :: python random email generator 
Python :: figure title python 
Python :: how to send audio with inline telebot 
ADD CONTENT
Topic
Content
Source link
Name
8+8 =