Exemplo n.º 1
0
    def stage_find(self, should_run=None):
        """
        The arm is actively using the end-effector camera to find objects of the
        correct size.

        :param should_run: a `threading.Event` that tells the stage to continue
            if `is_set()` is True
        :return: a dict containing this stage's results
        """
        log.info("[stage_find] _begin_")
        r = dict()

        ip = ImageProcessor(res_width=MAX_IMAGE_WIDTH,
                            res_height=MAX_IMAGE_HEIGHT)
        ip.capture_frame()

        log.info('[stage_find] max_pixel_count is:{0}'.format(
            ip.max_pixel_count))
        # check to see if the image processor found an object that is larger
        # than the minimum object size we want to try to pickup
        if ip.max_pixel_count > MIN_OBJECT_SIZE:
            print('largest object is:{0}'.format(ip.largest_object_id))
            print('largest object X coord is:{0}'.format(ip.largest_X))
            print('largest object Y coord is:{0}'.format(ip.largest_Y))
            r['x'] = ip.largest_X
            r['y'] = ip.largest_Y
            r['filename'] = ip.filename
            log.info("[stage_find] found object at x:{0} y:{1}".format(
                r['x'], r['y']))
            ip.close()
            log.info("[stage_find] _end_")
            return r
        else:
            # did not find an object larger than the minimum size - return
            # NO_BOX_FOUND
            log.info("[stage_find] no object larger than:{0}".format(
                MIN_OBJECT_SIZE))
            ip.close()
            log.info("[stage_find] _end_")
            return NO_BOX_FOUND
    def stage_find(self, should_run=None):
        """
        The arm is actively using the end-effector camera to find objects of the
        correct size.

        :param should_run: a `threading.Event` that tells the stage to continue
            if `is_set()` is True
        :return: a dict containing this stage's results
        """
        log.info("[stage_find] _begin_")
        r = dict()

        ip = ImageProcessor(res_width=MAX_IMAGE_WIDTH,
                            res_height=MAX_IMAGE_HEIGHT)
        ip.capture_frame()

        log.info('[stage_find] max_pixel_count is:{0}'.format(
            ip.max_pixel_count))
        # check to see if the image processor found an object that is larger
        # than the minimum object size we want to try to pickup
        if ip.max_pixel_count > MIN_OBJECT_SIZE:
            print('largest object is:{0}'.format(ip.largest_object_id))
            print('largest object X coord is:{0}'.format(ip.largest_X))
            print('largest object Y coord is:{0}'.format(ip.largest_Y))
            r['x'] = ip.largest_X
            r['y'] = ip.largest_Y
            r['filename'] = ip.filename
            log.info("[stage_find] found object at x:{0} y:{1}".format(
                r['x'], r['y']))
            ip.close()
            log.info("[stage_find] _end_")
            return r
        else:
            # did not find an object larger than the minimum size - return
            # NO_BOX_FOUND
            log.info("[stage_find] no object larger than:{0}".format(
                MIN_OBJECT_SIZE))
            ip.close()
            log.info("[stage_find] _end_")
            return NO_BOX_FOUND