Exemplo n.º 1
0
 def test_should_return_batches_equivalent_to_number_of_frames(self):
     video_loader = OpenCVReader(file_url=os.path.join(
         PATH_PREFIX, 'dummy.avi'),
                                 batch_mem_size=FRAME_SIZE)
     batches = list(video_loader.read())
     expected = list(create_dummy_batches(batch_size=1))
     self.assertTrue(batches, expected)
Exemplo n.º 2
0
 def test_should_return_one_batch(self):
     video_loader = OpenCVReader(file_url=os.path.join(
         PATH_PREFIX, 'dummy.avi'),
                                 batch_mem_size=NUM_FRAMES * FRAME_SIZE)
     batches = list(video_loader.read())
     expected = list(create_dummy_batches())
     self.assertTrue(batches, expected)
Exemplo n.º 3
0
 def test_should_start_frame_number_from_two(self):
     video_loader = OpenCVReader(file_url=os.path.join(
         PATH_PREFIX, 'dummy.avi'),
                                 batch_mem_size=FRAME_SIZE * NUM_FRAMES,
                                 start_frame_id=2)
     batches = list(video_loader.read())
     expected = list(
         create_dummy_batches(filters=[i for i in range(0, NUM_FRAMES)],
                              start_id=2))
     self.assertTrue(batches, expected)
Exemplo n.º 4
0
 def test_should_skip_first_two_frames_and_batch_size_equal_to_no_of_frames(
         self):
     video_loader = OpenCVReader(file_url=os.path.join(
         PATH_PREFIX, 'dummy.avi'),
                                 batch_mem_size=FRAME_SIZE * NUM_FRAMES,
                                 offset=2)
     batches = list(video_loader.read())
     expected = list(
         create_dummy_batches(filters=[i for i in range(2, NUM_FRAMES)]))
     self.assertTrue(batches, expected)
Exemplo n.º 5
0
    def read(self,
             table: DataFrameMetadata,
             batch_mem_size: int,
             predicate_func=None) -> Iterator[Batch]:

        metadata_file = Path(table.file_url) / self.metadata
        video_file_name = self._get_video_file_path(metadata_file)
        video_file = Path(table.file_url) / video_file_name
        reader = OpenCVReader(str(video_file), batch_mem_size=batch_mem_size)
        for batch in reader.read():
            yield batch
Exemplo n.º 6
0
    def test_should_load_and_select_real_video_in_table(self):
        query = """LOAD DATA INFILE 'data/ua_detrac/ua_detrac.mp4'
                   INTO UADETRAC;"""
        execute_query_fetch_all(query)

        select_query = "SELECT * FROM UADETRAC;"
        actual_batch = execute_query_fetch_all(select_query)
        actual_batch.sort()
        video_reader = OpenCVReader("data/ua_detrac/ua_detrac.mp4",
                                    batch_mem_size=30000000)
        expected_batch = Batch(frames=pd.DataFrame())
        for batch in video_reader.read():
            expected_batch += batch
        expected_batch.modify_column_alias("uadetrac")
        self.assertEqual(actual_batch, expected_batch)