Commit 80787c20 authored by Guillaume HEUSCH's avatar Guillaume HEUSCH
Browse files

[camera] very small modif, cosmetic changes

parent 79c710a6
......@@ -4,18 +4,21 @@ import numpy as np
import cv2
def depth_to_rgb(depth_frame, min_depth_value, max_depth_value,
colormap=cv2.COLORMAP_HSV, range_min=None, range_max=None):
valid_mask = cv2.inRange(depth_frame, min_depth_value, max_depth_value)
if range_min is None or range_max is None:
range_min, range_max, _, _ = cv2.minMaxLoc(depth_frame, valid_mask)
if range_max != range_min:
scale = np.iinfo(np.uint8).max / (range_max - range_min)
else:
scale = 1.0
depth_frame_view = cv2.convertScaleAbs(depth_frame, alpha=scale,
beta=-scale * range_min)
return cv2.applyColorMap(depth_frame_view, colormap)
#def depth_to_rgb(depth_frame, min_depth_value, max_depth_value,
# colormap=cv2.COLORMAP_HSV, range_min=None, range_max=None):
# """
#
# """
# valid_mask = cv2.inRange(depth_frame, min_depth_value, max_depth_value)
# if range_min is None or range_max is None:
# range_min, range_max, _, _ = cv2.minMaxLoc(depth_frame, valid_mask)
# if range_max != range_min:
# scale = np.iinfo(np.uint8).max / (range_max - range_min)
# else:
# scale = 1.0
# depth_frame_view = cv2.convertScaleAbs(depth_frame, alpha=scale,
# beta=-scale * range_min)
# return cv2.applyColorMap(depth_frame_view, colormap)
def points_to_color(points, intrinsics):
......@@ -122,12 +125,10 @@ def get_UV_map(depth_image, min_depth, depth_intrinsics, depth_scale,
np.clip(color_pixels[1] / color_intrinsics.height, 0, 1))
def get_correspondences(points, UV_map, color_width, color_height, depth_width,
depth_height):
x = points[:, 0].reshape((1, -1)) -\
np.array(UV_map[0] * color_width).ravel().reshape((-1, 1))
y = points[:, 1].reshape((1, -1)) -\
np.array(UV_map[1] * color_height).ravel().reshape((-1, 1))
def get_correspondences(points, UV_map, color_width, color_height, depth_width, depth_height):
x = points[:, 0].reshape((1, -1)) - np.array(UV_map[0] * color_width).ravel().reshape((-1, 1))
y = points[:, 1].reshape((1, -1)) - np.array(UV_map[1] * color_height).ravel().reshape((-1, 1))
dist2 = x * x + y * y
return np.nanmin(dist2, 0), np.nanargmin(dist2, 0)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment