Skip to content

Instantly share code, notes, and snippets.

@11208
Created June 1, 2018 03:06
Show Gist options
  • Save 11208/b1c229c6997540346e3c5198b96c5b4c to your computer and use it in GitHub Desktop.
Save 11208/b1c229c6997540346e3c5198b96c5b4c to your computer and use it in GitHub Desktop.
Adapter Face Recognition Client
import cv2
import requests
import imutils
from PIL import Image
url = "http://192.168.0.164:5000/detect/faces"
video_capture = cv2.VideoCapture(0)
while True:
ret, frame = video_capture.read()
frame = imutils.resize(frame, width=640)
cv2.imshow('frame',frame)
_, img_encoded = cv2.imencode('.jpg', frame)
files = {'image': img_encoded.tostring()}
headers = {"Authorization":"Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpYXQiOjE1Mjc2NTAxMzksIm5iZiI6MTUyNzY1MDEzOSwianRpIjoiZWQzMzQwMzktYmYyOS00N2I1LTlkYzYtZDk4NmMzZjU5ZDEzIiwiZXhwIjoxNTI3NjUxMDM5LCJpZGVudGl0eSI6ImFkYXB0ZXIiLCJmcmVzaCI6ZmFsc2UsInR5cGUiOiJhY2Nlc3MifQ.EYZJKoje4yDHb6mmDdt4ScgEO8hAGRV-_XEP1I0J1S8"}
response = requests.post(url, files=files, headers=headers)
print(response.text)
cv2.waitKey(1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment