コード例 #1
0
def test_list_sources_single_async():
    image_source_a = image_protos.ImageSource()
    image_source_b = image_protos.ImageSource()
    client, service, server = _setup(
        image_sources=[image_source_a, image_source_b])
    fut = client.list_image_sources_async()
    assert 2 == len(fut.result())
コード例 #2
0
    def make_image_source(source_name,
                          rows=None,
                          cols=None,
                          image_type=image_pb2.ImageSource.IMAGE_TYPE_VISUAL):
        """Create an instance of the image_pb2.ImageSource for a given source name.

        Args:
            name (string): The name for the camera source.
            rows (int): The number of rows of pixels in the image.
            cols (int): The number of cols of pixels in the image.
            image_type (image_pb2.ImageType): The type of image (e.g. visual, depth).

        Returns:
            An ImageSource with the cols, rows, and image type populated.
        """
        source = image_pb2.ImageSource()
        source.name = source_name

        if rows is not None and cols is not None:
            source.rows = rows
            source.cols = cols

        # Image from the ricoh theta is a JPEG, which is considered a visual image source (no depth data).
        source.image_type = image_type
        return source
コード例 #3
0
    def __init__(self, bosdyn_sdk_robot, theta_ssid, logger=None):
        self.robot = bosdyn_sdk_robot
        self.robot.time_sync.wait_for_sync()

        # Create a service fault client.
        self.fault_client = self.robot.ensure_client(FaultClient.default_service_name)
        self.clear_faults_on_startup()

        # Setup the logger.
        self.logger = logger or _LOGGER

        # Name of the image source that is being requested from.
        self.theta_ssid = theta_ssid
        self.device_name = "RicohTheta_"+theta_ssid

        # Default value for JPEG image quality, in case one is not provided in the GetImage request.
        self.default_jpeg_quality = 95

        # Camera related variables. These will get initialized by calling initialize_camera(). If the
        # initialization of the camera failed, the service will never get registered with the directory.
        # This is done after because if a fault is thrown when attempting to connect to the Ricoh Theta
        # on startup, there is likely an issue with the camera connection or hardware, and the service
        # will likely to continue to fail until these issues are fixed.
        self.camera = None
        self.capture_parameters = image_pb2.CaptureParameters()
        self.ricoh_image_src_proto = image_pb2.ImageSource()
コード例 #4
0
    def make_ricoh_theta_image_source(self):
        """Create an instance of the image_pb2.ImageSource for the Ricoh Theta.

        Returns:
            An ImageSource with the cols, rows, and image type populated.
        """
        source = image_pb2.ImageSource()
        source.name = self.device_name

        # Request the image format (height, width) from the camera.
        format_json = None
        try:
            format_json = self.camera.getFileFormat(print_to_screen=False)
        except Exception as err:
            # An issue occurred getting the file format for the camera images. This is likely due
            # to upstream failures creating the Theta instance, which already have triggered service
            # faults.
            _LOGGER.info("Unable to set the image width/height dimensions. Error message: %s %s", str(type(err)), str(err))
            pass
        if format_json is not None:
            source.cols = format_json["width"]
            source.rows = format_json["height"]

        # Image from the ricoh theta is a JPEG, which is considered a visual image source (no depth data).
        source.image_type = image_pb2.ImageSource.IMAGE_TYPE_VISUAL
        return source
コード例 #5
0
ファイル: web_cam_image_service.py プロジェクト: wau/spot-sdk
    def make_image_source(device_name="/dev/video0"):
        """Create an instance of the image_pb2.ImageSource and a VideoCapture for that image source.
        Args:
            device_name(str): The image source name that should be described.

        Returns:
            An ImageSource with the cols, rows, and image type populated, in addition to an OpenCV VideoCapture
            instance which can be used to query the image source for images.
        """
        # Defaults to "/dev/video0" for the device name, which will take the first (or only) connected camera.
        source = image_pb2.ImageSource()
        source.name = device_name_to_source_name(device_name)
        capture = cv2.VideoCapture(device_name)
        source.cols = int(capture.get(cv2.CAP_PROP_FRAME_WIDTH))
        source.rows = int(capture.get(cv2.CAP_PROP_FRAME_HEIGHT))
        source.image_type = image_pb2.ImageSource.IMAGE_TYPE_VISUAL
        return source, capture
コード例 #6
0
ファイル: test_image.py プロジェクト: zhengfengran/spot-sdk
def test_list_sources_single():
    image_source = image_protos.ImageSource()
    client, service, server = _setup(image_sources=[image_source])
    assert 1 == len(client.list_image_sources())
コード例 #7
0
ファイル: test_image.py プロジェクト: zhengfengran/spot-sdk
def test_list_sources_multiple():
    image_source_a = image_protos.ImageSource()
    image_source_b = image_protos.ImageSource()
    client, service, server = _setup(image_sources=[image_source_a, image_source_b])
    assert 2 == len(client.list_image_sources())