2013-03-27 23:20:08 +01:00
|
|
|
|
// JCL_DEBUG_EXPERT_GENERATEJDBG OFF
|
|
|
|
|
// JCL_DEBUG_EXPERT_INSERTJDBG OFF
|
|
|
|
|
// JCL_DEBUG_EXPERT_DELETEMAPFILE OFF
|
2013-04-02 00:17:25 +02:00
|
|
|
|
program cvErode_cvDilate;
|
2012-10-26 23:31:45 +02:00
|
|
|
|
|
|
|
|
|
{$APPTYPE CONSOLE}
|
|
|
|
|
{$R *.res}
|
|
|
|
|
|
|
|
|
|
uses
|
|
|
|
|
System.SysUtils,
|
2013-04-18 08:34:16 +02:00
|
|
|
|
uLibName in '..\..\..\include\uLibName.pas',
|
|
|
|
|
highgui_c in '..\..\..\include\highgui\highgui_c.pas',
|
|
|
|
|
core_c in '..\..\..\include\core\core_c.pas',
|
|
|
|
|
Core.types_c in '..\..\..\include\core\Core.types_c.pas',
|
|
|
|
|
imgproc.types_c in '..\..\..\include\imgproc\imgproc.types_c.pas',
|
|
|
|
|
imgproc_c in '..\..\..\include\imgproc\imgproc_c.pas',
|
|
|
|
|
legacy in '..\..\..\include\legacy\legacy.pas',
|
|
|
|
|
calib3d in '..\..\..\include\calib3d\calib3d.pas',
|
|
|
|
|
imgproc in '..\..\..\include\imgproc\imgproc.pas',
|
|
|
|
|
haar in '..\..\..\include\objdetect\haar.pas',
|
|
|
|
|
objdetect in '..\..\..\include\objdetect\objdetect.pas',
|
|
|
|
|
tracking in '..\..\..\include\video\tracking.pas',
|
2013-05-21 01:35:54 +02:00
|
|
|
|
Core in '..\..\..\include\core\core.pas',
|
|
|
|
|
Mat in '..\..\..\include\core\Mat.pas';
|
2012-10-26 23:31:45 +02:00
|
|
|
|
|
|
|
|
|
Const
|
|
|
|
|
// <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2013-03-27 23:20:08 +01:00
|
|
|
|
filename = 'Resource\opencv_logo_with_text.png';
|
2012-10-26 23:31:45 +02:00
|
|
|
|
|
|
|
|
|
Var
|
|
|
|
|
image: PIplImage = Nil;
|
|
|
|
|
dst: PIplImage = Nil;
|
|
|
|
|
|
|
|
|
|
erode: PIplImage = Nil;
|
|
|
|
|
dilate: PIplImage = Nil;
|
|
|
|
|
|
|
|
|
|
radius: Integer = 1;
|
|
|
|
|
radius_max: Integer = 10;
|
|
|
|
|
iterations: Integer = 1;
|
|
|
|
|
iterations_max: Integer = 10;
|
|
|
|
|
Kern: pIplConvKernel;
|
|
|
|
|
c: Integer;
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>-<2D><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> -
|
2013-04-18 08:34:16 +02:00
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD>c <20><><EFBFBD><EFBFBD>
|
2012-10-26 23:31:45 +02:00
|
|
|
|
procedure myTrackbarRadius(pos: Integer); cdecl;
|
|
|
|
|
begin
|
|
|
|
|
radius := pos;
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>-<2D><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> -
|
2013-04-18 08:34:16 +02:00
|
|
|
|
// <20><>c<EFBFBD><63> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2012-10-26 23:31:45 +02:00
|
|
|
|
procedure myTrackbarIterations(pos: Integer); cdecl;
|
|
|
|
|
begin
|
|
|
|
|
iterations := pos;
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
begin
|
|
|
|
|
try
|
|
|
|
|
image := cvLoadImage(filename, 1);
|
|
|
|
|
Writeln('[i] image: ', filename);
|
|
|
|
|
if not Assigned(image) then
|
|
|
|
|
Halt;
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
dst := cvCloneImage(image);
|
|
|
|
|
erode := cvCloneImage(image);
|
|
|
|
|
dilate := cvCloneImage(image);
|
|
|
|
|
// <20><><EFBFBD><EFBFBD> <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
cvNamedWindow('original', CV_WINDOW_AUTOSIZE);
|
|
|
|
|
cvNamedWindow('erode', CV_WINDOW_AUTOSIZE);
|
|
|
|
|
cvNamedWindow('dilate', CV_WINDOW_AUTOSIZE);
|
|
|
|
|
|
|
|
|
|
cvCreateTrackbar('Radius', 'original', @radius, radius_max, myTrackbarRadius);
|
|
|
|
|
cvCreateTrackbar('Iterations', 'original', @iterations, iterations_max, myTrackbarIterations);
|
|
|
|
|
|
|
|
|
|
while True do
|
|
|
|
|
begin
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
cvShowImage('original', image);
|
2013-04-18 08:34:16 +02:00
|
|
|
|
// c<><63><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
|
2013-04-05 13:36:47 +02:00
|
|
|
|
Kern := cvCreateStructuringElementEx(radius * 2 + 1, radius * 2 + 1, radius, radius, CV_SHAPE_ELLIPSE);
|
2012-10-26 23:31:45 +02:00
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
cvErode(image, erode, Kern, iterations);
|
|
|
|
|
cvDilate(image, dilate, Kern, iterations);
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
cvShowImage('erode', erode);
|
|
|
|
|
cvShowImage('dilate', dilate);
|
|
|
|
|
cvReleaseStructuringElement(Kern);
|
|
|
|
|
c := cvWaitKey(33);
|
|
|
|
|
if (c = 27) then
|
|
|
|
|
Break;
|
|
|
|
|
end;
|
2013-04-18 08:34:16 +02:00
|
|
|
|
// <20>c<EFBFBD><63><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><>c<EFBFBD><63>c<EFBFBD>
|
2012-10-26 23:31:45 +02:00
|
|
|
|
cvReleaseImage(image);
|
|
|
|
|
cvReleaseImage(dst);
|
|
|
|
|
cvReleaseImage(erode);
|
|
|
|
|
cvReleaseImage(dilate);
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
|
|
|
|
|
cvDestroyWindow('original');
|
|
|
|
|
cvDestroyWindow('erode');
|
|
|
|
|
cvDestroyWindow('dilate');
|
|
|
|
|
except
|
|
|
|
|
on E: Exception do
|
|
|
|
|
Writeln(E.ClassName, ': ', E.Message);
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
end.
|