Пример #1
0
def image_callback(data):
    global current_rgb_img, current_gray_img
    # Read image from message
    current_img = np.array(cvbridge.imgmsg_to_cv(data, "bgr8"))
    # Compute the gray image
    current_gray_img = cv2.GaussianBlur(np.asarray(to_grayscale(current_img)), (5,5), 3)
    # If the tracker is running, ask it to update and publish roi
    if tracker.is_initialized(): 
        # update
        tracker.update(current_gray_img)
        # publish roi
        message = NNTrackerROI()
        region = tracker.get_region()
        message.ulx, message.uly = region[:,0]
        message.urx, message.ury = region[:,1]
        message.lrx, message.lry = region[:,2]
        message.llx, message.lly = region[:,3]
        roi_pub.publish(message)
Пример #2
0
 def image_callback(self, img_msg):
     self.on_frame(np.array(self.bridge.imgmsg_to_cv(img_msg, "bgr8")))
     if self.trackers[0].is_initialized():
         message = NNTrackerROI()
         region = self.trackers[0].get_region()
         message.ulx, message.uly = region[:,0]
         message.urx, message.ury = region[:,1]
         message.lrx, message.lry = region[:,2]
         message.llx, message.lly = region[:,3]
         self.roi_pub.publish(message)
def image_callback(data):
    global current_rgb_img, current_gray_img
    # Read image from message
    current_img = np.array(cvbridge.imgmsg_to_cv(data, "bgr8"))
    # Compute the gray image
    current_gray_img = cv2.GaussianBlur(np.asarray(to_grayscale(current_img)),
                                        (5, 5), 3)
    # If the tracker is running, ask it to update and publish roi
    if tracker.is_initialized():
        # update
        tracker.update(current_gray_img)
        # publish roi
        message = NNTrackerROI()
        region = tracker.get_region()
        message.ulx, message.uly = region[:, 0]
        message.urx, message.ury = region[:, 1]
        message.lrx, message.lry = region[:, 2]
        message.llx, message.lly = region[:, 3]
        roi_pub.publish(message)