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

CAD-dxf格式匹配问题,它是以xld的那个位置作为匹配中心的?

[复制链接]
fate. 发表于 2024-1-4 09:32:38 | 显示全部楼层 |阅读模式
  1. read_image (Image, 'metal-parts/metal-part-model-02')
  2. dev_display (Image)
  3. dev_set_color ('green')
  4. threshold (Image, Region, 79, 202)  

  5. *得到xld
  6. inspect_shape_model (Image, ModelImages, ModelRegions, 1, 30)
  7. connection (ModelRegions, ConnectedRegions)
  8. select_shape (ConnectedRegions, SelectedRegions, 'area', 'and', 20, 100000)
  9. union1 (SelectedRegions, ModelRegions)
  10. gen_contours_skeleton_xld (ModelRegions, ModelContours, 1, 'filter')
  11. write_contour_xld_dxf (ModelContours, 'a')

  12. *创建模板xld
  13. read_contour_xld_dxf (Contours11, 'a', [], [], DxfStatus)
  14. create_scaled_shape_model_xld (Contours11, 'auto', -0.39, 0.79, 'auto', 0.9, 1.1, 'auto', 'auto', 'ignore_color_polarity', 5, ModelID)
  15. get_shape_model_contours (ModelCont, ModelID, 1)

  16. *匹配
  17. find_shape_model (Image, ModelID, -0.39, 0.79, 0.5, 1, 0, 'interpolation', 0, 0, Row, Column, Angle, Score)
  18. dev_set_color ('red')
  19. gen_cross_contour_xld (endCross, Row, Column, 300, 0)
复制代码

------------------------
基于图像的模板匹配是基于匹配工件的小区域作为中心。
这个基于xld作为模板的,我试了半天,也没想出来,它是以哪个位置作为中心的。
奖励计划已经开启,本站鼓励作者发布最擅长的技术内容和资源,流量变现就在现在,[点我]加入吧~~~Go
halcon2016 发表于 2024-1-4 10:48:11 | 显示全部楼层
  1. SmallestRectangle1Xld (ho_FinalContours, &hv_Row1, &hv_Column1, &hv_Row2, &hv_Column2);//计算模板默认中心点
  2. hv_CenterRow=(hv_Row1.TupleMin()+hv_Row2.TupleMax())/2.0;
  3. hv_CenterCol=(hv_Column1.TupleMin()+hv_Column2.TupleMax())/2.0;
复制代码
这是我用的计算方法
奖励计划已经开启,本站鼓励作者发布最擅长的技术内容和资源,流量变现就在现在,[点我]加入吧~~~Go
halcon2016 发表于 2024-1-4 10:16:57 | 显示全部楼层
create_scaled_shape_model_xld算了文档原话:
  1. The center of gravity of the smallest surrounding rectangle of the Contours that is parallel to the coordinate axes is used as the origin (reference point) of the model
复制代码
奖励计划已经开启,本站鼓励作者发布最擅长的技术内容和资源,流量变现就在现在,[点我]加入吧~~~Go
 楼主| fate. 发表于 2024-1-4 10:35:54 | 显示全部楼层
halcon2016 发表于 2024-1-4 10:16
create_scaled_shape_model_xld算了文档原话:The center of gravity of the smallest surrounding rectan ...

但是很奇怪,小红色十字就是xld的重心    area_center_points_xld (Contours11, Area3, Row2, Column2)
大十字就是他作为模板的中心位置。差的蛮多的
屏幕截图 2024-01-04 103428.png
奖励计划已经开启,本站鼓励作者发布最擅长的技术内容和资源,流量变现就在现在,[点我]加入吧~~~Go
halcon2016 发表于 2024-1-4 10:45:10 | 显示全部楼层
fate. 发表于 2024-1-4 10:35
但是很奇怪,小红色十字就是xld的重心    area_center_points_xld (Contours11, Area3, Row2, Column2)
...

你没仔细理解那句英文的意思,是用平行坐标轴的最小矩形来包围整个xld,这个矩形的重心(实际就是几何中心)作为原点,跟你用area_center_points_xld求出来的不是一个概念
奖励计划已经开启,本站鼓励作者发布最擅长的技术内容和资源,流量变现就在现在,[点我]加入吧~~~Go
 楼主| fate. 发表于 2024-1-4 11:20:37 | 显示全部楼层
halcon2016 发表于 2024-1-4 10:45
你没仔细理解那句英文的意思,是用平行坐标轴的最小矩形来包围整个xld,这个矩形的重心(实际就是几何中 ...

明白了,原来是基于水平坐标轴的。感谢!受教了。
奖励计划已经开启,本站鼓励作者发布最擅长的技术内容和资源,流量变现就在现在,[点我]加入吧~~~Go
绝地武士 发表于 2024-1-4 11:52:26 | 显示全部楼层
halcon2016 发表于 2024-1-4 10:48
这是我用的计算方法

这个像是导出代码自动生成的求取中心的代码
奖励计划已经开启,本站鼓励作者发布最擅长的技术内容和资源,流量变现就在现在,[点我]加入吧~~~Go
halcon2016 发表于 2024-1-4 14:21:58 | 显示全部楼层
绝地武士 发表于 2024-1-4 11:52
这个像是导出代码自动生成的求取中心的代码

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

本版积分规则

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