예제 #1
0
def test_gets_markers_with_calibration(
    filename: str, camera_name: str, snapshot: Any
) -> None:
    class TestCamera(BaseImageFileCamera):
        marker_type = MarkerType.DICT_APRILTAG_36H11

        def get_marker_size(self, marker_id: int) -> int:
            return 100

    camera = TestCamera(
        TEST_IMAGE_DIR.joinpath(filename),
        calibration_file=get_calibration(camera_name),
    )
    snapshot.assert_match(
        sorted(
            (
                {
                    "id": marker.id,
                    "size": marker.size,
                    "pixel_corners": [list(coords) for coords in marker.pixel_corners],
                    "pixel_centre": list(marker.pixel_centre),
                    "distance": marker.distance,
                    "orientation": tuple(marker.orientation),
                    "spherical": tuple(marker.spherical),
                    "cartesian": list(marker.cartesian),
                }
                for marker in camera.process_frame()
            ),
            key=operator.itemgetter("pixel_centre"),
        )
    )
예제 #2
0
def test_gets_markers_with_calibration(filename, camera_name, snapshot):
    class TestCamera(ImageFileCamera):
        def get_marker_size(self, id):
            return 100

    camera = TestCamera(
        TEST_IMAGE_DIR.joinpath(filename),
        marker_dict=MarkerDict.DICT_APRILTAG_36H11,
        calibration_file=get_calibration(camera_name),
    )
    snapshot.assert_match(
        sorted(
            ({
                "id":
                marker.id,
                "size":
                marker.size,
                "pixel_corners":
                [coords.to_list() for coords in marker.pixel_corners],
                "pixel_centre":
                marker.pixel_centre.to_list(),
                "distance":
                marker.distance,
                "orientation":
                tuple(marker.orientation),
                "spherical":
                tuple(marker.spherical),
                "cartesian":
                marker.cartesian.to_list(),
            } for marker in camera.process_frame()),
            key=operator.itemgetter("pixel_centre"),
        ))
예제 #3
0
def test_process_frame_eager(filename, camera_name, benchmark,
                             temp_image_file):
    class TestCamera(ImageFileCamera):
        def get_marker_size(self, id):
            return 100

    camera = TestCamera(
        TEST_IMAGE_DIR.joinpath(filename),
        marker_dict=MarkerDict.DICT_APRILTAG_36H11,
        calibration_file=get_calibration(camera_name),
    )
    benchmark(camera.save_frame, temp_image_file)
예제 #4
0
def test_process_frame_eager(
    filename: str,
    camera_name: str,
    benchmark: Callable,
    temp_image_file: Callable[[str], Path],
) -> None:
    class TestCamera(BaseImageFileCamera):
        marker_type = MarkerType.DICT_APRILTAG_36H11

        def get_marker_size(self, marker_id: int) -> int:
            return 100

    camera = TestCamera(
        TEST_IMAGE_DIR.joinpath(filename),
        calibration_file=get_calibration(camera_name),
    )
    benchmark(camera.save_frame, temp_image_file)