diff --git a/client/sbs_client2.py b/client/sbs_client2.py deleted file mode 100644 index 0dc0bbf65a0e3830c7a35c15430ea9c2155ba6af..0000000000000000000000000000000000000000 --- a/client/sbs_client2.py +++ /dev/null @@ -1,65 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Created on Tue Feb 20 21:33:57 2018 - -@author: veskuh -""" - -import cv2 -import requests -from requests_toolbelt.multipart.encoder import MultipartEncoder -import os - -# Haarcascade for face detection -face_cascade = cv2.CascadeClassifier("./haarcascade/haarcascade_frontalface_default.xml") - -# Image file name and location -image = "./images/image.jpg" - - -# Sending image to server -def sendImage(image): - # Send local image file to tensorflow-client - multipart_data = MultipartEncoder( - fields={ - # a file upload field - "image": ("image.jpg", open(image, "rb"), "image/jpg"), - "stop_code": "Test" - } - ) - - requests.post("http://tensorflow.stop.capstone.utu.fi/api/v1/classifyImage/", data=multipart_data, - headers={"Content-Type": multipart_data.content_type}) - -# Removing image for security purposes -def removeImage(image): - os.remove(image) - -# Taking a picture from default webcam and saving it -def takePicture(image, face_cascade): - # Take picture - cap = cv2.VideoCapture(0) - ret, frame = cap.read() - cv2.imwrite(image,frame) - cap.release() - - # Locate faces - image = cv2.imread(image) - gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY) - faces = face_cascade.detectMultiScale( - gray, - scaleFactor=1.1, - minNeighbors=5, - minSize=(30, 30) - ) - - return len(faces) - -facesDetected = takePicture(image, face_cascade) - -if facesDetected > 0: - print ("Faces detected: " + str(facesDetected)) - sendImage(image) - removeImage(image) -# -#