def test_is_depth_available_is_true_iff_all_images_have_depth_data(self): subject = ic.ImageCollection( images=self.images, type_=core.sequence_type.ImageSequenceType.SEQUENTIAL, db_client_=self.create_mock_db_client()) self.assertTrue(subject.is_depth_available) subject = ic.ImageCollection( type_=core.sequence_type.ImageSequenceType.SEQUENTIAL, images=du.defaults({1.7: make_image(depth_data=None)}, self.images), db_client_=self.create_mock_db_client()) self.assertFalse(subject.is_depth_available)
def test_is_stereo_available_is_true_iff_all_images_are_stereo_images( self): stereo_images_list = { i * 1.3: make_stereo_image(index=i) for i in range(10) } subject = ic.ImageCollection( type_=core.sequence_type.ImageSequenceType.SEQUENTIAL, images=stereo_images_list, db_client_=self.create_mock_db_client()) self.assertTrue(subject.is_stereo_available) subject = ic.ImageCollection( type_=core.sequence_type.ImageSequenceType.SEQUENTIAL, images=du.defaults(stereo_images_list, self.images), db_client_=self.create_mock_db_client()) self.assertFalse(subject.is_stereo_available)
def make_mock_image_collection(num_images): return ic.ImageCollection( id_=bson.objectid.ObjectId(), type_=core.sequence_type.ImageSequenceType.NON_SEQUENTIAL, images={1.2 * idx: make_image() for idx in range(num_images)}, db_client_=None)
def test_timestamps_returns_all_timestamps_in_order(self): subject = ic.ImageCollection( images=self.images, type_=core.sequence_type.ImageSequenceType.SEQUENTIAL, db_client_=self.create_mock_db_client()) self.assertEqual([1.2 * t for t in range(10)], subject.timestamps) for stamp in subject.timestamps: self.assertIsNotNone(subject.get(stamp))
def make_instance(self, *args, **kwargs): kwargs = du.defaults( kwargs, { 'images': self.images, 'type_': core.sequence_type.ImageSequenceType.SEQUENTIAL, 'db_client_': self.create_mock_db_client() }) return ic.ImageCollection(*args, **kwargs)
def test_is_labels_available_is_true_iff_all_images_have_bounding_boxes( self): subject = ic.ImageCollection( images=self.images, type_=core.sequence_type.ImageSequenceType.SEQUENTIAL, db_client_=self.create_mock_db_client()) self.assertTrue(subject.is_labels_available) subject = ic.ImageCollection( type_=core.sequence_type.ImageSequenceType.SEQUENTIAL, images=du.defaults( { 1.7: make_image(metadata=imeta.ImageMetadata( hash_=b'\xf1\x9a\xe2|' + np.random.randint(0, 0xFFFFFFFF).to_bytes(4, 'big'), source_type=imeta.ImageSourceType.SYNTHETIC, camera_pose=tf.Transform( location=(800, 2 + np.random.uniform(-1, 1), 3), rotation=(4, 5, 6, 7 + np.random.uniform(-4, 4))), intrinsics=cam_intr.CameraIntrinsics( 800, 600, 550.2, 750.2, 400, 300), environment_type=imeta.EnvironmentType.INDOOR_CLOSE, light_level=imeta.LightingLevel.WELL_LIT, time_of_day=imeta.TimeOfDay.DAY, lens_focal_distance=5, aperture=22, simulation_world='TestSimulationWorld', lighting_model=imeta.LightingModel.LIT, texture_mipmap_bias=1, normal_maps_enabled=2, roughness_enabled=True, geometry_decimation=0.8, procedural_generation_seed=16234, labelled_objects=[], average_scene_depth=90.12)) }, self.images), db_client_=self.create_mock_db_client()) self.assertFalse(subject.is_labels_available)