| 93 | |
| 94 | |
| 95 | def read_binary_file_to_ndarray(file_path, width, height): |
| 96 | nv21_size = width * height * 3 // 2 # NV21 size calculation |
| 97 | |
| 98 | try: |
| 99 | with open(file_path, 'rb') as file: |
| 100 | file_data = file.read() # Read the entire file |
| 101 | |
| 102 | if len(file_data) != nv21_size: |
| 103 | print(f"Expected file size is {nv21_size}, but got {len(file_data)}") |
| 104 | return None |
| 105 | |
| 106 | # Assuming the file data is a complete NV21 frame |
| 107 | data = np.frombuffer(file_data, dtype=np.uint8) |
| 108 | return data |
| 109 | except FileNotFoundError: |
| 110 | print(f"File '{file_path}' not found.") |
| 111 | return None |
| 112 | except Exception as e: |
| 113 | print(f"An error occurred while reading the file: {str(e)}") |
| 114 | return None |
| 115 | |
| 116 | |
| 117 | def print_benchmark_table(benchmark_results): |