fixed new sample cannot detect boxes due to filter
This commit is contained in:
+7
-16
@@ -7,10 +7,10 @@ import time
|
||||
def main():
|
||||
|
||||
# 方式1: 从视频文件读取
|
||||
sensor = orisys.Sensor("./s1.mp4", isstitch=True, cuda=True, verbose=True)
|
||||
# sensor = orisys.Sensor("./s1.mp4", isstitch=True, cuda=True, verbose=True)
|
||||
|
||||
# 方式2: 从摄像头读取(取消注释使用)
|
||||
# sensor = orisys.Sensor(0, isstitch=True, cuda=True, verbose=True)
|
||||
sensor = orisys.Sensor(0, isstitch=True, cuda=True, verbose=True)
|
||||
|
||||
print("\n按 'q' 退出程序,按 'r' 重置光流追踪器")
|
||||
|
||||
@@ -36,34 +36,25 @@ def main():
|
||||
)
|
||||
cv2.imshow("形变场 Deformation", arrows)
|
||||
|
||||
mag_img = orisys.util.draw_magnitude_map(
|
||||
sensor.img.copy(),
|
||||
vnormal,
|
||||
threshold=5,
|
||||
colormap=cv2.COLORMAP_HOT,
|
||||
downsample_factor = 1
|
||||
)
|
||||
cv2.imshow("magnitude map", mag_img)
|
||||
|
||||
# 计算触碰点
|
||||
contact_result = sensor.get_contact(min_magnitude=1, expansion_threshold=0.01,denoise_sigma=15)
|
||||
sensor.compute_contact(min_magnitude=0.1,expansion_threshold=0.01,denoise_sigma=15)
|
||||
|
||||
# 在图像上触碰点和区域
|
||||
image_with_foe = orisys.util.draw_foe(sensor.img.copy(), contact_result)
|
||||
image_with_foe = orisys.util.draw_contact(sensor.img.copy(), sensor.contour, sensor.centroid)
|
||||
cv2.imshow("Contact Centroid", image_with_foe)
|
||||
|
||||
# 计算触碰区域
|
||||
divergence = contact_result['divergence_map']
|
||||
depth_map = sensor.depth_map
|
||||
|
||||
# 归一化散度值到0-255范围(使用绝对值,然后归一化)
|
||||
div_abs = divergence
|
||||
div_abs = depth_map
|
||||
if div_abs.max() > div_abs.min():
|
||||
div_normalized = ((div_abs - div_abs.min()) / (div_abs.max() - div_abs.min()) * 255).astype(np.uint8)
|
||||
else:
|
||||
div_normalized = np.zeros_like(div_abs, dtype=np.uint8)
|
||||
|
||||
# 应用颜色映射(使用JET:蓝色=低散度,红色=高散度)
|
||||
cv2.imshow("Divergence Map", cv2.applyColorMap(div_normalized, cv2.COLORMAP_JET))
|
||||
cv2.imshow("Depth Map", cv2.applyColorMap(div_normalized, cv2.COLORMAP_JET))
|
||||
|
||||
print(f"fps: {fps}")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user