(test_file_path, frame_list_file_path, frames_directory_path)
| 37 | |
| 38 | |
| 39 | def 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 | |
| 60 | def test_cfr_h264_mp4_decoding(): |
no test coverage detected