Skip to content

Commit a2fef67

Browse files
committed
add dualbuff param for find rect demo
1 parent b1fac14 commit a2fef67

File tree

1 file changed

+7
-7
lines changed
  • projects/demo_diansai_2025_E_circle_track

1 file changed

+7
-7
lines changed

projects/demo_diansai_2025_E_circle_track/main.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
# debug_draw_err_msg = True # 画出圆心和画面中心的误差值和 FPS 信息,需要消耗7ms左右时间,慎用
3737
debug_draw_circle = True # 画出圆圈,实际是画点,需要再打开变量, debug 模式都会画,耗费时间比较多,慎用
3838
# debug_draw_rect = True # 画出矩形框
39-
debug_show_hires = True # 显示结果在高分辨率图上,而不是小分辨率图上, 开启了 hires_mode 才生效
39+
# debug_show_hires = True # 显示结果在高分辨率图上,而不是小分辨率图上, 开启了 hires_mode 才生效
4040

4141

4242
crop_padding = 12 # 裁切图时的外扩距离,调试到保证最近和最远位置整个黑框在检测框里,可以打开 DEBUG 模式看
@@ -49,15 +49,15 @@
4949
# 注意开启了这个模式,输出的误差值也是基于大图的分辨率
5050
high_res = 448 # 高分辨率模式宽高,越高越清晰但是帧率越低,注意 std_res 也要跟着改大点
5151
model_path = "/root/models/model_3356.mud" # 检测黑框模型路径,从 https://maixhub.com/model/zoo/1159 下载并传到开发板的 /root/models 目录
52-
52+
model_dual_buff_mode = True # 模型双缓冲模式,开启了帧率会高一帧处理的时间,但是延迟也会高一帧
5353

5454
find_circle = False # 在找到黑框以内白框后是否继续找圆,如果圆圈画得标准,在纸正中心则不用找,如果画点不在纸正中心则需要找。
5555
# 建议把A4纸制作正确就不用找了,帧率更高。
5656
# 可以用hires_mode 更清晰才能识别到,另外设置合理的 std_res
5757
cam_buff_num = 1 # 摄像头缓冲, 1 延迟更低帧率慢一点点, 2延迟更高帧率高一点点
5858
find_laser = False # 找激光点(未测试),实际使用时直接把摄像头中心和激光点保持移植就好了,不需要找激光点
5959

60-
auto_awb = True # 自动白平衡或者手动白平衡
60+
auto_awb = True # 自动白平衡或者手动白平衡
6161
awb_gain = [0.134, 0.0625, 0.0625, 0.1139] # 手动白平衡,auto_awb为False才生效, R GR GB B 的值,调 R 和 B 即可
6262
contrast = 80 # 对比度,会影响到检测,阴影和圆圈痕迹都会更重
6363

@@ -70,7 +70,7 @@
7070
model_path = model_path1
7171

7272
# 初始化摄像头
73-
detector = nn.YOLOv5(model=model_path, dual_buff = True)
73+
detector = nn.YOLOv5(model=model_path, dual_buff = model_dual_buff_mode)
7474

7575
# 初始化摄像头
7676
if hires_mode:
@@ -375,11 +375,11 @@ def debug_time(msg):
375375
# 画在小图上显示
376376
# too slow
377377
# center_ai = image.resize_map_pos(img.width(), img.height(), img_ai.width(), img_ai.height(), image.Fit.FIT_FILL, original_center_point[0], original_center_point[1])
378-
center_ai = [int(original_center_point[0] * img_ai_scale[0]), int(original_center_point[1] * img_ai_scale[1])]
378+
center_ai = [int(original_center_point[0] / img_ai_scale[0]), int(original_center_point[1] / img_ai_scale[1])]
379379
img_ai.draw_circle(center_ai[0], center_ai[1], 2, image.COLOR_RED, thickness=-1)
380380
pts = orig_circle_pts[0] # shape: (N, 2)
381381

382-
scaled_pts = (pts * img_ai_scale).astype(np.int32) # shape: (N, 2)
382+
scaled_pts = (pts / img_ai_scale).astype(np.int32) # shape: (N, 2)
383383
points = scaled_pts.reshape(-1).tolist() # 转为 Python list(与原结果相同)
384384
if debug_draw_circle:
385385
img_ai.draw_keypoints(points, image.COLOR_RED, 1, line_thickness=1)
@@ -418,4 +418,4 @@ def debug_time(msg):
418418
if debug_draw_err_msg:
419419
img_ai.draw_string(2, img.height() - 32, f"err: {err_center[0]:5.1f}, {err_center[1]:5.1f}, fps: {time.fps():2.0f}", image.COLOR_RED, scale=1.5, thickness=2)
420420
disp.show(img_ai)
421-
debug_time("display img")
421+
debug_time("display img")

0 commit comments

Comments
 (0)