Merge pull request #74 from JanOosting/master

Squares demo: contour storage trashes Squares storage
This commit is contained in:
Laentir Valetov 2017-06-22 11:35:04 +04:00 committed by GitHub
commit 87d112e499

View File

@ -68,6 +68,8 @@ var
result_: PCvSeq; result_: PCvSeq;
rr: integer; rr: integer;
contourstorage: PCvMemStorage;
yy: pointer; yy: pointer;
a: AnsiString; a: AnsiString;
begin begin
@ -92,6 +94,8 @@ begin
// cvSetImageROI(timg, cvRect(0, 0, sz.width, sz.height)); // cvSetImageROI(timg, cvRect(0, 0, sz.width, sz.height));
cvResetImageROI(timg); cvResetImageROI(timg);
contourstorage := cvCreateMemStorage(0);
// down-scale and upscale the image to filter out the noise // down-scale and upscale the image to filter out the noise
cvPyrDown(timg, pyr, 7); cvPyrDown(timg, pyr, 7);
cvPyrUp(pyr, timg, 7); cvPyrUp(pyr, timg, 7);
@ -131,8 +135,8 @@ begin
// try // try
// find contours and store them all as a list // find contours and store them all as a list
cvClearMemStorage(storage); cvClearMemStorage(contourstorage);
rr := cvFindContours(gray, storage, @contours, sizeof(TCvContour), CV_RETR_LIST, CV_CHAIN_APPROX_SIMPLE, rr := cvFindContours(gray, contourstorage, @contours, sizeof(TCvContour), CV_RETR_LIST, CV_CHAIN_APPROX_SIMPLE,
CvPoint(0, 0)); CvPoint(0, 0));
// test each contour // test each contour
@ -186,7 +190,7 @@ begin
cvReleaseImage(pyr); cvReleaseImage(pyr);
cvReleaseImage(tgray); cvReleaseImage(tgray);
cvReleaseImage(timg); cvReleaseImage(timg);
cvReleaseMemStorage(contourstorage);
result := Squares; result := Squares;
end; end;