Spaces:
Sleeping
Sleeping
| import cv2 | |
| import socket | |
| import pickle | |
| import numpy as np | |
| import demo | |
| s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) | |
| ip = "127.0.0.1" | |
| port = 6666 | |
| s.bind((ip,port)) | |
| face_locations = [] | |
| # face_encodings = [] | |
| face_names = [] | |
| process_this_frame = True | |
| score = [] | |
| faces = 0 | |
| while True: | |
| print("Hello") | |
| x = s.recvfrom(1000000) | |
| clientip = x[1][0] | |
| data = x[0] | |
| data = pickle.loads(data) | |
| frame = cv2.imdecode(data, cv2.IMREAD_COLOR) | |
| result, process_this_frame, face_locations, faces, face_names, score = demo.process_frame(frame, process_this_frame, face_locations, faces, face_names, score) | |
| result = cv2.cvtColor(result, cv2.COLOR_BGR2RGB) | |
| cv2.imshow('server side', result) | |
| print(score) | |
| if len(score) > 20: | |
| avg_score = sum(score) / len(score) | |
| break | |
| if cv2.waitKey(5) & 0xFF == 27: | |
| break | |
| cv2.destroyAllWindows() |