📄 contours4.dpr
字号:
program Contours4;
uses
Forms,
IPL in '..\Ipl.pas',
OpenCV in '..\OpenCV.pas',
highGui in '..\highGui.pas';
{$R *.res}
const w = 500 ;
var imgA,imgB: pIplImage;
storage : pCvMemStorage;
contours : pCvSeq;
contour_num : integer;
i1,i2,i,j : integer;
point : pInteger;
begin
imgA := cvLoadImage( 'image_sample12.bmp', -1);
imgB := cvCreateImage( cvSize_(imgA.width, imgA.Height), IPL_DEPTH_8U, 3);
//--- Smooth
// cvSmooth( imgA, imgB, CV_GAUSSIAN, 7, 0, 0);
//-- Contours
cvCvtColor( imgA, imgB, CV_GRAY2BGR);
storage := cvCreateMemStorage( 0);
contours :=nil;
contour_num := cvFindContours( imgA, storage, @contours, sizeof(CvContour), CV_RETR_LIST,
CV_CHAIN_APPROX_NONE, cvPoint_(0,0));
i :=0 ;
while (i<contour_num) do
begin
for j:=0 to contours.total-1 do
begin
point := pInteger(cvGetSeqElem( contours, j));
i1 := point^; inc(point); i2 := point^;
cvSet2D( imgB,i1,i2, CV_RGB( 255,0,0));
end;
inc(i,contours.total);
contours := contours.h_next;
end;
cvDrawContours( imgB, contours, CV_RGB( 255, 0, 0), CV_RGB( 255, 0, 0), 1, 1, 8,cvPoint_(0,0));
cvNamedWindow( 'image', 1 );
cvShowImage( 'image', imgB );
cvWaitKey(0);
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -