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

Fixed new ROS2 msg and OpenCV API change #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions live_detection/live_detection/live_detection_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,15 @@ def listener_callback(self, data):

for i in range(boxes.size(0)):
box = boxes[i, :]
box = box.numpy().astype(int) #convert to numpy and cast as int. OpenCV rectange cannot parse floats
label = f"{self.class_names[labels[i]]}: {probs[i]:.2f}"
print("Object: " + str(i) + " " + label)
cv2.rectangle(cv_image, (box[0], box[1]), (box[2], box[3]), (255, 255, 0), 4)

# Definition of 2D array message and ading all object stored in it.
object_hypothesis_with_pose = ObjectHypothesisWithPose()
object_hypothesis_with_pose.id = str(self.class_names[labels[i]])
object_hypothesis_with_pose.score = float(probs[i])
object_hypothesis_with_pose.hypothesis.class_id = str(self.class_names[labels[i]])
object_hypothesis_with_pose.hypothesis.score = float(probs[i])

bounding_box = BoundingBox2D()
bounding_box.center.x = float((box[0] + box[2])/2)
Expand Down
5 changes: 3 additions & 2 deletions trt_live_detector/trt_live_detector/trt_detection_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,14 +102,15 @@ def listener_callback(self, data):

for i in range(boxes.size(0)):
box = boxes[i, :]
box = box.numpy().astype(int) #convert to numpy and cast as int. OpenCV rectange cannot parse floats
label = f"{self.class_names[labels[i]]}: {probs[i]:.2f}"
print("Object: " + str(i) + " " + label)
cv2.rectangle(cv_image, (box[0], box[1]), (box[2], box[3]), (255, 255, 0), 4)

# Definition of 2D array message and ading all object stored in it.
object_hypothesis_with_pose = ObjectHypothesisWithPose()
object_hypothesis_with_pose.id = str(self.class_names[labels[i]])
object_hypothesis_with_pose.score = float(probs[i])
object_hypothesis_with_pose.hypothesis.class_id = str(self.class_names[labels[i]])
object_hypothesis_with_pose.hypothesis.score = float(probs[i])

bounding_box = BoundingBox2D()
bounding_box.center.x = float((box[0] + box[2])/2)
Expand Down