抓圆工具-记录

* Matching 01: BEGIN of generated code for model initialization
set_system ('border_shape_models', 'false')
* Matching 01: Obtain the model image
*read_image (Image, 'E:/下载/3倍镜PCB/1-10.bmp')
* Matching 01: build the ROI from basic regions
*gen_circle (ModelRegion, 974.458,1579.111, 230.85)
Row1M:=974.458
Column1M:=1569.333
CircleInitRadius:=294.552
* Matching 01: reduce the model template
*reduce_domain (Image, ModelRegion, TemplateImage)
* Matching 01: create the shape model
*create_shape_model (TemplateImage, 7, rad(0), rad(360), rad(0.4972), ['point_reduction_high','no_pregeneration'], 'use_polarity', [45,60,4], 3, ModelId)
* Matching 01: get the model contour for transforming it later into the image
read_shape_model ('E://demo//MachineVisionSoftWare//MachineVisionSoftWare//bin//x86//Debug//shmFiles//CreateShapeModel20230310211013.shm', ModelID)
get_shape_model_contours (ModelContours, ModelID, 1)
* Matching 01: END of generated code for model initialization
* Matching 01: BEGIN of generated code for model application
* Matching 01: the following operations are usually moved into
* Matching 01: that loop where the aquired images are processed
* Matching 01: Find the model
read_image (Image1, 'E:/下载/3倍镜PCB/1-20.bmp')
find_shape_model (Image1, ModelID,0, 360, 0.3, 0, 0.5, 'least_squares', [7,1], 0.75, ModelRow, ModelColumn, ModelAngle, ModelScore)
* Matching 01: transform the model contours into the detected positions
*for MatchingObjIdx := 0 to |ModelScore| - 1 by 1
*    hom_mat2d_identity (HomMat)
*    hom_mat2d_rotate (HomMat, ModelAngle[MatchingObjIdx], 0, 0, HomMat)
*    hom_mat2d_translate (HomMat, ModelRow[MatchingObjIdx], ModelColumn[MatchingObjIdx], HomMat)
*    affine_trans_contour_xld (ModelContours, TransContours, HomMat)
*    dev_display (TransContours)
*endfor
for MatchingObjIdx := 0 to |ModelScore| - 1 by 1
    hom_mat2d_identity (HomMat)
    hom_mat2d_translate (HomMat, ModelRow[MatchingObjIdx], ModelColumn[MatchingObjIdx], HomMat2DTranslate)
    hom_mat2d_rotate (HomMat2DTranslate, ModelAngle[MatchingObjIdx],  ModelRow[MatchingObjIdx], ModelColumn[MatchingObjIdx], HomMat2DRotate)
    vector_angle_to_rigid (ModelRow, ModelColumn, ModelAngle, ModelRow, ModelColumn, ModelAngle, HomMat2D)
    affine_trans_contour_xld (ModelContours, ShapeModelTrans, HomMat2DRotate)
endfor

affine_trans_pixel (HomMat2D,Row1M,Column1M, Rect1RowCheck, Rect1ColCheck)
create_metrology_model (MetrologyHandle)
*创建测量句柄
*create_metrology_model (MetrologyHandle)
*将圆形或圆弧型的测量对象(ROI)添加到测量模型
add_metrology_object_circle_measure (MetrologyHandle, Rect1RowCheck,Rect1ColCheck,  CircleInitRadius, 10, 5, 1, 0,[], [], Index1)
*add_metrology_object_circle_measure (MetrologyHandle,Rect1RowCheck, Rect1ColCheck, \
                             CircleInitRadius, 10, 5,1, 0, 'num_measures', 30, Index)
*set_metrology_object_param (MetrologyHandle, 'all', 'num_measures',35)

set_metrology_object_param (MetrologyHandle, 'all', 'measure_transition', 'negative')
apply_metrology_model (Image1, MetrologyHandle)
*获取测量模型的测量结果
get_metrology_object_result (MetrologyHandle, Index1, 'all', 'result_type', 'all_param', Circle)
*获取测量对象的结果轮廓,测量模型拟合出来的圆
get_metrology_object_result_contour (Contours, MetrologyHandle, Index1, 'all', 1.5)

*获取测量模型中测量对象的测量区域和边缘点位置的坐标
get_metrology_object_measures (Contour, MetrologyHandle, 'all', 'all', Row1, Column1)

* Matching 01: Clear model when done
*clear_shape_model (ModelId)
* Matching 01: END of generated code for model application

你可能感兴趣的:(工作记录,工作记录)