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-05-26 10:50:18 +02:00
|
|
|
|
highgui_c,
|
|
|
|
|
core_c,
|
|
|
|
|
Core.types_c,
|
|
|
|
|
imgproc_c,
|
2014-05-20 07:10:43 +02:00
|
|
|
|
imgproc.types_c,
|
|
|
|
|
uResourcePaths;
|
2012-10-26 23:31:45 +02:00
|
|
|
|
|
2013-05-21 10:53:30 +02:00
|
|
|
|
const
|
2012-10-26 23:31:45 +02:00
|
|
|
|
// <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2014-05-20 07:10:43 +02:00
|
|
|
|
filename = cResourceMedia + 'opencv_logo_with_text.png';
|
2012-10-26 23:31:45 +02:00
|
|
|
|
|
2013-05-21 10:53:30 +02:00
|
|
|
|
var
|
2012-10-26 23:31:45 +02:00
|
|
|
|
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.
|