Exemplo n.º 1
0
 def test_write_exif(self):
     image_filepath_wo_exif = path.join(self._samples_folder,
                                        '7scenes/microsoft/stairs/seq-01/frame-000000.color.jpg')
     image_filepath_w_exif = path.join(self._samples_folder, 'berlin/opensfm/images/01.jpg')
     image_filepath_temp = path.join(self._tempdir.name, 'frame-000000.color.jpg')
     shutil.copy(image_filepath_wo_exif, image_filepath_temp)
     expected_exif = read_exif(image_filepath_w_exif)
     write_exif(image_filepath_temp, expected_exif)
     actual_exif = read_exif(image_filepath_temp)
     # self.assertEqual(len(expected_exif), len(actual_exif))
     self.assertEqual(set(expected_exif.keys()), set(actual_exif.keys()))
     self.assertDictEqual(expected_exif['GPS'], actual_exif['GPS'])
Exemplo n.º 2
0
 def test_clear_exif(self):
     image_filepath_w_exif = path.join(self._samples_folder, 'berlin/opensfm/images/01.jpg')
     image_filepath_temp = path.join(self._tempdir.name, 'image.jpg')
     shutil.copy(image_filepath_w_exif, image_filepath_temp)
     clear_exif(image_filepath_temp)
     exif_data = read_exif(image_filepath_temp)
     self.assertIsNone(exif_data)
Exemplo n.º 3
0
 def test_read_exif_gps(self):
     image_filepath_w_exif = path.join(self._samples_folder, 'berlin/opensfm/images/01.jpg')
     exif_data = read_exif(image_filepath_w_exif)
     self.assertIn('GPS', exif_data)
     gps_data = exif_data['GPS']
     self.assertIsInstance(gps_data, dict)
     self.assertEqual(6, len(gps_data))
     self.assertIn(piexif.GPSIFD.GPSLatitude, gps_data)
Exemplo n.º 4
0
    def test_export(self):
        temp_kapture_dirpath = path.join(self._tempdir.name, 'kapture')
        shutil.copytree(self._kapture_dirpath, temp_kapture_dirpath)
        kapture_data = kapture.io.csv.kapture_from_dir(temp_kapture_dirpath)
        images_filepaths = images_to_filepaths(kapture_data.records_camera, temp_kapture_dirpath)
        # make sure there is no EXIF in images
        for image_filepath in images_filepaths.values():
            clear_exif(image_filepath)

        # insert gps to exif
        export_gps_to_exif(kapture_data=kapture_data,
                           kapture_dirpath=temp_kapture_dirpath)

        rebuilt_records = kapture.RecordsGnss()
        for timestamp, cam_id, image_name in kapture.flatten(kapture_data.records_camera):
            image_filepath = get_image_fullpath(temp_kapture_dirpath, image_name)
            exif_data = read_exif(image_filepath)
            rebuilt_records[timestamp, 'GPS_' + cam_id] = convert_gps_to_kapture_record(exif_data)

        self.assertTrue(equal_records_gnss(kapture_data.records_gnss, rebuilt_records))
Exemplo n.º 5
0
 def test_read_exif(self):
     image_filepath_w_exif = path.join(self._samples_folder, 'berlin/opensfm/images/01.jpg')
     exif_data = read_exif(image_filepath_w_exif)
     self.assertIsInstance(exif_data, dict)
     self.assertEqual(6, len(exif_data))
     self.assertIn('GPS', exif_data)
Exemplo n.º 6
0
 def test_read_exif_invalid(self):
     invalid_image_filepath = path.join(self._samples_folder,
                                        '7scenes/microsoft/stairs/seq-01/frame-000000.color.jpg')
     exif_data = read_exif(invalid_image_filepath)
     self.assertIsNone(exif_data)