diff --git a/fishsense_lite/commands/label_studio.py b/fishsense_lite/commands/label_studio.py index 2f69422..4d856b5 100644 --- a/fishsense_lite/commands/label_studio.py +++ b/fishsense_lite/commands/label_studio.py @@ -127,7 +127,7 @@ def execute_fishial( ml_depth_map = DepthAnythingDepthMap(img8, device) - if laser_coords: + if laser_coords is not None: laser_coords_int = np.round(laser_coords).astype(int) depth_map = LaserDepthMap( laser_coords, lens_calibration, estimated_laser_calibration diff --git a/fishsense_lite/utils.py b/fishsense_lite/utils.py index dfeafeb..95704e6 100644 --- a/fishsense_lite/utils.py +++ b/fishsense_lite/utils.py @@ -29,9 +29,21 @@ def get_root(files: List[Path]) -> Path | None: return root +def uint8_2_double(img: np.ndarray) -> np.ndarray: + return img.astype(np.float64) / 255 + + def uint16_2_double(img: np.ndarray) -> np.ndarray: return img.astype(np.float64) / 65535 +def double_2_uint8(img: np.ndarray) -> np.ndarray: + return (img * 255).astype(np.uint8) + + +def double_2_uint16(img: np.ndarray) -> np.ndarray: + return (img * 65535).astype(np.uint16) + + def uint16_2_uint8(img: np.ndarray) -> np.ndarray: - return (uint16_2_double(img) * 255).astype(np.uint8) + return double_2_uint8(uint16_2_double(img))