|
1 | 1 | #!/usr/bin/env python |
2 | 2 |
|
| 3 | +import os |
| 4 | +import sys |
| 5 | + |
| 6 | +import diagnostic_updater |
3 | 7 | import rospy |
4 | 8 | from cv_bridge import CvBridge, CvBridgeError |
5 | | - |
6 | | -from image_recognition_msgs.srv import Recognize, Annotate |
7 | 9 | from image_recognition_msgs.msg import Recognition, Recognitions, CategoryProbability, CategoricalDistribution |
| 10 | +from image_recognition_msgs.srv import Recognize, Annotate |
| 11 | +from image_recognition_util import image_writer |
| 12 | +from openface_ros.face_recognizer import FaceRecognizer |
8 | 13 | from sensor_msgs.msg import RegionOfInterest, Image |
9 | 14 | from std_srvs.srv import Empty |
10 | | -import diagnostic_updater |
11 | | - |
12 | | -import os |
13 | | -import sys |
14 | | - |
15 | | -from image_recognition_util import image_writer |
16 | | -from openface_ros.face_recognizer import FaceRecognizer, RecognizedFace |
17 | 15 |
|
18 | 16 |
|
19 | 17 | class OpenfaceROS: |
@@ -75,8 +73,8 @@ class OpenfaceROS: |
75 | 73 | raise Exception("Could not convert to opencv image: %s" % str(e)) |
76 | 74 |
|
77 | 75 | for annotation in req.annotations: |
78 | | - roi_image = bgr_image[annotation.roi.y_offset:annotation.roi.y_offset+annotation.roi.height, |
79 | | - annotation.roi.x_offset:annotation.roi.x_offset + annotation.roi.width] |
| 76 | + roi_image = bgr_image[annotation.roi.y_offset:annotation.roi.y_offset + annotation.roi.height, |
| 77 | + annotation.roi.x_offset:annotation.roi.x_offset + annotation.roi.width] |
80 | 78 |
|
81 | 79 | if self._save_images_folder: |
82 | 80 | image_writer.write_annotated(self._save_images_folder, roi_image, annotation.label, True) |
@@ -184,8 +182,8 @@ class OpenfaceROS: |
184 | 182 | def restore_trained_faces(self, file_name): |
185 | 183 | self._face_recognizer.restore_trained_faces(file_name) |
186 | 184 |
|
187 | | -if __name__ == '__main__': |
188 | 185 |
|
| 186 | +if __name__ == '__main__': |
189 | 187 | rospy.init_node("face_recognition") |
190 | 188 |
|
191 | 189 | try: |
|
0 commit comments