halcon找到最左侧/最顶点

 

 


*以灰度值大于Threshold区域和灰度值小于Threshold的区域为分界点提取亚像素精密轮廓
threshold_sub_pix (Image, Border, Fenjie)
segment_contours_xld (Border, Edges, 'lines', PingHua, 4, 2)

dev_display(Edges)
union_adjacent_contours_xld (Edges, UnionContours, 10, 1, 'attr_keep')
smooth_contours_xld (UnionContours, SmoothedContours, 9)
select_contours_xld (SmoothedContours, SelectedContours, 'contour_length', 1, 2000, -0.5, 0.5)

sort_contours_xld (SelectedContours, SortedContours, 'character', 'true', 'column')
count_obj (SortedContours, Number)
PeakRows:=[]
PeakCols:=[]


for i := 1 to Number by 1
select_obj (SortedContours, ObjectSelected, i)
get_contour_xld (ObjectSelected, RowR, ColR)
if(LeftOrRight=='left')
sortcol:=ColR
endif
if(LeftOrRight=='right')
sortcol:=-ColR
endif
tuple_sort_index (sortcol, Indices)
PeakRow := RowR[Indices[0]]
PeakCol := ColR[Indices[0]]
PeakRows := [PeakRows,PeakRow]
PeakCols := [PeakCols,PeakCol]
disp_message (WindowHandle, '顶点'+i+':'+PeakRow+','+PeakCol, 'window', MessagePosition+(i-1)*20, 5, 'cyan', 'false')
disp_cross (WindowHandle, PeakRows, PeakCols, 12, rad(45))
disp_message (WindowHandle, i, 'image', round(PeakRow), round(PeakCol)-15, 'red', 'false')
endfor
gen_cross_contour_xld (Cross, PeakRows1, PeakCols1, 16, Phi)
dev_set_color('blue')
*显示顶点
dev_display(Cross)

————————————————
版权声明:本文为CSDN博主「大胡子大叔」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/sunnyrainflower/article/details/130329789

posted @ 2023-09-20 17:04  QuincyYi  阅读(135)  评论(0编辑  收藏  举报