set_system ('border_shape_models', 'false')
read_image (Image, 'D:/图像文件/调试图片/调试图片/cam220230726182355309.bmp')
* draw_rectangle2 (3600, Row4, Column5, Phi3, Length12, Length22)
Rect1Row:=1010.37
Rect1Col:=1189.15
phi:=-0.188
RectLength1:=450.531
RectLength2:=499
* draw_rectangle2 (3600, Row, Column, Phi, Length1, Length2)
Row:=1010.37
Column:=1189
Phi:=-0.188
Length1:=450
Length2:=499
gen_cross_contour_xld (Cross, Rect1Row, Rect1Col, 60, 0.785398)
ratio := 90.045/1.5708
angle := ratio*phi
* HHH:=rad(-angle)
HHH:=rad(phi)
gen_rectangle2 (ModelRegion, Rect1Row, Rect1Col, rad(phi), RectLength1, RectLength2)
gen_rectangle2 (Rectangle,Row, Column, rad(Phi), Length1, Length2)
hom_mat2d_identity (HomMat2DIdentity)
hom_mat2d_rotate (HomMat2DIdentity,HHH,Rect1Row, Rect1Col, HomMat2DRotate)
affine_trans_region (Rectangle, RegionAffineTrans1, HomMat2DRotate, 'nearest_neighbor')
affine_trans_image (Image, ImageAffinTrans, HomMat2DRotate, 'constant', 'false')
area_center (RegionAffineTrans1, Area, Row6, Column7)
gen_contour_region_xld (RegionAffineTrans1, Contours1, 'border')
orientation_region (RegionAffineTrans1, Phi1)
Row1M:=Row6-Rect1Row
Column1M:=Rect1Col-Column7
gen_rectangle2 (ModelRegion1, Rect1Row, Rect1Col, 0, RectLength1, RectLength2)
reduce_domain (ImageAffinTrans, ModelRegion1, TemplateImage)
create_shape_model (TemplateImage, 7,0, 360, 'auto', ['point_reduction_high','no_pregeneration'], 'use_polarity', [33,49,7], 3, ModelId)
get_shape_model_contours (ModelContours, ModelId, 1)
hom_mat2d_identity (HomMat2DIdentity)
hom_mat2d_rotate (HomMat2DIdentity,rad(phi), Rect1Row, Rect1Col,HomMat2DRotate)
hom_mat2d_translate (HomMat2DRotate, Rect1Row, Rect1Col, HomMat2DTranslate)
affine_trans_contour_xld (ModelContours, ShapeModelTrans, HomMat2DTranslate)
read_image (Image1,'D:/图像文件/调试图片/调试图片/cam220230726182355309.bmp')
find_shape_model (Image1, ModelId, 0, 360, 0.7, 0, 0.5, 'least_squares', [7,1], 0.7, ModelRow, ModelColumn, ModelAngle, ModelScore)
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)
affine_trans_contour_xld (ModelContours, ShapeModelTrans, HomMat2DRotate)
endfor
affine_trans_pixel (HomMat2DRotate,Row1M,Column1M, Rect1RowCheck, Rect1ColCheck)
create_metrology_model (MetrologyHandle)
add_metrology_object_rectangle2_measure (MetrologyHandle,Rect1RowCheck, Rect1ColCheck,rad(Phi1)+ModelAngle, Length1, Length2, 5, 2, 1, 2, [], [], Index2)
set_metrology_object_param (MetrologyHandle, 'all', 'num_measures',25)
apply_metrology_model (Image1, MetrologyHandle)
get_metrology_object_measures (Contours, MetrologyHandle, 'all', 'all', Row3, Column3)
dev_display (Contours)
get_metrology_object_result (MetrologyHandle, 'all', 'all', 'result_type', 'all_param', Parameter)
gen_rectangle2 (Rectangle1, Parameter[0], Parameter[1], Parameter[2], Parameter[3], Parameter[4])
get_metrology_object_result_contour (Contour, MetrologyHandle,'all', 'all', 1.5)
clear_shape_model (ModelId)