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

求助大神如何识别零件腔体中心

[复制链接]
小妖怪旅店 发表于 2026-2-5 18:01:09 | 显示全部楼层 |阅读模式
悬赏10视觉币
如图“识别示例”,需要获取到图像中的红色的四条腔体外边界,从而获取两条对边的中心线,最终获取到中心点,需要输出中心坐标,及垂直方向的角度偏差。

识别示例

识别示例

腔体

腔体

最佳答案

查看完整内容

卡尺求完4条直线再求中心和角度就行了
奖励计划已经开启,本站鼓励作者发布最擅长的技术内容和资源,流量变现就在现在,[点我]加入吧~~~Go
大凡光学,专注标定板提供
去0564 发表于 2026-2-5 18:01:10 | 显示全部楼层
本帖最后由 去0564 于 2026-2-6 11:24 编辑
  1. read_image (Image, 'C:/Users/Administrator/Desktop/腔体图像.png')
  2. rgb1_to_gray(Image,ImageGray)
  3. create_metrology_model(MetrologyHandle)
  4. typeName := ['min_score','measure_select','measure_transition']
  5. value := [0,'last', 'positive']
  6. value2 := [0,'first', 'negative']
  7. ***L1
  8. ROIl1 := [ 366.801, 659.756, 367.972, 525.184]
  9. add_metrology_object_line_measure (MetrologyHandle, ROIl1[0], ROIl1[1], ROIl1[2], ROIl1[3],\
  10.                                    50, 5, 1, 30, typeName, value, IndexL1)
  11. ***L2
  12. ROIl2 := [ 557.096, 721.389, 422.423, 721.389]
  13. add_metrology_object_line_measure (MetrologyHandle, ROIl2[0], ROIl2[1], ROIl2[2], ROIl2[3],\
  14.                                    10, 5, 1, 30, typeName, value, IndexL2)
  15. ***L3

  16. ROIl3 := [790.461, 586.594, 790.461, 508.831]
  17. add_metrology_object_line_measure (MetrologyHandle, ROIl3[0], ROIl3[1], ROIl3[2], ROIl3[3],\
  18.                                    50, 5, 1, 30, typeName, value2, IndexL3)
  19. ***L4
  20. ROIl4 := [ 636.511, 477.395, 499.116, 475.74]
  21. add_metrology_object_line_measure (MetrologyHandle, ROIl4[0], ROIl4[1], ROIl4[2], ROIl4[3],\
  22.                                    50, 5, 1, 30, typeName, value2, IndexL4)

  23. ***卡尺检测
  24. apply_metrology_model (Image, MetrologyHandle)
  25. **L1
  26. get_metrology_object_result (MetrologyHandle, IndexL1, 'all', 'result_type', 'all_param',LineL1)
  27. get_metrology_object_result_contour (ContourOutL1, MetrologyHandle, IndexL1, 'all', 1.5)
  28. **L2
  29. get_metrology_object_result (MetrologyHandle, IndexL2, 'all', 'result_type', 'all_param',LineL2)
  30. get_metrology_object_result_contour (ContourOutL2, MetrologyHandle, IndexL2, 'all', 1.5)
  31. **L3
  32. get_metrology_object_result (MetrologyHandle, IndexL3, 'all', 'result_type', 'all_param',LineL3)
  33. get_metrology_object_result_contour (ContourOutL3, MetrologyHandle, IndexL3, 'all', 1.5)
  34. **L4
  35. get_metrology_object_result (MetrologyHandle, IndexL4, 'all', 'result_type', 'all_param',LineL4)
  36. get_metrology_object_result_contour (ContourOutL4, MetrologyHandle, IndexL4, 'all', 1.5)

  37. **左上点
  38. intersection_lines(LineL1[0], LineL1[1], LineL1[2], LineL1[3], LineL4[0], LineL4[1], LineL4[2], LineL4[3], Rowlu, Columnlu, IsOverlapping)
  39. **右上点
  40. intersection_lines(LineL1[0], LineL1[1], LineL1[2], LineL1[3], LineL2[0], LineL2[1], LineL2[2], LineL2[3], Rowru, Columnru, IsOverlapping)
  41. **右下点
  42. intersection_lines(LineL2[0], LineL2[1], LineL2[2], LineL2[3], LineL3[0], LineL3[1], LineL3[2], LineL3[3], Rowrd, Columnrd, IsOverlapping)
  43. **左下点
  44. intersection_lines(LineL3[0], LineL3[1], LineL3[2], LineL3[3], LineL4[0], LineL4[1], LineL4[2], LineL4[3], Rowld, Columnld, IsOverlapping)
  45. **左中点
  46. lineLx := (Columnlu + Columnld)/2
  47. lineLy := (Rowlu + Rowld)/2
  48. **上中点
  49. lineUx := (Columnlu + Columnru)/2
  50. lineUy := (Rowlu + Rowru)/2
  51. **右中点
  52. lineRx := (Columnru + Columnrd)/2
  53. lineRy := (Rowru + Rowrd)/2
  54. **下中点
  55. lineDx := (Columnld + Columnrd)/2
  56. lineDy := (Rowrd + Rowld)/2
  57. dev_get_window (WindowHandle)
  58. disp_line(WindowHandle,lineLy, lineLx, lineRy, lineRx)
  59. disp_line(WindowHandle,lineUy, lineUx, lineDy, lineDx)

  60. ****中心点
  61. intersection_lines(lineLy, lineLx, lineRy, lineRx, lineUy, lineUx, lineDy, lineDx, CenterX,CenterY, IsOverlapping)
  62. angle_lx (lineUy, lineUx, lineDy, lineDx, Angle)
复制代码
卡尺求完4条直线再求中心和角度就行了

屏幕截图 2026-02-06 110122.png
奖励计划已经开启,本站鼓励作者发布最擅长的技术内容和资源,流量变现就在现在,[点我]加入吧~~~Go
回复

使用道具 举报

rtghj 发表于 2026-2-7 19:10:45 | 显示全部楼层
奖励计划已经开启,本站鼓励作者发布最擅长的技术内容和资源,流量变现就在现在,[点我]加入吧~~~Go
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

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