def __init__(self):
     super(LabelImageDecomposer, self).__init__()
     self.pub_img = self.advertise('~output', Image, queue_size=5)
     self._publish_tile = rospy.get_param('~publish_tile', False)
     jsk_loginfo('~publish_info: {}'.format(self._publish_tile))
     if self._publish_tile:
         self.pub_tile = self.advertise('~output/tile', Image, queue_size=5)
Exemplo n.º 2
0
 def __init__(self):
     super(LabelImageDecomposer, self).__init__()
     self.pub_img = self.advertise('~output', Image, queue_size=5)
     self._publish_tile = rospy.get_param('~publish_tile', False)
     jsk_loginfo('~publish_info: {}'.format(self._publish_tile))
     if self._publish_tile:
         self.pub_tile = self.advertise('~output/tile', Image, queue_size=5)
 def subscribe(self):
     self.sub = message_filters.Subscriber('~input', Image)
     self.sub_mask = message_filters.Subscriber('~input/mask', Image)
     self.use_async = rospy.get_param('~approximate_sync', False)
     jsk_loginfo('~approximate_sync: {}'.format(self.use_async))
     if self.use_async:
         sync = message_filters.ApproximateTimeSynchronizer(
             [self.sub, self.sub_mask], queue_size=1000, slop=0.1)
     else:
         sync = message_filters.TimeSynchronizer(
             [self.sub, self.sub_mask], queue_size=1000)
     sync.registerCallback(self._apply)
     warn_no_remap('~input', '~input/mask')
    def __init__(self):
        super(BoFHistogramExtractor, self).__init__()

        # load bag of features
        jsk_loginfo('Loading BoF data')
        bof_data = rospy.get_param('~bof_data', None)
        if bof_data is None:
            quit()
        with gzip.open(bof_data, 'rb') as f:
            self.bof = pickle.load(f)

        self.pub = self.advertise('~output', Histogram, queue_size=1)
        jsk_loginfo('Initialized BoF histogram extractor')
Exemplo n.º 5
0
 def subscribe(self):
     self.sub = message_filters.Subscriber('~input', Image)
     self.sub_mask = message_filters.Subscriber('~input/mask', Image)
     self.use_async = rospy.get_param('~approximate_sync', False)
     jsk_loginfo('~approximate_sync: {}'.format(self.use_async))
     if self.use_async:
         sync = message_filters.ApproximateTimeSynchronizer(
             [self.sub, self.sub_mask], queue_size=1000, slop=0.1)
     else:
         sync = message_filters.TimeSynchronizer([self.sub, self.sub_mask],
                                                 queue_size=1000)
     sync.registerCallback(self._apply)
     warn_no_remap('~input', '~input/mask')
 def _cb_dyn_reconfig(self, config, level):
     file_name = config['file_name']
     config['file_name'] = os.path.abspath(file_name)
     img_bgr = cv2.imread(file_name)
     if img_bgr is None:
         jsk_logwarn('Could not read image file: {}'.format(file_name))
         with self.lock:
             self.imgmsg = None
     else:
         jsk_loginfo('Read the image file: {}'.format(file_name))
         with self.lock:
             self.imgmsg = self.cv2_to_imgmsg(img_bgr, self.encoding)
     return config
