Halcon示例之求一个矩形四个角点坐标的八种方法

http://www.ihalcon.com/read-12547.html

gen_image_const (Image, 'byte', 512, 512)
get_domain (Image, Domain)
paint_region (Domain, Image, ImageResult1, 100, 'fill')
gen_rectangle1 (ROI_0, 204.77, 124.164, 278.986, 347.643)
 
paint_region (ROI_0, ImageResult1, ImageResult, 255, 'fill')
 
 
binary_threshold (ImageResult, Region, 'max_separability', 'light', UsedThreshold)
 
*已知矩形 求矩形四个顶点坐标
**方法一
get_region_polygon (Region, 5, Rows, Columns)
gen_cross_contour_xld (Cross, Rows, Columns, 60, 0.785398)
**方法二
gen_contour_region_xld (Region, Contours, 'border')
gen_polygons_xld (Contours, Polygons, 'ramer', 2)
get_polygon_xld (Polygons, Row, Col, Length, Phi)
gen_cross_contour_xld (Cross, Row, Col, 60, 0.785398)
**
get_lines_xld (Polygons, BeginRow, BeginCol, EndRow, EndCol, Length1, Phi1)
*********
**方法三
smallest_rectangle2 (Region, Row2, Column1, Phi3, Length12, Length21)
gen_rectangle2_contour_xld (Rectangle, Row2, Column1, Phi3, Length12, Length21)
get_contour_xld (Rectangle, Row3, Col1)
gen_cross_contour_xld (Cross1, Row3, Col1, 60, Phi1)
 
 
***方法四**角点法***这里感谢管理员TreWan提供***@TreWan
 Size:=60
 Angle:=0
points_foerstner (ImageResult, 1, 2, 3, 200, 0.3, 'gauss', 'true', RowJunctions, ColJunctions, \
                  CoRRJunctions, CoRCJunctions, CoCCJunctions, RowArea, ColArea, CoRRArea, CoRCArea, CoCCArea)
gen_cross_contour_xld (CrossFoerstner, RowJunctions, ColJunctions, Size, Angle)
dev_display (ImageResult)
dev_display (CrossFoerstner)
 
stop ()
*
***方法五 Harris interest points detector
points_harris (ImageResult, 0.7, 2, 0.04, 0, RowHarris, ColHarris)
gen_cross_contour_xld (CrossHarris, RowHarris, ColHarris, Size, Angle)
dev_display (ImageResult)
dev_display (CrossHarris)
 
*
***方法六 Harris binomial interest points detector
points_harris_binomial (ImageResult, 5, 15, 0.04, 1000, 'on', RowHarrisBinomial, ColHarrisBinomial)
gen_cross_contour_xld (CrossHarrisBinom, RowHarrisBinomial, ColHarrisBinomial, Size, Angle)
dev_display (ImageResult)
dev_display (CrossHarrisBinom)
 
stop ()
*
***方法七 Sojka interest points detector
points_sojka (ImageResult, 9, 2.5, 0.75, 30, 90, 0.5, 'true', RowSojka, ColSojka)
gen_cross_contour_xld (CrossSojka, RowSojka, ColSojka, Size, Angle)
dev_display (ImageResult)
dev_display (CrossSojka)
 
stop ()
*
***方法八 Lepetit interest points detector
points_lepetit (ImageResult, 3, 1, 20, 35, 'interpolation', RowLepetit, ColLepetit)
gen_cross_contour_xld (CrossLepetit, RowLepetit, ColLepetit, Size, Angle)
dev_display (ImageResult)
dev_display (CrossLepetit)


Halcon示例之求一个矩形四个角点坐标的八种方法

上一篇:项目开发总结报告


下一篇:跟我一起学 第3课