|
|
@@ -0,0 +1,59 @@ |
|
|
|
<?xml version="1.0" encoding="UTF-8"?> |
|
|
|
<hdevelop file_version="1.2" halcon_version="21.05.0.0"> |
|
|
|
<procedure name="My_Sort_XY"> |
|
|
|
<interface> |
|
|
|
<io> |
|
|
|
<par name="ConnectedRegions" base_type="iconic" dimension="0"/> |
|
|
|
</io> |
|
|
|
<oo> |
|
|
|
<par name="ObjectSelected17" base_type="iconic" dimension="0"/> |
|
|
|
</oo> |
|
|
|
<ic> |
|
|
|
<par name="Width" base_type="ctrl" dimension="0"/> |
|
|
|
<par name="times" base_type="ctrl" dimension="0"/> |
|
|
|
</ic> |
|
|
|
</interface> |
|
|
|
<body> |
|
|
|
<l>num:=1</l> |
|
|
|
<l>* times:=1</l> |
|
|
|
<c>*先判断是行是列,用不同的排序方式</c> |
|
|
|
<l>height_width_ratio (ConnectedRegions, Height, Width1, Ratio)</l> |
|
|
|
<l>tuple_mean (Height, Height_Mean)</l> |
|
|
|
<l>tuple_mean (Width1, Width1_Mean)</l> |
|
|
|
<l>if (Height_Mean>Width1_Mean)</l> |
|
|
|
<l> para:='row'</l> |
|
|
|
<l>else</l> |
|
|
|
<l> para:='column'</l> |
|
|
|
<l>endif</l> |
|
|
|
<l>union1 (ConnectedRegions, RegionUnion11)</l> |
|
|
|
<l>closing_rectangle1 (RegionUnion11, RegionClosing10, Width, 1)</l> |
|
|
|
<l>connection (RegionClosing10, ConnectedRegions20)</l> |
|
|
|
<l>sort_region (ConnectedRegions20, SortedRegions, 'first_point', 'true', 'row')</l> |
|
|
|
<l>count_obj (ConnectedRegions20, Number15)</l> |
|
|
|
<l>for Index9 := 1 to Number15 by 1</l> |
|
|
|
<l> select_obj (SortedRegions, ObjectSelected7, Index9)</l> |
|
|
|
<l> intersection (ObjectSelected7, RegionUnion11, RegionIntersection3)</l> |
|
|
|
<l> connection (RegionIntersection3, ConnectedRegions22)</l> |
|
|
|
<l> sort_region (ConnectedRegions22, SortedRegions2, 'first_point', 'true', para)</l> |
|
|
|
<l> count_obj (SortedRegions2, Number16)</l> |
|
|
|
<l> for Index10 := 1 to Number16 by 1</l> |
|
|
|
<c> </c> |
|
|
|
<l> if (times=num)</l> |
|
|
|
<l> select_obj (SortedRegions2,ObjectSelected17, Index10) </l> |
|
|
|
<l> return()</l> |
|
|
|
<l> endif</l> |
|
|
|
<l> num:=num+1</l> |
|
|
|
<l> endfor</l> |
|
|
|
<l>endfor</l> |
|
|
|
<l>return ()</l> |
|
|
|
</body> |
|
|
|
<docu id="My_Sort_XY"> |
|
|
|
<parameters> |
|
|
|
<parameter id="ConnectedRegions"/> |
|
|
|
<parameter id="ObjectSelected17"/> |
|
|
|
<parameter id="Width"/> |
|
|
|
<parameter id="times"/> |
|
|
|
</parameters> |
|
|
|
</docu> |
|
|
|
</procedure> |
|
|
|
</hdevelop> |