Home Python, Capture image after countdown ends using webcam
Reply: 0

Python, Capture image after countdown ends using webcam

user653
1#
user653 Published in July 21, 2018, 11:29 pm

i want my program to capture image after countdown ends. But during the countdown, i want it to show me the live cam. This is my code.

import cv2
import time
cam = cv2.VideoCapture(0)
countdown=3
img_counter = 0
cv2.namedWindow("test")
ret, frame = cam.read()
cv2.imshow("test", frame)
img_name = "example.png"

while countdown >0:
                time.sleep(1)
                print(countdown)
                countdown -=1
                if countdown == 0:
                    cv2.imwrite(img_name, frame)
                    print("{} written!".format(img_name))

cam.release()

cv2.destroyAllWindows()
You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.3062 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO