Пример #1
0
def img_process(frame):
	#debug
	#video_capture = cv2.VideoCapture(0)
	#ret, frame = video_capture.read()
	#frame = cv2.imread('test2.jpeg')


	faces = opencv.detect_faces(frame)

	main_rect = (0, 0)

	sum_sqr_rect = 0
	# Draw a rectangle around the faces
	for (x, y, w, h) in faces:
		main_rect = (main_rect[0] + x + w/2, main_rect[1] + y + h/2)
		sum_sqr_rect += w*h
		cv2.rectangle(frame, (x, y), (x+w, y+h), (0, 255, 0), 2)

	if 0 != len(faces):
		main_rect = (main_rect[0]/len(faces),main_rect[1]/len(faces))
	else:
		return 0
	w, h = frame.shape[:2]

	return main_rect[0]-h/2, main_rect[1]-w/2, sum_sqr_rect
Пример #2
0
 def process(self, cv_image):
     faces = opencv.detect_faces(cv_image)
     if len(faces) > 0:
         result = json.dumps(faces.tolist())
         self.write_message(result)
Пример #3
0
 def process(self, cv_image):
   faces = opencv.detect_faces(cv_image)
   if len(faces) > 0:
     result = json.dumps(faces.tolist())
     self.write_message(result)