Halcon得出三角形内切圆
news2023/5/27 7:14:
目录
- 一、得出三角形的三个角点
- 二、用类似尺规作图法得出三角形圆心
-
- 1、以三角形三角点画出圆形轮廓
- 2、求出三角形轮廓与圆形轮廓之间的交点
- 3、获得角平分线,三边角平分线交点为圆心
- 三、求出圆心到边最短距离即半径
一、得出三角形的三个角点
参考上篇文章“Halcon提取三角形边缘以及获取角点”
二、用类似尺规作图法得出三角形圆心
以三角形三个边为圆心生成三个圆形轮廓
求出轮廓与轮廓之间的交点
再以交点为圆心画圆轮廓,得到两个圆的交点,获得角平分线,三边角平分线交点为圆心
1、以三角形三角点画出圆形轮廓
gen_circle_contour_xld (ContCircle1, RowA, ColumnA, 20, 0, 6.28318, 'positive', 1)
gen_circle_contour_xld (ContCircle2, RowB, ColumnB, 20, 0, 6.28318, 'positive', 1)
gen_circle_contour_xld (ContCircle3, RowC, ColumnC, 20, 0, 6.28318, 'positive', 1)
2、求出三角形轮廓与圆形轮廓之间的交点
intersection_contours_xld (Contour, ContCircle3, 'all', Row, Column, IsOverlapping1)
intersection_contours_xld (Contour, ContCircle1, 'all', Row2, Column2, IsOverlapping3)
intersection_contours_xld (Contour, ContCircle2, 'all', Row4, Column4, IsOverlapping5)
3、获得角平分线,三边角平分线交点为圆心
//以交点为圆心画出两个同半径圆,两圆交点连线即为角平分线
gen_circle_contour_xld (ContCircle31, Row[0], Column[0], 40, 0, 6.28318, 'positive', 1)
gen_circle_contour_xld (ContCircle32, Row[1], Column[1], 40, 0, 6.28318, 'positive', 1)
intersection_contours_xld (ContCircle31, ContCircle32, 'all', Row1, Column1, IsOverlapping2)
disp_line (3600, Row1[0], Column1[0], Row1[1], Column1[1])gen_circle_contour_xld (ContCircle21, Row2[0], Column2[0], 40, 0, 6.28318, 'positive', 1)
gen_circle_contour_xld (ContCircle22, Row2[1], Column2[1], 40, 0, 6.28318, 'positive', 1)
intersection_contours_xld (ContCircle21, ContCircle22, 'all', Row3, Column3, IsOverlapping4)
disp_line (3600, Row3[0], Column3[0], Row3[1], Column3[1])gen_circle_contour_xld (ContCircle11, Row4[0], Column4[0], 40, 0, 6.28318, 'positive', 1)
gen_circle_contour_xld (ContCircle12, Row4[1], Column4[1], 40, 0, 6.28318, 'positive', 1)
intersection_contours_xld (ContCircle11, ContCircle12, 'all', Row5, Column5, IsOverlapping6)
disp_line (3600, Row5[0], Column5[0], Row5[1], Column5[1])
延长直线,求交点
r:= Row1[0] - Row1[1]
n:= Column1[0] - Column1[1]
k1:= r/n
b1:=Row1[1] - k1*Column1[1]
row1:=k1*5+b1
row12:=k1*2500+b1
disp_line (3600, row1, 5, row12, 2500)
r:= Row3[0] - Row3[1]
n:= Column3[0] - Column3[1]
k1:= r/n
b1:=Row3[1] - k1*Column3[1]
row2:=k1*5+b1
row22:=k1*2500+b1
* disp_line (3600, RowBegin, ColBegin, RowEnd, ColEnd)
disp_line (3600, row2,5 , row22, 2500)
r:= Row5[0] - Row5[1]
n:= Column5[0]- Column5[1]
k1:= r/n
b1:=Row5[1] - k1*Column5[1]
row3:=k1*5+b1
row32:=k1*2500+b1
disp_line (3600, row3,5 , row32, 2500)//求出圆心 Row6, Column6
intersection_lines (row2, 5, row22, 2500, row3,5 , row32, 2500, Row6, Column6, IsOverlapping7)
三、求出圆心到边最短距离即半径
distance_pc(Contour, Row6, Column6, DistanceMin, DistanceMax)
gen_circle_contour_xld (ContCircle, Row6, Column6, DistanceMin, 0, 6.28318, 'positive', 1)