设置首页收藏本站
开启左侧

求助这坐标怎么得到的

[复制链接]
senskaishin 发表于 2025-9-8 16:31:39 | 显示全部楼层 |阅读模式
  1. * fuse.hdev: measuring the width of a fuse wire
  2. *
  3. dev_update_window ('off')
  4. dev_close_window ()
  5. * ****
  6. * step: acquire image
  7. * ****
  8. read_image (Fuse, 'fuse')
  9. get_image_size (Fuse, Width, Height)
  10. dev_open_window_fit_image (Fuse, 0, 0, Width, Height, WindowID)
  11. set_display_font (WindowID, 12, 'mono', 'true', 'false')
  12. dev_set_draw ('margin')
  13. dev_set_line_width (3)
  14. dev_display (Fuse)
  15. set_display_font (WindowID, 12, 'mono', 'true', 'false')
  16. disp_continue_message (WindowID, 'black', 'true')
  17. stop ()
  18. * ****
  19. * step: create measure object
  20. * ****
  21. * -> specify ROI
  22. Row := 297
  23. Column := 545
  24. Length1 := 80
  25. Length2 := 10
  26. Angle := rad(90)
  27. gen_rectangle2 (ROI, Row, Column, Angle, Length1, Length2)
  28. * -> create measure object
  29. gen_measure_rectangle2 (Row, Column, Angle, Length1, Length2, Width, Height, 'bilinear', MeasureHandle)
  30. dev_display (ROI)
  31. disp_continue_message (WindowID, 'black', 'true')
  32. stop ()
  33. * ****
  34. * step: measure
  35. * ****
  36. measure_pairs (Fuse, MeasureHandle, 1, 1, 'negative', 'all', RowEdgeFirst, ColumnEdgeFirst, AmplitudeFirst, RowEdgeSecond, ColumnEdgeSecond, AmplitudeSecond, IntraDistance, InterDistance)
  37. disp_continue_message (WindowID, 'black', 'true')
  38. stop ()
  39. * ****
  40. * step: visualize results
  41. * ****
  42. for i := 0 to |RowEdgeFirst| - 1 by 1
  43.     gen_contour_polygon_xld (EdgeFirst, [-sin(Angle + rad(90)) * Length2 + RowEdgeFirst[i],-sin(Angle - rad(90)) * Length2 + RowEdgeFirst[i]], [cos(Angle + rad(90)) * Length2 + ColumnEdgeFirst[i],cos(Angle - rad(90)) * Length2 + ColumnEdgeFirst[i]])
  44.     gen_contour_polygon_xld (EdgeSecond, [-sin(Angle + rad(90)) * Length2 + RowEdgeSecond[i],-sin(Angle - rad(90)) * Length2 + RowEdgeSecond[i]], [cos(Angle + rad(90)) * Length2 + ColumnEdgeSecond[i],cos(Angle - rad(90)) * Length2 + ColumnEdgeSecond[i]])
  45.     dev_set_color ('cyan')
  46.     dev_display (EdgeFirst)
  47.     dev_set_color ('magenta')
  48.     dev_display (EdgeSecond)
  49.     dev_set_color ('blue')
  50.     if (i == 0)
  51.         set_tposition (WindowID, RowEdgeFirst[i] + 5, ColumnEdgeFirst[i] + 20)
  52.     else
  53.         set_tposition (WindowID, RowEdgeFirst[i] - 40, ColumnEdgeFirst[i] + 20)
  54.     endif
  55.     write_string (WindowID, 'width: ' + IntraDistance[i] + ' pix')
  56. endfor
  57. disp_continue_message (WindowID, 'black', 'true')
  58. stop ()
  59. * ****
  60. * step: destroy measure object
  61. * ****
  62. close_measure (MeasureHandle)
  63. dev_update_window ('on')
  64. dev_clear_window ()
复制代码


这个官方例程:求解
  1. gen_contour_polygon_xld (EdgeFirst, [-sin(Angle + rad(90)) * Length2 + RowEdgeFirst,-sin(Angle - rad(90)) * Length2 + RowEdgeFirst], [cos(Angle + rad(90)) * Length2 + ColumnEdgeFirst,cos(Angle - rad(90)) * Length2 + ColumnEdgeFirst])
  2.     gen_contour_polygon_xld (EdgeSecond, [-sin(Angle + rad(90)) * Length2 + RowEdgeSecond,-sin(Angle - rad(90)) * Length2 + RowEdgeSecond], [cos(Angle + rad(90)) * Length2 + ColumnEdgeSecond,cos(Angle - rad(90)) * Length2 + ColumnEdgeSecond])
