Halcon实现卡尺找圆
最近在学习halcon算子,在此纪录一下学习内容,卡尺找圆的实现。
运行结果图
粗略注释
dev_close_window ()
dev_open_window (0, 0, 512, 512, 'black', WindowHandle)
*读取图像
read_image (Image, 'D:/Image/1.png')
*显示图像
dev_display (Image)
*图像灰度转换
rgb1_to_gray (Image, GrayImage)
*绘制圆形
draw_circle (WindowHandle, Row, Column, Radius)
*创建计量模型
create_metrology_model (MetrologyHandle)
*添加圆形计量模型
add_metrology_object_circle_measure (MetrologyHandle, Row, Column, Radius, 20, 5, 1, 30, [], [], Index)
*获取计量对象模型轮廓
get_metrology_object_model_contour (Contour1, MetrologyHandle, Index, 1.5)
*获取计量模型测量结果
get_metrology_object_measures (Contours, MetrologyHandle, 'all', 'all', Row1, Column1)
*应用计量模型到图像
apply_metrology_model (GrayImage, MetrologyHandle)
*获取计量模型结果对象
get_metrology_object_result (MetrologyHandle, Index, 'all', 'result_type', 'all_param', Parameter)
*获取计量模型对象结果轮廓
get_metrology_object_result_contour (Contour, MetrologyHandle, Index, 'all', 1.5)
*显示轮廓
dev_set_color ('green')
dev_display (Contour)
查看官方帮助文档注释
dev_close_window ()
dev_open_window (0, 0, 512, 512, 'black', WindowHandle)
read_image (Image, 'D:/Image/1.png')
dev_display (Image)
**灰度转换
rgb1_to_gray (Image, GrayImage)
draw_circle (WindowHandle, Row, Column, Radius)
**Create the data structure that is needed to measure geometric shapes.
**创建计量模型:创建测量几何形状所需的数据结构,
create_metrology_model (MetrologyHandle)
** Add a circle or a circular arc to a metrology model.
****添加圆测量计量对象:添加一个圆或圆弧到计量模型,输出Index
**MetrologyHandle:计量模型句柄
*Row :所在行
*Column :所在列
*Radius :半径
*MesureLength1 :测量长度1
*MesureLength2 :测量长度2
*MesureSigma :测量平滑系数
*MesureThreshold :测量阈值
*GenparamName :参数名
*GenparamValue :参数值
*Index :索引
add_metrology_object_circle_measure (MetrologyHandle, Row, Column, Radius, 20, 5, 1, 30, [], [], Index)
****Query the model contour of a metrology object in image coordinates.
****获取计量对象模型轮廓: 在图像坐标系中查询计量对象的模型轮廓
**Contour :输出轮廓
**MetrologyHandle:计量模型句柄
**Index : 计量对象索引(Index of the metrology object.)
**Resolution:相邻轮廓点之间的距离(Distance between neighboring contour points.)。
get_metrology_object_model_contour (Contour1, MetrologyHandle, Index, 1.5)
**Get the measure regions and the results of the edge location for the metrology objects of a metrology model.
**获取一个计量模型中,计量对象的测量区域和边缘位置定位结果
**Contours :测量区域的矩形xld轮廓(Rectangular XLD Contours of measure regions.)
**MetrologyHandle :计量对象句柄
**Index :计量对象索引
**Transition :极性选择: 任意极性/由暗到明(0->255)/由明到暗(255->0)(Select light/dark or dark/light edges.)
**Row1:所在行
**Column1:所在列
get_metrology_object_measures (Contours, MetrologyHandle, 'all', 'all', Row1, Column1)
**Measure and fit the geometric shapes of all metrology objects of a metrology model.
**应用计量模型:测量和拟合一个计量模型中所有计量对象的几何形状
**确定边缘位置
**拟合边缘位置几何形状
apply_metrology_model (GrayImage, MetrologyHandle)
****get the results of the measurement of a metrology model.
****获取计量对象结果:获取计量模型的测量结果
**MetrologyHandle:计量句柄
**Index:计量索引
**Instance:计量对象实例(Instance of the metrology object.)
**GenParamName:通用参数名
**GenParamValue:通用参数值
**Parameter:返回结果
get_metrology_object_result (MetrologyHandle, Index, 'all', 'result_type', 'all_param', Parameter)
* Query the result contour of a metrology object.
*获取计量对象结果轮廓:查询计量对象的结果轮廓
**Contour :获取的结果轮廓
**MetrologyHandle:计量句柄
**Instance:计量对象实例(Instance of the metrology object.)
**Resolution:相邻轮廓点之间的距离(Distance between neighboring contour points.)。
get_metrology_object_result_contour (Contour, MetrologyHandle, Index, 'all', 1.5)
dev_set_color ('green')
dev_display (Contour)