예제 #1
0
    def test_tiff_io(self):
        '''Round-trip TIFF test that checks both dimensions and contents.'''
        w, h = 1000, 600
        rgb = np.zeros((h, w, 3), np.uint8)
        range = np.full((int(h / 2), int(w / 2)), 2.0, np.float32)
        multi = MultiImageTiff({
            MultiImagePageType.RGB: rgb,
            MultiImagePageType.Depth: range
        })

        tiff_path = os.path.join(self.temp_directory,
                                 'test-multi_image_tests1.tif')
        multi.save(tiff_path, near=1.0)
        read_near1 = MultiImageTiff.load(tiff_path)

        tiff_path2 = os.path.join(self.temp_directory,
                                  'test-multi_image_tests2.tif')
        multi.save(tiff_path2, near=2.0)
        read_near2 = MultiImageTiff.load(tiff_path2)

        self.assertEqual(read_near1.rgb.shape, (h, w, 3))
        self.assertEqual(read_near1.range.shape, (h / 2, w / 2))
        np.testing.assert_array_equal(read_near1.rgb, multi.rgb)
        np.testing.assert_array_almost_equal(read_near1.range,
                                             multi.range,
                                             decimal=4)
        np.testing.assert_array_almost_equal(read_near1.range,
                                             read_near2.range,
                                             decimal=4)
예제 #2
0
 def test_tiff_read(self):
     tiff_path = os.path.join(PATH, 'checkered360-rgbd.tif')
     multi = MultiImageTiff.load(tiff_path)
     w, h = 360, 180
     self.assertEqual(multi.rgb.shape, (h, w, 3))
     self.assertEqual(multi.range.shape, (h / 2, w / 2))
     # Check that range in middle of image is indeed ~ 5 m.
     # agreeing with generated image from 360rgbd01_generate.ipynb
     self.assertAlmostEqual(multi.range[int(h / 4), int(w / 4)],
                            5.0,
                            places=0)
예제 #3
0
    def test_inverse_range(self):
        w, h = 100, 60
        rgb = np.zeros((h, w, 3), np.uint8)
        inverse_range = np.full((h, w), 200, np.uint16)
        range = depth_image_of_inverse_depth_map(inverse_range)
        page_map = {
            MultiImagePageType.RGB: rgb,
            MultiImagePageType.InverseDepth: inverse_range
        }
        multi = MultiImageTiff(page_map)

        tiff_path = os.path.join(self.temp_directory, 'test-invdepth.tiff')
        multi.save(tiff_path)
        read_inverse_range = MultiImageTiff.load(tiff_path)
        np.testing.assert_array_almost_equal(read_inverse_range.range, range)
예제 #4
0
 def test_tiff_read_failure(self):
     with self.assertRaises(RuntimeError):
         MultiImageTiff.load("dummy")
예제 #5
0
print('unitize(Vector3(100, 201, 50)): ', unitize(Vector3(100, 201, 50)))

# rot3_tests
from sumo.geometry.rot3 import Rot3, ENU_R_CAMERA
import numpy as np
wRc = np.transpose(np.array([[1, 0, 0], [0, 0, -1], [0, 1, 0]], dtype=float))
rot = Rot3(wRc)
print(rot.matrix())

# MultiImageTiff
from sumo.geometry.inverse_depth import depth_image_of_inverse_depth_map
from sumo.images.multi_image_tiff import MultiImageTiff, MultiImagePageType

tiff_path = parutil.get_file_path(
    '/mnt/lustre/sunjiankai/Dataset/sample_data/sumo-input/sumo-input.tif')
multi = MultiImageTiff.load(tiff_path)
print('multi.rgb.shape: ', multi.rgb.shape, 'multi.range.shape (Depth): ',
      multi.range.shape, 'multi.category.shape (Category): ',
      multi.category.shape, 'multi.instance.shape (Instance): ',
      multi.instance.shape)
# multi.rgb.shape:  (1024, 6144, 3) multi.range.shape:  (1024, 6144) multi.category.shape:  (1024, 6144) multi.instance.shape:  (1024, 6144)

from sumo.semantic.project_converter import ProjectConverter
from sumo.semantic.project_scene import ProjectScene

glb_path = parutil.get_file_path(
    '/mnt/lustre/sunjiankai/Dataset/sample_data/sumo-output')
meshes_model = ProjectScene.load(glb_path, "bounding_box_sample")
bbox_model = ProjectConverter().run(meshes_model, "bounding_box")
print('bbox_model.elements[\'1087\'].bounds.corners():\n',
      bbox_model.elements['1087'].bounds.corners())