复制代码
奖励计划已经开启,本站鼓励作者发布最擅长的技术内容和资源,流量变现就在现在,[点我]加入吧~~~Go
UKimiF 发表于 2025-9-9 09:22:26 | 显示全部楼层
没太看懂你的需求,直接给你解释了一下这段代码吧
  1. * fuse.hdev:测量保险丝线的宽度 *
  2. *//关闭窗口刷新,单步调试下不起作用,如果使用dev_update_off()是全局生效
  3. dev_update_window ('off')
  4. *//关闭窗口
  5. dev_close_window ()
  6. * ****
  7. * 步骤:获取图像
  8. * ****
  9. *//读入图片
  10. read_image (Fuse, 'fuse')
  11. *//获得你读入图片的尺寸宽度:Width和高度Height
  12. get_image_size (Fuse, Width, Height)
  13. *//根据上面获得宽高打开一个窗口,这里有点操作多余直接打开一个新窗口就行了
  14. dev_open_window_fit_image (Fuse, 0, 0, Width, Height, WindowID)
  15. *//设置显示的字体格式和大小
  16. set_display_font (WindowID, 12, 'mono', 'true', 'false')
复制代码

奖励计划已经开启,本站鼓励作者发布最擅长的技术内容和资源,流量变现就在现在,[点我]加入吧~~~Go
Mr.Han 发表于 2025-9-9 13:18:34 | 显示全部楼层
问题都没讲清楚啊
奖励计划已经开启,本站鼓励作者发布最擅长的技术内容和资源,流量变现就在现在,[点我]加入吧~~~Go
回复 支持 2 反对 0

使用道具 举报

lil888 发表于 2025-9-9 18:01:57 | 显示全部楼层
学习一下
奖励计划已经开启,本站鼓励作者发布最擅长的技术内容和资源,流量变现就在现在,[点我]加入吧~~~Go
347784474 发表于 2025-9-10 11:48:22 | 显示全部楼层
不太理解问题
奖励计划已经开启,本站鼓励作者发布最擅长的技术内容和资源,流量变现就在现在,[点我]加入吧~~~Go
 楼主| senskaishin 发表于 2025-9-11 11:48:02 | 显示全部楼层
  1. [-sin(Angle + rad(90)) * Length2 + RowEdgeFirst,-sin(Angle - rad(90)) * Length2 + RowEdgeFirst], [cos(Angle + rad(90)) * Length2 + ColumnEdgeFirst,cos(Angle - rad(90)) * Length2 + ColumnEdgeFirst])
复制代码

就是这些如何解释,为什么加rad(90)为什么用正弦余弦
奖励计划已经开启,本站鼓励作者发布最擅长的技术内容和资源,流量变现就在现在,[点我]加入吧~~~Go
testway1022 发表于 2025-10-10 16:27:41 | 显示全部楼层
senskaishin 发表于 2025-9-11 11:48
[-sin(Angle + rad(90)) * Length2 + RowEdgeFirst,-sin(Angle - rad(90)) * Length2 + RowEdgeFirst], [co ...

Halcon简单卡尺测量实例 | 鸟叔机器视觉(gen_measure_rectangle2 和 measure_pairs 算子说明)
https://www.sohu.com/a/477753850_121174094
需要从上面连接里面了解算子得到的相关端点点坐标位置以及 len1 和 len2 的含义,是后续三角函数计算所需要的。

结合 Angle 这个变量,通过在测量区域内保险丝与直线对的夹角,与原线对坐标计算三角函数结合坐标系方向得到正负偏移,加到原线对坐标上,即为带角度的保险丝边缘的大概轮廓坐标

当图片角度不同时对应坐标的计算公式简化便于理解

当图片角度不同时对应坐标的计算公式简化便于理解

奖励计划已经开启,本站鼓励作者发布最擅长的技术内容和资源,流量变现就在现在,[点我]加入吧~~~Go
您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表