Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Robust-detections #217

Merged
merged 32 commits into from
Jun 16, 2024
Merged

Robust-detections #217

merged 32 commits into from
Jun 16, 2024

Conversation

m-barker
Copy link
Collaborator

No description provided.

@m-barker m-barker marked this pull request as ready for review June 16, 2024 11:55
@m-barker m-barker requested a review from jws-1 June 16, 2024 11:55
Copy link
Member

@jws-1 jws-1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fantastic work! Looks good to me. Some minor refactoring suggestions, but feel free to ignore!

skills/src/lasr_skills/vision/get_cropped_image.py Outdated Show resolved Hide resolved
skills/src/lasr_skills/vision/get_cropped_image.py Outdated Show resolved Hide resolved
skills/src/lasr_skills/vision/get_cropped_image.py Outdated Show resolved Hide resolved
skills/src/lasr_skills/vision/get_cropped_image.py Outdated Show resolved Hide resolved
Comment on lines 105 to 117
for det in detections:
x, y, _, _ = det.xywh[0], det.xywh[1], det.xywh[2], det.xywh[3]
det_center_x = x
det_center_y = y
det_dist = np.sqrt(
(x_to_compare - det_center_x) ** 2 + (y_to_compare - det_center_y) ** 2
)
if det_dist < dist:
dist = det_dist
detection = det

if detection is None:
raise ValueError("No detections found")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
for det in detections:
x, y, _, _ = det.xywh[0], det.xywh[1], det.xywh[2], det.xywh[3]
det_center_x = x
det_center_y = y
det_dist = np.sqrt(
(x_to_compare - det_center_x) ** 2 + (y_to_compare - det_center_y) ** 2
)
if det_dist < dist:
dist = det_dist
detection = det
if detection is None:
raise ValueError("No detections found")
if not detections:
raise ValueError("No detections found")
detection = min(detections, key = lambda det : np.sqrt(x_to_compare - det.xywh[0]) ** 2 + (y_to_compare - det.xywh[1]) ** 2))

skills/src/lasr_skills/vision/get_cropped_image.py Outdated Show resolved Hide resolved
if self._crop_method in self._valid_2d_methods:
img_msg = rospy.wait_for_message(self._rgb_topic, Image)
detections = self._yolo_2d(
img_msg, "yolov8x.pt", 0.5, 0.3
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe the model, confidence and nms threshold should be given in the constructor?

@m-barker m-barker merged commit 22be61f into LASR-at-Home:main Jun 16, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants