add private variable and copy when return by readinfo

This commit is contained in:
unknown
2025-12-30 14:52:06 +08:00
parent 2a739ed27c
commit 398d2b1706
8 changed files with 134 additions and 158 deletions
+14 -13
View File
@@ -7,10 +7,10 @@ import time
def main():
# 方式1: 从视频文件读取
sensor = orisys.Sensor("./s1.mp4", isstitch=True, cuda=True, verbose=True,config_name="./config/prototype.json")
# sensor = orisys.Sensor("./s1.mp4", isstitch=True, cuda=True, verbose=True,config_name="prototype")
# 方式2: 从摄像头读取(取消注释使用)
# sensor = orisys.Sensor(0, isstitch=True, cuda=False, verbose=True,config_name="./config/prototype.json")
sensor = orisys.Sensor(0, isstitch=True, cuda=True, verbose=True,config_name="prototype")
print("\n按 'q' 退出程序,按 'r' 重置光流追踪器")
@@ -20,32 +20,33 @@ def main():
# 步骤 2.2: 计算形变场
sensor.compute_deformation()
# 计算触碰点
# sensor.compute_contact(min_magnitude=0.1,expansion_threshold=0.01,denoise_sigma=15)
sensor.compute_contact()
fps, flow, vnormal = sensor.read_info(
#计算后读取信息
fps, flow, vnormal, img, contour, centroid, depth_map = sensor.read_info(
sensor.info.FPS,
sensor.info.VRAW,
sensor.info.VNORMAL
sensor.info.VNORMAL,
sensor.info.IMG,
sensor.info.CONTOUR,
sensor.info.CENTROID,
sensor.info.DEPTH
)
arrows = orisys.util.draw_arrows(
sensor.img.copy(), # 使用 copy() 避免修改原图
img, # 使用 copy() 避免修改原图
vnormal,
threshold=5,
grid_spacing=10,
arrow_scale=1.0
)
cv2.imshow("形变场 Deformation", arrows)
# 计算触碰点
# sensor.compute_contact(min_magnitude=0.1,expansion_threshold=0.01,denoise_sigma=15)
sensor.compute_contact()
# 在图像上触碰点和区域
image_with_foe = orisys.util.draw_contact(sensor.img.copy(), sensor.contour, sensor.centroid)
image_with_foe = orisys.util.draw_contact(img, contour, centroid)
cv2.imshow("Contact Centroid", image_with_foe)
# 计算触碰区域
depth_map = sensor.depth_map
# 归一化散度值到0-255范围(使用绝对值,然后归一化)
div_abs = depth_map