Beispiel #1
0
 def _get_faces(self, image):
     try:
         r = self._recognize_srv(image=image)
         rospy.loginfo('found %d face(s) in the image', len(r.recognitions))
     except rospy.ServiceException as e:
         rospy.logerr(e.message)
         r = RecognizeResponse()
     return r
Beispiel #2
0
 def _get_faces(self, image=None):
     if not image:
         image = self.get_image()
     try:
         r = self._recognize_srv(image=image)
         rospy.loginfo('Found %d face(s) in the image', len(r.recognitions))
     except rospy.ServiceException as e:
         rospy.logerr("Can't connect to face recognition service: {}".format(e))
         r = RecognizeResponse()
     except Exception as e:
         rospy.logerr("Can't detect faces: {}".format(e))
     return r
    def __init__(self, context):
        """
        ManualPlugin class that performs a manual recognition based on a request

        :param context: QT context, aka parent
        """
        super(ManualPlugin, self).__init__(context)

        # Widget setup
        self.setObjectName('Manual Plugin')

        self._widget = QWidget()
        context.add_widget(self._widget)

        # Layout and attach to widget
        layout = QVBoxLayout()
        self._widget.setLayout(layout)

        self._image_widget = ImageWidget(self._widget, self.image_roi_callback)
        layout.addWidget(self._image_widget)

        # Input field
        grid_layout = QGridLayout()
        layout.addLayout(grid_layout)

        self._labels_edit = QLineEdit()
        self._labels_edit.setDisabled(True)
        grid_layout.addWidget(self._labels_edit, 2, 2)

        self._edit_labels_button = QPushButton("Edit labels")
        self._edit_labels_button.clicked.connect(self._get_labels)
        grid_layout.addWidget(self._edit_labels_button, 2, 1)

        self._done_recognizing_button = QPushButton("Done recognizing..")
        self._done_recognizing_button.clicked.connect(self._done_recognizing)
        self._done_recognizing_button.setDisabled(True)
        grid_layout.addWidget(self._done_recognizing_button, 3, 2)

        # Bridge for opencv conversion
        self.bridge = CvBridge()

        # Set service to None
        self._srv = None
        self._srv_name = None

        self._response = RecognizeResponse()
        self._recognizing = False