MCPcopy Create free account
hub / github.com/NVIDIA/DALI / run_video_decoding_test

Function run_video_decoding_test

dali/test/python/test_dali_video_plugin_decoder.py:39–57  ·  view source on GitHub ↗
(test_file_path, frame_list_file_path, frames_directory_path)

Source from the content-addressed store, hash-verified

37
38
39def run_video_decoding_test(test_file_path, frame_list_file_path, frames_directory_path):
40 pipeline = video_decoder_pipeline(test_file_path)
41
42 (output,) = pipeline.run()
43 frames = output.as_cpu().as_array()
44
45 with open(frame_list_file_path) as f:
46 frame_list = f.read().splitlines()
47
48 for i, frame in enumerate(frames[0]):
49 # Check if the frame is equal to the ground truth frame.
50 # Due to differences in how the decoding is implemented in
51 # different video codecs, we can't guarantee that the frames
52 # will be exactly the same. Main purpose of this test is to
53 # check if the decoding is working and we hit the correct frames.
54 ground_truth = cv2.imread(f"{frames_directory_path}/{frame_list[i]}")
55 frame = cv2.cvtColor(frame, cv2.COLOR_RGB2BGR)
56 if not np.average(frame - ground_truth) < 15:
57 assert False, f"Frame {i} is not equal"
58
59
60def test_cfr_h264_mp4_decoding():

Callers 6

Calls 3

readMethod · 0.80
video_decoder_pipelineFunction · 0.70
runMethod · 0.45

Tested by

no test coverage detected