Skip to content

Commit 8bc103c

Browse files
committed
Updated FaceDetection for new staging position
1 parent 74137b2 commit 8bc103c

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

feeding_web_app_ros2_test/feeding_web_app_ros2_test/FaceDetection.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ def camera_callback(self, msg):
107107
function will detect faces in the image and publish information about
108108
them to the /face_detection topic.
109109
"""
110+
self.get_logger().debug("Received image")
110111
self.is_on_lock.acquire()
111112
is_on = self.is_on
112113
self.is_on_lock.release()
@@ -161,23 +162,30 @@ def camera_callback(self, msg):
161162
annotated_img = annotated_msg
162163
# Publish the detected mouth center. The below is a hardcoded
163164
# rough position of the mouth from the side staging location,
164-
# in "camera_color_optical_frame." We add 5cm of noise to the
165+
# in "camera_color_optical_frame." We add +/- 5cm of noise to the
165166
# position for added realism
167+
# head_position_from_staging_location = [0.044, -0.130, 0.654]
168+
head_position_from_staging_location = [0.04196, -0.11682, 0.58047]
166169
face_detection_msg.detected_mouth_center = PointStamped()
167170
face_detection_msg.detected_mouth_center.header = msg.header
168171
face_detection_msg.detected_mouth_center.point.x = (
169-
0.044 + (np.random.rand() - 0.5) / 10
172+
head_position_from_staging_location[0]
173+
+ (2 * np.random.rand() - 1) * 0.05
170174
)
171175
face_detection_msg.detected_mouth_center.point.y = (
172-
-0.130 + (np.random.rand() - 0.5) / 10
176+
head_position_from_staging_location[1]
177+
+ (2 * np.random.rand() - 1) * 0.05
173178
)
174179
face_detection_msg.detected_mouth_center.point.z = (
175-
0.654 + (np.random.rand() - 0.5) / 10
180+
head_position_from_staging_location[2]
181+
+ (2 * np.random.rand() - 1) * 0.05
176182
)
177183
else:
184+
face_detection_msg.detected_mouth_center.header = msg.header
178185
annotated_img = msg
179186
face_detection_msg.is_mouth_open = open_mouth_detected
180187
self.publisher_results.publish(face_detection_msg)
188+
self.get_logger().info("Published face detection")
181189
self.publisher_image.publish(annotated_img)
182190

183191

0 commit comments

Comments
 (0)