Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # -*- coding: utf-8 -*-
- """
- Created on Sun Apr 5 01:55:37 2020
- @author: USER
- """
- import serial
- import time
- import face_recognition
- import cv2
- # Get a reference to webcam #0 (the default one)
- video_capture = cv2.VideoCapture(0)
- # Initialize some variables
- face_locations = []
- counter = 0
- send=serial.Serial('COM4',115200)
- time.sleep(5)
- send.write(b'mac join abp')
- while True:
- # Grab a single frame of video
- ret, frame = video_capture.read()
- # Resize frame of video to 1/4 size for faster face detection processing
- small_frame = cv2.resize(frame, (0, 0), fx=0.25, fy=0.25)
- # Find all the faces and face encodings in the current frame of video
- face_locations = face_recognition.face_locations(small_frame, model="cnn")
- if(len(face_locations) >= 1):
- print("I found {} face(s) in this photograph.".format(len(face_locations)))
- #while True:
- time.sleep(5)
- send.write(b'mac tx ucnf 2 024945121225')
- else:
- print("Nothing here")
- # Display the results
- cv2.imshow('Video', small_frame)
- # Hit 'q' on the keyboard to quit!
- if cv2.waitKey(1) & 0xFF == ord('q'):
- break
- # Release handle to the webcam
- video_capture.release()
- cv2.destroyAllWindows()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement