Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import cv2
- import os
- import shutil
- import datetime
- import requests
- key = cv2.waitKey(1)
- webcam = cv2.VideoCapture(0)
- name = datetime.datetime.now()
- filename = str(name)+'.jpg'
- def record(nf):
- while True:
- check, frame = webcam.read()
- print(check) #prints true as long as the webcam is running
- print(frame) #prints matrix values of each framecd
- cv2.imshow("Capturing", frame)
- key = cv2.waitKey(1)
- if key == ord('s'):
- url = "http://localhost:8000/upload"
- cv2.imwrite(nf, frame)
- image = open(nf, 'rb')
- files = {'file': image}
- r = requests.post(url, files=files)
- print(r)
- os.remove(nf)
- break
- elif key == ord('q'):
- print("Turning off camera.")
- webcam.release()
- print("Camera off.")
- break
- record(filename)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement