📄 snakes.dpr
字号:
program Snakes;
uses
Forms,sysutils,
IPL in '..\Ipl.pas',
OpenCV in '..\OpenCV.pas',
highGui in '..\highGui.pas';
{$R *.res}
const w = 500 ;
var imgA,imgB: pIplImage;
storage : pCvMemStorage;
contour : pCvPointArray;
Approx_contours : PcvSeq ;
contour_num : integer;
i1,i2,i,j,length ,f1: integer;
point : pInteger;
c_alpha :float= 0.45;
c_beta :float= 0.10;
c_gamma :float= 0.45;
contours : PCvSeqArr;
begin
imgA := cvLoadImage( 'image_sample21.bmp', -1);
imgB := cvCreateImage( cvSize_(imgA.width, imgA.Height), IPL_DEPTH_8U, 3);
//--- Smooth
// cvSmooth( imgA, imgB, CV_GAUSSIAN, 7, 0, 0);
length := 200 ;
contour := GetMemory(sizeof(CvPoint) * length*2) ;
for i:=0 to length-1 do
begin
contour^[i].x := round(100*cos(2*PI*i/length)+100);
contour^[i].y := round(100*sin(2*PI*i/length)+100);
end;
f1 := 0;
while f1<10 do
begin
cvSnakeImage( imgA, @contour^[0], length, @c_alpha, @c_beta, @c_gamma, CV_VALUE,
cvSize_( 21, 21), cvTermCriteria_( CV_TERMCRIT_ITER, 1, 0.0), 1);
cvCvtColor( imgA, imgB, CV_GRAY2RGB);
for i:=0 to length-2 do cvLine( imgB, contour^[i], contour^[i+1], CV_RGB( 255, 0, 0), 2, 8, 0);
cvLine( imgB, contour^[length-1], contour^[0], CV_RGB( 255, 0, 0), 2, 8, 0);
cvNamedWindow( 'image', 1 );
cvShowImage( 'image', imgB );
cvWaitKey(0);
inc(f1,1);
end;
cvReleaseImage(imgA);
cvReleaseImage(imgB);
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -