unit filterContour;
(* ***** BEGIN LICENSE BLOCK *****
* Copyright (C) 2004 Durand Emmanuel
* Copyright (C) 2004 Burgel Eric
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Contact :
* filters@edurand.com
* filters@burgel.com
*
* ***** END LICENSE BLOCK ***** *)
{
edurand (filters@edurand.com)
}
{
use 'OpenCv' Suzuki algorithms implementation
}
interface
uses
filter, fparameters, image;
type
TFilterContour = class(TFilter)
public
constructor Create; override;
procedure Run(); override;
private
parameterImageIn, parameterImageOut : TParameterImage;
parameterThreshold : TParameterInteger;
parameterFill : TParameterBoolean;
parameterCriticalPoints : TParameterBoolean;
parameterApproximationAccuracy : TParameterInteger;
end;
implementation
uses
imageIO, wrapper_opencv, SysUtils;
constructor TFilterContour.Create;
begin
inherited;
parameterImageIn:=addParameterImage('inImage', 'input image');
parameterImageOut:=addParameterImage('outImage', 'result image');
parameterThreshold:=addParameterInteger('threshold','threshold1',0,255,100);
parameterFill:=addParameterBoolean('fill','fill contours',True);
parameterCriticalPoints:=addParameterBoolean('criticalPoints','show critical points of the contours',True);
parameterApproximationAccuracy:=addParameterInteger('approximationAccuracy','approximationAccuracy',0,10,1);
end;
procedure TFilterContour.Run();
var
fill, criticalPoints : Integer;
begin
if (parameterImageIn.Image<>nil) and (parameterImageOut.Image<>nil) then begin
fill:=1;
if parameterFill.Value=False then fill:=0;
criticalPoints:=1;
if parameterCriticalPoints.Value=False then criticalPoints:=0;
wrapper_opencv.filterCvContours(
parameterImageIn.Image,parameterImageOut.Image,
parameterThreshold.Value,fill,
criticalPoints,parameterApproximationAccuracy.Value
);
end;
end;
end.