add depth map
This commit is contained in:
@@ -4,7 +4,7 @@ import cv2
|
|||||||
import numpy as np
|
import numpy as np
|
||||||
from orisys import Sensor
|
from orisys import Sensor
|
||||||
|
|
||||||
def draw_arrows_fade(img, flow, grid_spacing=10, arrow_scale=1.0, threshold=5.0):
|
def draw_arrows_fade(img, flow, depth, depth_scale=0.5, grid_spacing=40, arrow_scale=1.0, threshold=5.0):
|
||||||
"""
|
"""
|
||||||
Draw optical flow arrows on image with transparency based on magnitude.
|
Draw optical flow arrows on image with transparency based on magnitude.
|
||||||
|
|
||||||
@@ -18,8 +18,10 @@ def draw_arrows_fade(img, flow, grid_spacing=10, arrow_scale=1.0, threshold=5.0)
|
|||||||
Returns:
|
Returns:
|
||||||
Image with arrows drawn, blended with original image
|
Image with arrows drawn, blended with original image
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
depth_img = cv2.applyColorMap(((depth+1)*depth_scale* 255.0).astype('uint8'), cv2.COLORMAP_HOT)
|
||||||
# Make a copy of the image
|
# Make a copy of the image
|
||||||
img_copy = img.copy()
|
img_copy = depth_img.copy()
|
||||||
|
|
||||||
# Convert grayscale to BGR if needed
|
# Convert grayscale to BGR if needed
|
||||||
if len(img_copy.shape) == 2 or img_copy.shape[2] == 1:
|
if len(img_copy.shape) == 2 or img_copy.shape[2] == 1:
|
||||||
@@ -140,8 +142,9 @@ def main():
|
|||||||
# 向量场: VRAW, VNORMAL, VSHEAR: 原始,法向,切向
|
# 向量场: VRAW, VNORMAL, VSHEAR: 原始,法向,切向
|
||||||
# 帧率,时间戳: FPS, TIMESTAMP
|
# 帧率,时间戳: FPS, TIMESTAMP
|
||||||
# 变形量总和: FNORMAL , FSHEARX, FSHEARY : 法向,切向(X),切向(Y)
|
# 变形量总和: FNORMAL , FSHEARX, FSHEARY : 法向,切向(X),切向(Y)
|
||||||
fps, fn, fx, fy, flow = sensor1.read_info(sensor1.info.FPS, sensor1.info.FNORMAL, sensor1.info.FSHEARX, sensor1.info.FSHEARY, sensor1.info.VRAW)
|
fps, fn, fx, fy, flow, depth = sensor1.read_info(sensor1.info.FPS, sensor1.info.FNORMAL, sensor1.info.FSHEARX, sensor1.info.FSHEARY, sensor1.info.VRAW, sensor1.info.DEPTH)
|
||||||
arrows = draw_arrows_fade(sensor1.img, flow)
|
arrows = draw_arrows_fade(sensor1.img, flow, depth)
|
||||||
|
print(fps,np.min(depth),np.mean(depth))
|
||||||
cv2.imshow("Deformation", arrows)
|
cv2.imshow("Deformation", arrows)
|
||||||
|
|
||||||
key = cv2.waitKey(1)
|
key = cv2.waitKey(1)
|
||||||
|
|||||||
Reference in New Issue
Block a user