Skip to content

Commit b11dc03

Browse files
committed
Remove unnecessary subscriber of face recognition data
1 parent 9ed5a33 commit b11dc03

File tree

1 file changed

+1
-56
lines changed

1 file changed

+1
-56
lines changed

coffee_ws/src/coffee_head/coffee_head/camera_node.py

Lines changed: 1 addition & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -112,68 +112,13 @@ def __init__(self, node=None):
112112
self.face_image_pub = node.create_publisher(Image, 'face_images', 10)
113113
self.bridge = CvBridge()
114114

115-
# TODO: REMOVE
116-
# Face recognition subscription
117-
self.face_recognition_sub = node.create_subscription(
118-
String,
119-
'face_recognition_data',
120-
self.face_recognition_callback,
121-
10
122-
)
123-
124115
# Face recognition data
125116
self.face_ids = {} # Map of face index to recognized face ID
126117
self.last_recognition_time = 0
127118
self.recognition_timeout = 3.0 # Clear recognition data after 3 seconds
128119

129120
self.init_face_detector()
130-
131-
# TODO: REMOVE
132-
def face_recognition_callback(self, msg):
133-
"""Process face recognition data from face recognition node"""
134-
try:
135-
recognition_data = json.loads(msg.data)
136-
self.last_recognition_time = time.time()
137-
138-
# Clear existing face IDs
139-
self.face_ids = {}
140-
141-
# Process each recognized face
142-
for face in recognition_data.get('faces', []):
143-
face_id = face.get('id')
144-
position = face.get('position', {})
145-
center_x = int(position.get('center_x', 0))
146-
center_y = int(position.get('center_y', 0))
147-
148-
# Find the corresponding detected face
149-
# Match based on position
150-
best_match_idx = -1
151-
best_match_dist = float('inf')
152-
153-
for i, detected_face in enumerate(self.prev_faces[-1] if self.prev_faces else []):
154-
# Calculate distance between centers
155-
dx = float(detected_face.get('center_x', 0)) - center_x
156-
dy = float(detected_face.get('center_y', 0)) - center_y
157-
dist = (dx**2 + dy**2)**0.5
158-
159-
if dist < best_match_dist and dist < 100: # Max 100px distance for a match
160-
best_match_dist = dist
161-
best_match_idx = i
162-
163-
if best_match_idx >= 0:
164-
# Store the ID with this face index
165-
self.face_ids[best_match_idx] = {
166-
'id': str(face_id),
167-
'confidence': float(face.get('confidence', 0.0)),
168-
'is_new': bool(face.get('is_new', False))
169-
}
170-
171-
except Exception as e:
172-
if self.node:
173-
self.node.get_logger().error(f"Error processing face recognition data: {e}")
174-
import traceback
175-
traceback.print_exc()
176-
121+
177122
def publish_face_data(self, faces):
178123
"""Publish face detection data for other nodes"""
179124
if not self.node:

0 commit comments

Comments
 (0)