2013-03-27 23:20:08 +01:00
|
|
|
|
// JCL_DEBUG_EXPERT_GENERATEJDBG OFF
|
|
|
|
|
// JCL_DEBUG_EXPERT_INSERTJDBG OFF
|
|
|
|
|
// JCL_DEBUG_EXPERT_DELETEMAPFILE OFF
|
|
|
|
|
program cv_HoughCircles;
|
2013-01-07 15:02:10 +01:00
|
|
|
|
|
|
|
|
|
{$APPTYPE CONSOLE}
|
|
|
|
|
{$R *.res}
|
|
|
|
|
|
|
|
|
|
uses
|
|
|
|
|
System.SysUtils,
|
2013-04-05 13:36:47 +02:00
|
|
|
|
{$I ..\..\uses_include.inc}
|
|
|
|
|
;
|
2013-01-07 15:02:10 +01:00
|
|
|
|
|
|
|
|
|
const
|
2013-03-27 23:20:08 +01:00
|
|
|
|
filename = 'Resource\opencv_logo_with_text_sm.png';
|
2013-01-07 15:02:10 +01:00
|
|
|
|
|
|
|
|
|
Type
|
|
|
|
|
TFloatArray = array [0 .. 10] of Single;
|
|
|
|
|
pFloatArray = ^TFloatArray;
|
|
|
|
|
|
|
|
|
|
Var
|
|
|
|
|
image: pIplImage = nil;
|
|
|
|
|
src: pIplImage = nil;
|
|
|
|
|
storage: pCvMemStorage;
|
|
|
|
|
results: pCvSeq;
|
|
|
|
|
i: Integer;
|
|
|
|
|
p: pFloatArray;
|
2013-04-05 13:36:47 +02:00
|
|
|
|
pt: TCvPoint;
|
2013-01-07 15:02:10 +01:00
|
|
|
|
|
|
|
|
|
begin
|
2013-04-05 13:36:47 +02:00
|
|
|
|
try
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> (<28> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>)
|
|
|
|
|
image := cvLoadImage(filename, CV_LOAD_IMAGE_GRAYSCALE);
|
|
|
|
|
WriteLn(Format('[i] image: %s', [filename]));
|
2013-01-07 15:02:10 +01:00
|
|
|
|
|
2013-04-05 13:36:47 +02:00
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
src := cvLoadImage(filename);
|
2013-01-07 15:02:10 +01:00
|
|
|
|
|
2013-04-05 13:36:47 +02:00
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
storage := cvCreateMemStorage(0);
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
cvSmooth(image, image, CV_GAUSSIAN, 5, 5);
|
2013-01-07 15:02:10 +01:00
|
|
|
|
|
2013-04-05 13:36:47 +02:00
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
results := cvHoughCircles(image, storage, CV_HOUGH_GRADIENT, 10, image^.width / 5);
|
2013-01-07 15:02:10 +01:00
|
|
|
|
|
2013-04-05 13:36:47 +02:00
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
for i := 0 to results^.total - 1 do
|
|
|
|
|
begin
|
|
|
|
|
p := pFloatArray(cvGetSeqElem(results, i));
|
|
|
|
|
pt := CvPoint(cvRound(p^[0]), cvRound(p^[1]));
|
|
|
|
|
cvCircle(src, pt, cvRound(p^[2]), CV_RGB(255, 0, 0));
|
|
|
|
|
end;
|
2013-01-07 15:02:10 +01:00
|
|
|
|
|
2013-04-05 13:36:47 +02:00
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
cvNamedWindow('cvHoughCircles', 1);
|
|
|
|
|
cvShowImage('cvHoughCircles', src);
|
2013-01-07 15:02:10 +01:00
|
|
|
|
|
2013-04-05 13:36:47 +02:00
|
|
|
|
// <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
cvWaitKey(0);
|
2013-01-07 15:02:10 +01:00
|
|
|
|
|
2013-04-05 13:36:47 +02:00
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
cvReleaseMemStorage(storage);
|
|
|
|
|
cvReleaseImage(image);
|
|
|
|
|
cvReleaseImage(src);
|
|
|
|
|
cvDestroyAllWindows();
|
|
|
|
|
except
|
|
|
|
|
on E: Exception do
|
|
|
|
|
WriteLn(E.ClassName, ': ', E.Message);
|
|
|
|
|
end;
|
2013-01-07 15:02:10 +01:00
|
|
|
|
|
|
|
|
|
end.
|