Git Product home page Git Product logo

Comments (4)

knorth55 avatar knorth55 commented on May 28, 2024 1

Your suggestions works good with a value of 2.0, but it wonders me, how the node could echo the pixel values faster than the incoming Image message...

The node just keeps the old image and use it to publish in >2Hz.

def visualize_cb(self, event):
if (not self.visualize or self.img is None or self.encoding is None
or self.header is None or self.bboxes is None
or self.labels is None or self.scores is None):
return
with self.lock:
vis_img = self.img.copy()
encoding = copy.copy(self.encoding)
header = copy.deepcopy(self.header)
bboxes = self.bboxes.copy()
labels = self.labels.copy()
scores = self.scores.copy()
# bbox
cmap = matplotlib.cm.get_cmap('hsv')
n = max(len(bboxes) - 1, 10)
for i, (bbox, label, score) in enumerate(zip(bboxes, labels, scores)):
rgba = np.array(cmap(1. * i / n))
color = rgba[:3] * 255
label_text = '{}, {:.2f}'.format(self.label_names[label], score)
p1y = max(bbox[0], 0)
p1x = max(bbox[1], 0)
p2y = min(bbox[2], vis_img.shape[0])
p2x = min(bbox[3], vis_img.shape[1])
cv2.rectangle(
vis_img, (p1x, p1y), (p2x, p2y),
color, thickness=3, lineType=cv2.LINE_AA)
cv2.putText(
vis_img, label_text, (p1x, max(p1y - 10, 0)),
cv2.FONT_HERSHEY_SIMPLEX, 0.5, color,
thickness=2, lineType=cv2.LINE_AA)
if self.pub_image.get_num_connections() > 0:
vis_msg = self.bridge.cv2_to_imgmsg(vis_img, 'rgb8')
# BUG: https://answers.ros.org/question/316362/sensor_msgsimage-generates-float-instead-of-int-with-python3/ # NOQA
vis_msg.step = int(vis_msg.step)
vis_msg.header = header
self.pub_image.publish(vis_msg)
if self.pub_image_compressed.get_num_connections() > 0:
# publish compressed http://wiki.ros.org/rospy_tutorials/Tutorials/WritingImagePublisherSubscriber # NOQA
vis_compressed_msg = CompressedImage()
vis_compressed_msg.header = header
# image format https://github.com/ros-perception/image_transport_plugins/blob/f0afd122ed9a66ff3362dc7937e6d465e3c3ccf7/compressed_image_transport/src/compressed_publisher.cpp#L116 # NOQA
vis_compressed_msg.format = encoding + '; jpeg compressed bgr8'
vis_img_rgb = cv2.cvtColor(vis_img, cv2.COLOR_BGR2RGB)
vis_compressed_msg.data = np.array(
cv2.imencode('.jpg', vis_img_rgb)[1]).tostring()
self.pub_image_compressed.publish(vis_compressed_msg)

from coral_usb_ros.

knorth55 avatar knorth55 commented on May 28, 2024

https://github.com/jsk-ros-pkg/coral_usb_ros#parameters

visualization loop is anothr loop.
we can control the hz by visualization_duration.

from coral_usb_ros.

Petros626 avatar Petros626 commented on May 28, 2024

https://github.com/jsk-ros-pkg/coral_usb_ros#parameters

visualization loop is anothr loop. we can control the hz by visualization_duration.

the visualization frequency in rviz is the same the messages are coming (2 Hz). By using using rostopic echo /edgetpu_object_detector/output/image I noticed the difference from 2Hz to >2Hz.

Your suggestions works good with a value of 2.0, but it wonders me, how the node could echo the pixel values faster than the incoming Image message...

from coral_usb_ros.

Petros626 avatar Petros626 commented on May 28, 2024

Yes, but your suggestion helps, will close the issue

from coral_usb_ros.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.