forked from srl-ethz/srl_il
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcheck.py
38 lines (33 loc) · 1.43 KB
/
check.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import h5py
import os
def check_extrinsics_in_h5(file_path):
"""Check if the key 'oakd_front_view/extrinsics' exists in the HDF5 file."""
try:
# Open the .h5 file
with h5py.File(file_path, 'r') as f:
# Check if the key 'oakd_front_view/extrinsics' exists in the file
if 'oakd_front_view/extrinsics' in f:
print(f"Found 'oakd_front_view/extrinsics' in {file_path}")
return True
else:
print(f"'oakd_front_view/extrinsics' NOT found in {file_path}")
return False
except Exception as e:
print(f"Error reading {file_path}: {e}")
return False
def check_directory_for_extrinsics(directory):
"""Check all .h5 files in the given directory for the 'oakd_front_view/extrinsics' key."""
# Loop through all files in the directory
for filename in os.listdir(directory):
file_path = os.path.join(directory, filename)
# Only process .h5 files
if file_path.endswith('.h5') and os.path.isfile(file_path):
check_extrinsics_in_h5(file_path)
if __name__ == "__main__":
# Replace with your desired directory path
directory = input("Enter the directory path to check: ")
# Check if the directory exists
if os.path.isdir(directory):
check_directory_for_extrinsics(directory)
else:
print(f"Error: The directory {directory} does not exist.")