dev_close_window () read_image (Image, 'gj2') rgb1_to_gray (Image, Image) get_image_size (Image, Width, Height) dev_open_window (0, 0, Width / 2, Height / 2, 'black', WindowHandle) set_display_font (WindowHandle, 14, 'mono', 'true', 'false') dev_display (Image) disp_continue_message (WindowHandle, 'black', 'true') binary_threshold (Image, Region, 'max_separability', 'dark', UsedThreshold) connection (Region, ConnectedRegions) select_shape (ConnectedRegions, SelectedRegions1, 'area', 'and', 237241, 282695) area_center (SelectedRegions1, Area, Row, Column) orientation_region (SelectedRegions1, Phi) vector_angle_to_rigid (Row, Column, Phi, Row, Column, 0, HomMat2D) affine_trans_region (SelectedRegions1, RegionAffineTrans, HomMat2D, 'nearest_neighbor') affine_trans_image (Image, ImageAffineTrans, HomMat2D, 'constant', 'false') **没有啥用就是做个抠图 reduce_domain (ImageAffineTrans, RegionAffineTrans, ImageReduced) dev_clear_window () stop() * dev_display (SelectedRegions1) **这里从矫正后图像开 edges_sub_pix (ImageAffineTrans, Edges, 'canny', 0.6, 20, 50) disp_cross (WindowHandle, Row, Column, 6, 0) **斜边是60,做三角,因为行方向在角度是正时要取减号(即行数减少方向) disp_arrow (WindowHandle, Row, Column, Row - 60 * sin(Phi), Column + 60 * cos(Phi), 2) select_shape_xld (Edges, SelectedXLD1, ['width','height'], 'and', [686.6,324.16], [850.88,369.62]) segment_contours_xld (SelectedXLD1, ContoursSplit, 'lines_circles', 5, 4, 2) **拟合并绘制纵向直线 select_shape_xld (ContoursSplit, SelectedXLD, ['width','height'], 'and', [0,276.32], [27.91,345.69]) sort_contours_xld (SelectedXLD, SortedContours, 'character', 'true', 'row') fit_line_contour_xld (SortedContours, 'tukey', -1, 0, 5, 2, RowBegin, ColBegin, RowEnd, ColEnd, Nr, Nc, Dist) *采用拟合数据绘制线 gen_contour_polygon_xld (ContH_L, [RowBegin[0],RowEnd[0]] , [ColBegin[0],ColEnd[0]]) gen_contour_polygon_xld (ContH_R, [RowBegin[1],RowEnd[1]] , [ColBegin[1],ColEnd[1]]) **拟合并绘制横向直线 select_shape_xld (ContoursSplit, SelectedXLD2, ['width','height'], 'and', [702.55,0], [811,39.47]) sort_contours_xld (SelectedXLD2, SortedContours1, 'character', 'true', 'row') fit_line_contour_xld(SortedContours1, 'tukey', -1, 0, 5, 2, RowBegin1, ColBegin1, RowEnd1, ColEnd1, Nr1, Nc1, Dist1) *采用拟合数据绘制线 gen_contour_polygon_xld (ContW_T, [RowBegin1[0],RowEnd1[0]] , [ColBegin1[0],ColEnd1[0]]) gen_contour_polygon_xld (ContW_B, [RowBegin1[1],RowEnd1[1]] , [ColBegin1[1],ColEnd1[1]]) **测量水平距离 distance_pl (RowBegin[0], ColBegin[0], RowBegin[1], ColBegin[1], RowEnd[1], ColEnd[1], Distance) disp_message (200000, '两竖直边之间的距离 ' +Distance, 'window',300, 10, 'blue', 'false') **车辆垂直距离 distance_pl (RowBegin1[0], ColBegin1[0], RowEnd1[1], ColEnd1[1],RowBegin1[1], ColBegin1[1], Distance1) disp_message (200000, '两水平边之间的距离 ' +Distance1, 'window',340, 10, 'blue', 'false') **拟合圆 edges_sub_pix (ImageAffineTrans, Edges1, 'canny', 1, 20, 30) select_shape_xld (Edges1, SelectedXLD3, ['height','circularity'], 'and', [9.97,0.11404], [92.11,0.3756]) **直接使用下面的就不需要做联合了 **select_shape_xld (Edges, SelectedXLD3, ['width','circularity'], 'and', [74.16,0.74402], [142.74,0.98006]) union_cocircular_contours_xld (SelectedXLD3, UnionContours, 1.6, 0.9, 0.9, 30, 40, 40, 'true', 2) fit_circle_contour_xld (UnionContours, 'algebraic', -1, 0, 0, 3, 2, Row1, Column1, Radius, StartPhi, EndPhi, PointOrder) gen_circle_contour_xld (ContCircle, Row1, Column1, Radius, 0, 6.28318, 'positive', 1) distance_pl(Row1, Column1, RowBegin[0], ColBegin[0], RowEnd[0], ColEnd[0], DistanceR_left) disp_message (200000, '圆心到左边直线的距离 ' +DistanceR_left+'半径'+Radius, 'window',400, 10, 'blue', 'false') distance_pp(Row1, Column1, RowEnd1[0], ColEnd1[0],DistanceR_upendpoint) angle_ll(RowBegin[1],ColBegin[1],RowEnd[1],ColEnd[1],RowBegin1[0],ColBegin1[0],RowEnd1[0],ColEnd1[0],m_angle) disp_message (200000, '圆心到上边直线末尾点(左边点)的距离 ' +DistanceR_upendpoint+'半径'+Radius, 'window',440, 10, 'blue', 'false')
直线与圆的拟合测量
转载本文章为转载内容,我们尊重原作者对文章享有的著作权。如有内容错误或侵权问题,欢迎原作者联系我们进行内容更正或删除文章。
上一篇:模板匹配加测量Demo
下一篇:动态创建报表XRChart
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
有趣的CSS - 弹跳的圆
用css写一个好玩的不停弹跳变形的圆。
css 弹跳的圆 动效 动画 交互 -
有趣的CSS - 加载的圆
由4个圆组成的一个小清新的动态加载动画效果。
css 加载动画 loading 圆点加载 ux -
[Halcon&拟合] 直线、矩形和圆的边缘提取
一、测量矩形拟合提取直线边缘1、封装的函数介绍:将整个算法进行封装,得到函数MS_LineDetecter。MS_LineDetecter MS_L
图像处理 边缘提取 直线、矩形和圆 拟合 Image -
OpenCV求最小外接圆、最小外接矩形、椭圆拟合、直线拟合
import cv2import numpy as npif __name__ == "__main__": orig = cv2.imread('
OpenCV 最小外接圆 最小外接矩形 椭圆拟合 直线拟合