示例#1
0
    def get_image_full_res(self, index: int) -> Image:
        """Get the image at the given index, at full resolution.

        Args:
            index: the index to fetch.

        Raises:
            IndexError: if an out-of-bounds image index is requested.

        Returns:
            Image: the image at the query index.
        """
        if index < 0 or index >= len(self):
            raise IndexError(f"Image index {index} is invalid")

        # Read in image.
        img = io_utils.load_image(self._image_paths[index])

        # Generate mask to separate background deep space from foreground target body
        # based on image intensity values.
        mask = get_nonzero_intensity_mask(img)

        return Image(value_array=img.value_array,
                     exif_data=img.exif_data,
                     file_name=img.file_name,
                     mask=mask)
示例#2
0
    def get_camera_intrinsics(self, index: int) -> Optional[Cal3Bundler]:
        """Get the camera intrinsics at the given index.

        Args:
            the index to fetch.

        Returns:
            intrinsics for the given camera.
        """
        if len(self.explicit_intrinsics_paths) == 0:
            # get intrinsics from exif

            return io_utils.load_image(
                self.image_paths[index]).get_intrinsics_from_exif()

        else:
            # TODO: handle extra inputs in the intrinsics array
            intrinsics_array = np.load(self.explicit_intrinsics_paths[index])

            return Cal3Bundler(
                fx=min(intrinsics_array[0, 0], intrinsics_array[1, 1]),
                k1=0,
                k2=0,
                u0=intrinsics_array[0, 2],
                v0=intrinsics_array[1, 2],
            )
示例#3
0
 def setUp(
     self,
     detector_descriptor: DetectorDescriptorBase = SIFTDetectorDescriptor()
 ) -> None:
     super().setUp()
     self._input: Image = io_utils.load_image(str(IMG_PATH))
     self._detector_descriptor: DetectorDescriptorBase = detector_descriptor
 def setUp(
     self, verifier: VerifierBase = Ransac(use_intrinsics_in_verification=False, estimation_threshold_px=3)
 ) -> None:
     super().setUp()
     self._verifier: VerifierBase = verifier
     detector_descriptor = SIFTDetectorDescriptor()
     matcher = TwoWayMatcher()
     self._image_i1 = io_utils.load_image(str(IMG1_PATH))
     self._image_i2 = io_utils.load_image(str(IMG2_PATH))
     self._keypoints_i1, descriptors_i1 = detector_descriptor.detect_and_describe(self._image_i1)
     self._keypoints_i2, descriptors_i2 = detector_descriptor.detect_and_describe(self._image_i2)
     self._match_indices = matcher.match(
         self._keypoints_i1,
         self._keypoints_i2,
         descriptors_i1,
         descriptors_i2,
         (self._image_i1.height, self._image_i1.width),
         (self._image_i2.height, self._image_i2.width),
     )
    def test_image_contents(self):
        """Test the actual image which is being fetched by the loader at an index.

        This test's primary purpose is to check if the ordering of filename is being respected by the loader
        """
        index_to_test = 5
        file_path = DEFAULT_FOLDER / "images" / "DSC_0006.JPG"
        loader_image = self.loader.get_image(index_to_test)
        expected_image = io_utils.load_image(file_path)
        np.testing.assert_allclose(expected_image.value_array,
                                   loader_image.value_array)
示例#6
0
    def test_image_contents(self) -> None:
        """Test the actual image which is being fetched by the loader at an index.

        This test's primary purpose is to check if the ordering of filename is being respected by the loader
        """
        index_to_test = 1
        file_path = TEST_DATA_ROOT / "astronet" / "test_2011212_opnav_022" / "images" / "00000001.png"
        loader_image = self.loader.get_image(index_to_test)
        expected_image = io_utils.load_image(str(file_path))
        np.testing.assert_allclose(expected_image.value_array,
                                   loader_image.value_array)