Exemplo n.º 7
0
 def _cb_dyn_reconfig(self, config, level):
     file_name = config['file_name']
     config['file_name'] = os.path.abspath(file_name)
     img_bgr = cv2.imread(file_name)
     if img_bgr is None:
         jsk_logwarn('Could not read image file: {}'.format(file_name))
         with self.lock:
             self.imgmsg = None
     else:
         jsk_loginfo('Read the image file: {}'.format(file_name))
         with self.lock:
             self.imgmsg = self.cv2_to_imgmsg(img_bgr, self.encoding)
     return config
    def __init__(self):
        super(BoFHistogramExtractor, self).__init__()

        # load bag of features
        jsk_loginfo('Loading BoF data')
        bof_data = rospy.get_param('~bof_data', None)
        if bof_data is None:
            quit()
        with gzip.open(bof_data, 'rb') as f:
            self.bof = pickle.load(f)

        self._pub = self.advertise('~output', VectorArray, queue_size=1)
        jsk_loginfo('Initialized BoF histogram extractor')
 def __init__(self):
     super(LabelImageDecomposer, self).__init__()
     self.pub_img = self.advertise('~output', Image, queue_size=5)
     self.pub_label_viz = self.advertise('~output/label_viz', Image,
                                         queue_size=5)
     # publish masks of fg/bg by decomposing each label
     self._publish_mask = rospy.get_param('~publish_mask', False)
     if self._publish_mask:
         self.pub_fg_mask = self.advertise('~output/fg_mask', Image,
                                           queue_size=5)
         self.pub_bg_mask = self.advertise('~output/bg_mask', Image,
                                                 queue_size=5)
     # publish each region image. this can take time so optional.
     self._publish_tile = rospy.get_param('~publish_tile', False)
     jsk_loginfo('~publish_tile: {}'.format(self._publish_tile))
     if self._publish_tile:
         self.pub_tile = self.advertise('~output/tile', Image, queue_size=5)
 def subscribe(self):
     self.sub_img = message_filters.Subscriber('~input', Image)
     self.sub_label = message_filters.Subscriber('~input/label', Image)
     use_async = rospy.get_param('~approximate_sync', False)
     jsk_loginfo('~approximate_sync: {}'.format(use_async))
     if use_async:
         slop = rospy.get_param('~slop', 0.1)
         jsk_loginfo('~slop: {}'.format(slop))
         async = message_filters.ApproximateTimeSynchronizer(
             [self.sub_img, self.sub_label], queue_size=10, slop=slop)
         async.registerCallback(self._apply)
         if self._publish_tile:
             async.registerCallback(self._apply_tile)
     else:
         sync = message_filters.TimeSynchronizer(
             [self.sub_img, self.sub_label], queue_size=10)
         sync.registerCallback(self._apply)
         if self._publish_tile:
             sync.registerCallback(self._apply_tile)
Exemplo n.º 11
0
 def subscribe(self):
     self.sub_img = message_filters.Subscriber('~input', Image)
     self.sub_label = message_filters.Subscriber('~input/label', Image)
     use_async = rospy.get_param('~approximate_sync', False)
     jsk_loginfo('~approximate_sync: {}'.format(use_async))
     if use_async:
         slop = rospy.get_param('~slop', 0.1)
         jsk_loginfo('~slop: {}'.format(slop))
         async = message_filters.ApproximateTimeSynchronizer(
             [self.sub_img, self.sub_label], queue_size=10, slop=slop)
         async .registerCallback(self._apply)
         if self._publish_tile:
             async .registerCallback(self._apply_tile)
     else:
         sync = message_filters.TimeSynchronizer(
             [self.sub_img, self.sub_label], queue_size=10)
         sync.registerCallback(self._apply)
         if self._publish_tile:
             sync.registerCallback(self._apply_tile)
Exemplo n.º 12
0
 def subscribe(self):
     self.sub_rect = message_filters.Subscriber('~input', RectArray)
     self.sub_img = message_filters.Subscriber('~input/image', Image)
     self.sub_class = message_filters.Subscriber('~input/class', ClassificationResult)
     # warn_no_remap('~input','~input/image','~input/class')
     use_async = rospy.get_param('~approximate_sync', False)
     queue_size = rospy.get_param('~queue_size', 100)
     jsk_loginfo('~approximate_sync: {} queue_size: {}'.format(use_async, queue_size))
     if use_async:
         slop = rospy.get_param('~slop', 0.1)
         jsk_loginfo('~slop: {}'.format(slop))
         sync = message_filters.ApproximateTimeSynchronizer(
                 [self.sub_rect, self.sub_img, self.sub_class],
                 queue_size, slop)
     else:
         sync = message_filters.TimeSynchronizer(
                 [self.sub_rect, self.sub_img, self.sub_class],
                 queue_size)
     sync.registerCallback(self.convert)
