File size: 741 Bytes
bfbecd6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
# read the h5 file
import h5py
import numpy as np
import argparse
from pathlib import Path


# create a parser
parser = argparse.ArgumentParser(description="Read h5 file and convert to mm depth")
parser.add_argument("--input", type=str, help="input h5 file or dir")


if __name__ == "__main__":
    # parse the arguments
    args = parser.parse_args()
    inputs = sorted(Path(args.input).glob("*.h5")) if Path(args.input).is_dir() else [Path(args.input)]

    for input in tqdm(inputs):
        # read h5 file
        f = h5py.File(input, 'r')
        image = np.array(f['depth'])
        image = image * 1000.0
        image = image.astype("uint16")
        cv.imwrite(str(output / (input.stem + ".png")), image)

    print("=== Done ===")