def test_sole_image_without_face_doesnt_sent_to_recognition(self, skeleton, face_detect, send_to): return pdu = HeadCrop() pdu.process_message(self._image_message()) face_detect.assert_called_once_with() eq_(skeleton.call_count, 0, "crop_head should only be called if it has " "a corresponding image and skeleton") eq_(send_to.call_count, 0, "send_to should only be called if it has " "a corresponding image and skeleton")
def test_sole_image_without_face_doesnt_sent_to_recognition(self, skeleton, face_detect, send_to): pdu = HeadCrop(debug=True) message = RouterFactory('image_rgb') pdu.process_message(message) face_detect.assert_called_once_with(message['image_rgb']) eq_(skeleton.call_count, 0, "crop_head should only be called if it has " "a corresponding image and skeleton") eq_(send_to.call_count, 0, "send_to should only be called if it has " "a corresponding image and skeleton")
def test_sole_skeleton_doesnt_send_to_recognition(self, skeleton, face_detect, send_to): pdu = HeadCrop(debug=True) message = RouterFactory('skeleton') pdu.process_message(message) eq_(skeleton.call_count, 0, "crop_head should only be called if it has " "a corresponding image and skeleton") eq_(send_to.call_count, 0, "send_to should only be called if it has " "a corresponding image and skeleton") eq_(face_detect.call_count, 0, "face_detect should only be called if it has " "a corresponding image and skeleton")
def test_one_image_and_one_skeleton_not_close_enough(self, skeleton, face_detect, send_to): return pdu = HeadCrop() pdu.process_message(self._skeleton_message()) time.sleep(pdu.MAX_TIME) pdu.process_message(self._image_message()) face_detect.assert_called_once_with() eq_(skeleton.call_count, 0, "crop_head should only be called if it has " "a corresponding image and skeleton") eq_(send_to.call_count, 0, "send_to should only be called if it has " "a corresponding image and skeleton")
def test_one_image_and_one_skeleton_close_enough(self, skeleton, face_detect, send_to): pdu = HeadCrop(debug=True) skeleton_message = RouterFactory('skeleton') pdu.process_message(skeleton_message) image_message = RouterFactory('image_rgb') pdu.process_message(image_message) eq_(face_detect.call_count, 0, "face_detect should only be called if " "it has a corresponding image and skeleton") skeleton.assert_called_once_with(image_message['image_rgb'], skeleton_message['skeleton_3D']) send_to.assert_called_once_with('face-recognition', ANY)
def test_one_image_and_one_skeleton_not_close_enough(self, skeleton, face_detect, send_to): pdu = HeadCrop(debug=True) skeleton_message = RouterFactory('skeleton') pdu.process_message(skeleton_message) time.sleep(MAX_TIME) image_message = RouterFactory('image_rgb') pdu.process_message(image_message) face_detect.assert_called_once_with(image_message['image_rgb']) eq_(skeleton.call_count, 0, "crop_head should only be called if it has " "a corresponding image and skeleton") eq_(send_to.call_count, 0, "send_to should only be called if it has " "a corresponding image and skeleton")
def test_send_message_to_redis_when_cropped_head(self, session_store_mock): orig_fn = head_crop.crop_head head_crop.crop_head = one_by_one_image pdu = HeadCrop(debug=True) image_message = RouterFactory('image_rgb') pdu.process_message(image_message) time.sleep(1.0) sid = image_message['session_id'] t = image_message['created_at'] info = {'head': one_by_one_image(None)} session_store_mock.assert_called_once_with(sid, t, info) head_crop.crop_head = orig_fn
def test_one_image_and_one_skeleton_close_enough(self, skeleton, face_detect, send_to): # TODO(andrei): seems to me like this doesn't get run properly # due to the fact that it's a parallel PDU. Suggestion: let's implement # a "debug" mode for parallel PDUs without a worker pool. return pdu = HeadCrop() pdu.process_message(self._skeleton_message()) pdu.process_message(self._image_message()) time.sleep(1.0) eq_(face_detect.call_count, 0, "face_detect should only be called if it has " "a corresponding image and skeleton") face_recognition_message = { 'head_image': { 'width': 1, 'image': 'AAAA', 'height': 1 } } send_to.assert_called_once_with('face-recognition', face_recognition_message) skeleton.assert_called_once_with()