并行计算-Halcon12.0-win32:
模板匹配模型:
- * 创建形变模型
- create_shape_model (Obj, 'auto', rad(-20), rad(20), 'auto', \
- 'auto', 'use_polarity', 30, 10, ModelID)
- get_shape_model_contours (ModelXLD, ModelID, 1)
- * 显示 创建形变模型
- * area_center (Obj, Area, Row, Column)
- * hom_mat2d_identity (HomMat2DIdentity)
- * hom_mat2d_translate (HomMat2DIdentity, Row, Column, HomMat2DTranslate)
- * affine_trans_contour_xld (ModelXLD,ContoursAffinTrans, HomMat2DTranslate)
- * dev_set_line_width (2)
- * dev_set_color ('yellow')
- * dev_display (Obj)
- * dev_display (ContoursAffinTrans)
- * 在原图上查找匹配模板
- * count_seconds (S1)
- find_shape_model (Image, ModelID, rad(-20), rad(20), \
- 0.7, 0, 0.0, ['least_squares','max_deformation 16'], \
- 0, 0.6, Row, Column, Angle, Score)
- * count_seconds (S2)
- * Runtime := (S2 - S1) * 1000
- * Clear the model
- clear_shape_model (ModelID)
- return ()
复制代码
Mask创建过程,我采用MATLAB:- clc,clear,close all
- im = imread('43.bmp');
- imshow(im)
- im1 = im( 917:930, 1351:1366 );
- imshow(im1)
- k=1;
- for i=1:size(im1,1)
- for j=1:size(im1,2)
- row(1,k) = i-1;
- col(1,k) = j-1;
- gray(1,k) = im1(i,j);
- k=k+1;
- end
- end
- row_sequence = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13]
- col_sequence = [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15]
- gray_sequence = [243,198,201,215,222,224,238,231,247,248,255,255,255,255,255,255,246,196,205,219,217,207,206,210,209,211,211,220,216,225,233,251,248,202,222,221,205,193,211,227,239,229,230,221,210,203,203,221,239,205,212,182,123,109,142,214,251,254,255,255,239,235,214,206,235,204,196,126,71,63,90,173,247,255,255,255,251,248,219,207,235,206,203,122,64,60,81,159,235,255,255,255,255,253,217,212,220,211,222,164,94,80,110,192,246,255,255,253,255,250,212,217,216,211,246,213,175,164,187,225,253,253,241,226,219,218,203,222,203,218,255,248,243,241,252,249,249,232,185,145,129,149,170,215,202,226,255,255,255,255,255,255,235,180,107,73,68,100,155,211,203,232,255,255,255,255,255,245,209,125,67,54,58,93,152,227,204,196,201,216,216,223,233,224,184,112,68,56,69,98,163,232,240,218,202,192,191,193,189,188,163,122,100,93,95,126,177,249,255,255,255,255,247,237,227,213,193,177,166,170,158,167,209,255]
复制代码
|