Exemplo n.º 13
0
 def subscribe(self):
     self.sub_rect = message_filters.Subscriber('~input', RectArray)
     self.sub_img = message_filters.Subscriber('~input/image', Image)
     self.sub_class = message_filters.Subscriber('~input/class',
                                                 ClassificationResult)
     # warn_no_remap('~input','~input/image','~input/class')
     use_async = rospy.get_param('~approximate_sync', False)
     queue_size = rospy.get_param('~queue_size', 100)
     jsk_loginfo('~approximate_sync: {} queue_size: {}'.format(
         use_async, queue_size))
     if use_async:
         slop = rospy.get_param('~slop', 0.1)
         jsk_loginfo('~slop: {}'.format(slop))
         sync = message_filters.ApproximateTimeSynchronizer(
             [self.sub_rect, self.sub_img, self.sub_class], queue_size,
             slop)
     else:
         sync = message_filters.TimeSynchronizer(
             [self.sub_rect, self.sub_img, self.sub_class], queue_size)
     sync.registerCallback(self.convert)
Exemplo n.º 14
0
 def __init__(self):
     super(LabelImageDecomposer, self).__init__()
     self.pub_img = self.advertise('~output', Image, queue_size=5)
     self.pub_label_viz = self.advertise('~output/label_viz',
                                         Image,
                                         queue_size=5)
     # publish masks of fg/bg by decomposing each label
     self._publish_mask = rospy.get_param('~publish_mask', False)
     if self._publish_mask:
         self.pub_fg_mask = self.advertise('~output/fg_mask',
                                           Image,
                                           queue_size=5)
         self.pub_bg_mask = self.advertise('~output/bg_mask',
                                           Image,
                                           queue_size=5)
     # publish each region image. this can take time so optional.
     self._publish_tile = rospy.get_param('~publish_tile', False)
     jsk_loginfo('~publish_tile: {}'.format(self._publish_tile))
     if self._publish_tile:
         self.pub_tile = self.advertise('~output/tile', Image, queue_size=5)
    def __init__(self):
        super(BoFHistogramExtractor, self).__init__()

        self.queue_size = rospy.get_param('~queue_size', 10)

        # load bag of features
        jsk_loginfo('Loading BoF data')
        bof_data = rospy.get_param('~bof_data', None)
        if bof_data is None:
            quit()
        with gzip.open(bof_data, 'rb') as f:
            self.bof = pickle.load(f)
        if (StrictVersion(get_distribution('scikit-learn').version) >=
                StrictVersion('0.17.0')):
            if 'n_jobs' not in self.bof.nn.__dict__:
                # In scikit-learn>=0.17.0,
                # sklearn.neighbors.NearestNeighbors needs 'n_jobs' attribute.
                # https://github.com/jsk-ros-pkg/jsk_recognition/issues/1669
                self.bof.nn.n_jobs = 1

        self._pub = self.advertise('~output', VectorArray, queue_size=1)
        jsk_loginfo('Initialized BoF histogram extractor')
    def __init__(self):
        super(BoFHistogramExtractor, self).__init__()

        self.queue_size = rospy.get_param('~queue_size', 10)

        # load bag of features
        jsk_loginfo('Loading BoF data')
        bof_data = rospy.get_param('~bof_data', None)
        if bof_data is None:
            quit()
        with gzip.open(bof_data, 'rb') as f:
            self.bof = pickle.load(f)
        if (StrictVersion(get_distribution('scikit-learn').version) >=
                StrictVersion('0.17.0')):
            if 'n_jobs' not in self.bof.nn.__dict__:
                # In scikit-learn>=0.17.0,
                # sklearn.neighbors.NearestNeighbors needs 'n_jobs' attribute.
                # https://github.com/jsk-ros-pkg/jsk_recognition/issues/1669
                self.bof.nn.n_jobs = 1

        self._pub = self.advertise('~output', VectorArray, queue_size=1)
        jsk_loginfo('Initialized BoF histogram extractor')