标签:subset Dist xld dev halcon 龙熙 Indices 视觉 RowBegin
dev_update_off ()
dev_close_window ()
read_image (Image, 'diamond/diamond_01')
get_image_size (Image, Width, Height)
dev_open_window (0, 0, Width, Height, 'black', WindowHandle)
set_display_font (WindowHandle, 16, 'mono', 'true', 'false')
dev_set_line_width (2)
*
NumImages := 5
for Index := 1 to NumImages by 1
read_image (Image, 'diamond/diamond_' + Index$'.2')
*
* Segment diamond region
threshold (Image, Region, 128, 255)
clip_region_rel (Region, RegionClipped, 0, 290, 0, 0)
shape_trans (RegionClipped, RegionTrans, 'convex')
dilation_rectangle1 (RegionTrans, RegionDilation, 5, 1)
erosion_rectangle1 (RegionTrans, RegionErosion, 5, 1)
difference (RegionDilation, RegionErosion, RegionDifference)
reduce_domain (Image, RegionDifference, ImageReduced)
*
* Subpixel accurate fitting of the edges
edges_sub_pix (ImageReduced, Edges, 'canny', 3, 5, 5)
union_collinear_contours_xld (Edges, UnionContours, 100, 10, 4, rad(10), 'attr_keep')
select_contours_xld (UnionContours, SelectedContours, 'contour_length', 50, 2000, 0, 0)
fit_line_contour_xld (SelectedContours, 'tukey', -1, 0, 5, 2, RowBegin, ColBegin, RowEnd, ColEnd, Nr, Nc, Dist)
*
* Sort the edge contours and determine their intersection
tuple_sort_index (RowBegin, Indices)
RowBegin := subset(RowBegin,Indices)
RowEnd := subset(RowEnd,Indices)
ColBegin := subset(ColBegin,Indices)
ColEnd := subset(ColEnd,Indices)
Nr := subset(Nr,Indices)
Nc := subset(Nc,Indices)
Dist := subset(Dist,Indices)
gen_contour_polygon_xld (LineEdge1, [Dist[0] / Nr[0],0], [0,Dist[0] / Nc[0]])
gen_contour_polygon_xld (LineEdge2, [Dist[1] / Nr[1],Width - 1], [0,(Dist[1] - (Width - 1) * Nr[1]) / Nc[1]])
intersection_lines (RowBegin[0], ColBegin[0], RowEnd[0], ColEnd[0], RowBegin[1], ColBegin[1], RowEnd[1], ColEnd[1], RowTip, ColTip, IsOverlapping)
gen_cross_contour_xld (Cross, RowTip, ColTip, 20, rad(45))
*
* Display the results
dev_display (Image)
dev_set_color ('yellow')
dev_display (LineEdge1)
dev_display (LineEdge2)
dev_set_color ('blue')
dev_display (Cross)
if (Index != NumImages)
disp_continue_message (WindowHandle, 'black', 'true')
stop ()
endif
endfor
标签:subset,Dist,xld,dev,halcon,龙熙,Indices,视觉,RowBegin 来源: https://blog.csdn.net/weixin_45247360/article/details/105933278
本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享; 2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关; 3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关; 4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除; 5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。