示例#7
0
    def get_image_full_res(self, index: int) -> Image:
        """Get the image at the given index, at full resolution.

        Args:
            index: the index to fetch.

        Raises:
            IndexError: if an out-of-bounds image index is requested.

        Returns:
            Image: the image at the query index.
        """
        image_path: Path = self._base_folder / IMAGES_FOLDER / f"{index}.jpg"

        return io_utils.load_image(str(image_path))
    def test_image_contents(self):
        """Test the actual image which is being fetched by the loader at an index.

        This test's primary purpose is to check if the ordering of filename is being respected by the loader
        """
        index_to_test = 1
        # corresponds to dataset split
        split = "train1"
        log_id = "273c1883-673a-36bf-b124-88311b1a80be"
        camera_name = "ring_front_center"
        fname = "ring_front_center_315975643412234000.jpg"

        file_path = ARGOVERSE_DATA_ROOT_PATH / split / log_id / camera_name / fname
        loader_image = self.loader.get_image(index_to_test)
        expected_image = io_utils.load_image(file_path)
        np.testing.assert_allclose(expected_image.value_array, loader_image.value_array)
示例#9
0
    def get_image_full_res(self, index: int) -> Image:
        """Get the image at the given index, at full resolution.

        Args:
            index: the index to fetch.

        Raises:
            IndexError: if an out-of-bounds image index is requested.

        Returns:
            Image: the image at the query index.
        """

        if index < 0 or index >= len(self):
            raise IndexError("Image index is invalid")

        return io_utils.load_image(self._image_paths[index])
示例#10
0
    def get_camera_intrinsics_full_res(self, index: int) -> Optional[Cal3Bundler]:
        """Get the camera intrinsics at the given index, valid for a full-resolution image.

        Args:
            the index to fetch.

        Returns:
            intrinsics for the given camera.
        """
        if index < 0 or index >= len(self):
            raise IndexError("Image index is invalid")

        if not self._use_gt_intrinsics:
            # get intrinsics from exif
            intrinsics = io_utils.load_image(self._image_paths[index]).get_intrinsics_from_exif()
        else:
            intrinsics = self._calibrations[index]

        return intrinsics
示例#11
0
    def get_image_full_res(self, index: int) -> Image:
        """Get the image at the given index, at full resolution.

        Args:
            index: the index to fetch.

        Raises:
            IndexError: if an out-of-bounds image index is requested.

        Returns:
            Image: the image at the query index.
        """
        if index < 0 or index > self.__len__():
            raise IndexError("Image index is invalid")

        image_name = self._image_names[index]

        file_name = osp.join(self._folder, "images",
                             "{}.jpg".format(image_name))

        return io_utils.load_image(file_name)
示例#12
0
    def get_camera_intrinsics_full_res(self, index: int) -> Optional[Cal3Bundler]:
        """Get the camera intrinsics at the given index, valid for a full-resolution image.

        Args:
            the index to fetch.

        Returns:
            intrinsics for the given camera.
        """
        if not self._use_gt_intrinsics:
            # get intrinsics from exif
            intrinsics = io_utils.load_image(self._image_paths[index]).get_intrinsics_from_exif()

        else:
            intrinsics = Cal3Bundler(
                fx=min(self._K[0, 0], self._K[1, 1]),
                k1=0,
                k2=0,
                u0=self._K[0, 2],
                v0=self._K[1, 2],
            )
        return intrinsics
 def setUp(self, descriptor: DescriptorBase = SIFTDescriptor()) -> None:
     super().setUp()
     detector: DetectorBase = DoG()
     self._image: Image = io_utils.load_image(str(IMG_PATH))
     self._keypoints: Keypoints = detector.detect(self._image)
     self._descriptor: DescriptorBase = descriptor
示例#14
0
 def test_load_image(self) -> None:
     """Ensure focal length can be read from EXIF, for an image w/ known EXIF."""
     img_fpath = TEST_DATA_ROOT / "set2_lund_door_nointrinsics/images/DSC_0001.JPG"
     img = io_utils.load_image(img_fpath)
     self.assertEqual(img.exif_data.get("FocalLength"), 29)
示例#15
0
 def test_generate_hash_for_image(self):
     image_path = TEST_DATA_ROOT_PATH / "set1_lund_door" / "images" / "DSC_0001.JPG"
     image = io_utils.load_image(str(image_path))
     key = cache_utils.generate_hash_for_image(image=image)
     expected = "033223b24a9edfe6e989b6853db295df51011f3cdc58c96e361e565c018e33ff4630345c79c09188"
     self.assertEqual(key, expected)