features2d updated

Signed-off-by: Laentir Valetov <laex@bk.ru>
This commit is contained in:
Laentir Valetov 2015-01-24 15:20:48 +03:00
parent 74d9f34ded
commit d86e51c2f0
10 changed files with 708 additions and 84 deletions

Binary file not shown.

Binary file not shown.

View File

@ -46,8 +46,10 @@ begin
'Using the SURF desriptor:'#13#10#13#10'Usage:'#13#10#9'matcher_simple <image1> <image2>'); 'Using the SURF desriptor:'#13#10#13#10'Usage:'#13#10#9'matcher_simple <image1> <image2>');
end; end;
{$DEFINE USE_SURF } { .$DEFINE USE_SURF }
{.$DEFINE USE_SIFT} { .$DEFINE USE_SIFT }
{ .$DEFINE USE_ORB }
{$DEFINE USE_BRISK}
Var Var
{$IFDEF USE_SURF} {$IFDEF USE_SURF}
@ -57,14 +59,22 @@ Var
{$IFDEF USE_SIFT} {$IFDEF USE_SIFT}
detector: TSiftFeatureDetector; detector: TSiftFeatureDetector;
extractor: TSiftDescriptorExtractor; extractor: TSiftDescriptorExtractor;
{$ENDIF}
{$IFDEF USE_ORB}
detector: TORBFeatureDetector;
extractor: TORBDescriptorExtractor;
{$ENDIF}
{$IFDEF USE_BRISK}
detector: TBRISKFeatureDetector;
extractor: TBRISKDescriptorExtractor;
{$ENDIF} {$ENDIF}
img1, img2: TccvMat; img1, img2: TccvMat;
keypoints1, keypoints2: TCVectorKeyPoint; keypoints1, keypoints2: TCVectorKeyPoint;
descriptors1: TccvMat; descriptors1: TccvMat;
descriptors2: TccvMat; descriptors2: TccvMat;
matcher: TBFMatcher;
matches: TCVectorDMatch; matches: TCVectorDMatch;
img_matches: TccvMat; img_matches: TccvMat;
matcher: TBFMatcher;
begin begin
try try
@ -87,31 +97,31 @@ begin
end; end;
{$IFDEF USE_SURF} {$IFDEF USE_SURF}
// detecting keypoints
detector := TSurfFeatureDetector.Create(400); detector := TSurfFeatureDetector.Create(400);
keypoints1 := TCVectorKeyPoint.Create; extractor := TSurfFeatureDetector.Create;
keypoints2 := TCVectorKeyPoint.Create;
detector.detect(img1, keypoints1);
detector.detect(img2, keypoints2);
// computing descriptors
extractor := TSurfDescriptorExtractor.Create;
extractor.compute(img1, keypoints1, descriptors1);
extractor.compute(img2, keypoints2, descriptors2);
{$ENDIF} {$ENDIF}
{$IFDEF USE_SIFT} {$IFDEF USE_SIFT}
// detecting keypoints
detector := TSiftFeatureDetector.Create; detector := TSiftFeatureDetector.Create;
extractor := TSiftDescriptorExtractor.Create;
{$ENDIF}
{$IFDEF USE_ORB}
detector := TORBFeatureDetector.Create;
extractor := TORBDescriptorExtractor.Create;
{$ENDIF}
{$IFDEF USE_BRISK}
detector := TBRISKFeatureDetector.Create;
extractor := TBRISKDescriptorExtractor.Create;
{$ENDIF}
// detecting keypoints
keypoints1 := TCVectorKeyPoint.Create; keypoints1 := TCVectorKeyPoint.Create;
keypoints2 := TCVectorKeyPoint.Create; keypoints2 := TCVectorKeyPoint.Create;
detector.detect(img1, keypoints1); detector.detect(img1, keypoints1);
detector.detect(img2, keypoints2); detector.detect(img2, keypoints2);
// computing descriptors // computing descriptors
extractor := TSiftDescriptorExtractor.Create;
extractor.compute(img1, keypoints1, descriptors1); extractor.compute(img1, keypoints1, descriptors1);
extractor.compute(img2, keypoints2, descriptors2); extractor.compute(img2, keypoints2, descriptors2);
{$ENDIF}
// matching descriptors // matching descriptors
matcher := TBFMatcher.Create(NORM_L2); matcher := TBFMatcher.Create(NORM_L2);
matches := TCVectorDMatch.Create; matches := TCVectorDMatch.Create;

View File

@ -7,7 +7,7 @@
<TargetedPlatforms>3</TargetedPlatforms> <TargetedPlatforms>3</TargetedPlatforms>
<AppType>Package</AppType> <AppType>Package</AppType>
<FrameworkType>VCL</FrameworkType> <FrameworkType>VCL</FrameworkType>
<ProjectVersion>15.4</ProjectVersion> <ProjectVersion>16.1</ProjectVersion>
<Platform Condition="'$(Platform)'==''">Win32</Platform> <Platform Condition="'$(Platform)'==''">Win32</Platform>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Config)'=='Base' or '$(Base)'!=''"> <PropertyGroup Condition="'$(Config)'=='Base' or '$(Base)'!=''">
@ -157,7 +157,8 @@ $(PreBuildEvent)]]></PreBuildEvent>
<Import Project="$(BDS)\Bin\CodeGear.Delphi.Targets" Condition="Exists('$(BDS)\Bin\CodeGear.Delphi.Targets')"/> <Import Project="$(BDS)\Bin\CodeGear.Delphi.Targets" Condition="Exists('$(BDS)\Bin\CodeGear.Delphi.Targets')"/>
<Import Project="$(APPDATA)\Embarcadero\$(BDSAPPDATABASEDIR)\$(PRODUCTVERSION)\UserTools.proj" Condition="Exists('$(APPDATA)\Embarcadero\$(BDSAPPDATABASEDIR)\$(PRODUCTVERSION)\UserTools.proj')"/> <Import Project="$(APPDATA)\Embarcadero\$(BDSAPPDATABASEDIR)\$(PRODUCTVERSION)\UserTools.proj" Condition="Exists('$(APPDATA)\Embarcadero\$(BDSAPPDATABASEDIR)\$(PRODUCTVERSION)\UserTools.proj')"/>
<PropertyGroup Condition="'$(Config)'=='Release' And '$(Platform)'=='Android'"> <PropertyGroup Condition="'$(Config)'=='Release' And '$(Platform)'=='Android'">
<PreBuildEvent>brcc32 ..\..\..\resource\facedetectxml\haarcascade.rc -fo.\haarcascade.res</PreBuildEvent> <PreBuildEvent>brcc32 ..\..\..\resource\facedetectxml\haarcascade.rc -fo.\haarcascade.res
</PreBuildEvent>
<PreBuildEventIgnoreExitCode>False</PreBuildEventIgnoreExitCode> <PreBuildEventIgnoreExitCode>False</PreBuildEventIgnoreExitCode>
<PreLinkEvent/> <PreLinkEvent/>
<PreLinkEventIgnoreExitCode>False</PreLinkEventIgnoreExitCode> <PreLinkEventIgnoreExitCode>False</PreLinkEventIgnoreExitCode>
@ -165,7 +166,8 @@ $(PreBuildEvent)]]></PreBuildEvent>
<PostBuildEventIgnoreExitCode>False</PostBuildEventIgnoreExitCode> <PostBuildEventIgnoreExitCode>False</PostBuildEventIgnoreExitCode>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Config)'=='Release' And '$(Platform)'=='iOSDevice'"> <PropertyGroup Condition="'$(Config)'=='Release' And '$(Platform)'=='iOSDevice'">
<PreBuildEvent>brcc32 ..\..\..\resource\facedetectxml\haarcascade.rc -fo.\haarcascade.res</PreBuildEvent> <PreBuildEvent>brcc32 ..\..\..\resource\facedetectxml\haarcascade.rc -fo.\haarcascade.res
</PreBuildEvent>
<PreBuildEventIgnoreExitCode>False</PreBuildEventIgnoreExitCode> <PreBuildEventIgnoreExitCode>False</PreBuildEventIgnoreExitCode>
<PreLinkEvent/> <PreLinkEvent/>
<PreLinkEventIgnoreExitCode>False</PreLinkEventIgnoreExitCode> <PreLinkEventIgnoreExitCode>False</PreLinkEventIgnoreExitCode>
@ -173,7 +175,8 @@ $(PreBuildEvent)]]></PreBuildEvent>
<PostBuildEventIgnoreExitCode>False</PostBuildEventIgnoreExitCode> <PostBuildEventIgnoreExitCode>False</PostBuildEventIgnoreExitCode>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Config)'=='Release' And '$(Platform)'=='iOSSimulator'"> <PropertyGroup Condition="'$(Config)'=='Release' And '$(Platform)'=='iOSSimulator'">
<PreBuildEvent>brcc32 ..\..\..\resource\facedetectxml\haarcascade.rc -fo.\haarcascade.res</PreBuildEvent> <PreBuildEvent>brcc32 ..\..\..\resource\facedetectxml\haarcascade.rc -fo.\haarcascade.res
</PreBuildEvent>
<PreBuildEventIgnoreExitCode>False</PreBuildEventIgnoreExitCode> <PreBuildEventIgnoreExitCode>False</PreBuildEventIgnoreExitCode>
<PreLinkEvent/> <PreLinkEvent/>
<PreLinkEventIgnoreExitCode>False</PreLinkEventIgnoreExitCode> <PreLinkEventIgnoreExitCode>False</PreLinkEventIgnoreExitCode>
@ -181,7 +184,8 @@ $(PreBuildEvent)]]></PreBuildEvent>
<PostBuildEventIgnoreExitCode>False</PostBuildEventIgnoreExitCode> <PostBuildEventIgnoreExitCode>False</PostBuildEventIgnoreExitCode>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Config)'=='Release' And '$(Platform)'=='Win32'"> <PropertyGroup Condition="'$(Config)'=='Release' And '$(Platform)'=='Win32'">
<PreBuildEvent>brcc32 ..\..\..\resource\facedetectxml\haarcascade.rc -fo.\haarcascade.res</PreBuildEvent> <PreBuildEvent>brcc32 ..\..\..\resource\facedetectxml\haarcascade.rc -fo.\haarcascade.res
</PreBuildEvent>
<PreBuildEventIgnoreExitCode>False</PreBuildEventIgnoreExitCode> <PreBuildEventIgnoreExitCode>False</PreBuildEventIgnoreExitCode>
<PreLinkEvent/> <PreLinkEvent/>
<PreLinkEventIgnoreExitCode>False</PreLinkEventIgnoreExitCode> <PreLinkEventIgnoreExitCode>False</PreLinkEventIgnoreExitCode>
@ -189,7 +193,8 @@ $(PreBuildEvent)]]></PreBuildEvent>
<PostBuildEventIgnoreExitCode>False</PostBuildEventIgnoreExitCode> <PostBuildEventIgnoreExitCode>False</PostBuildEventIgnoreExitCode>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Config)'=='Release' And '$(Platform)'=='Win64'"> <PropertyGroup Condition="'$(Config)'=='Release' And '$(Platform)'=='Win64'">
<PreBuildEvent>brcc32 ..\..\..\resource\facedetectxml\haarcascade.rc -fo.\haarcascade.res</PreBuildEvent> <PreBuildEvent>brcc32 ..\..\..\resource\facedetectxml\haarcascade.rc -fo.\haarcascade.res
</PreBuildEvent>
<PreBuildEventIgnoreExitCode>False</PreBuildEventIgnoreExitCode> <PreBuildEventIgnoreExitCode>False</PreBuildEventIgnoreExitCode>
<PreLinkEvent/> <PreLinkEvent/>
<PreLinkEventIgnoreExitCode>False</PreLinkEventIgnoreExitCode> <PreLinkEventIgnoreExitCode>False</PreLinkEventIgnoreExitCode>
@ -197,7 +202,8 @@ $(PreBuildEvent)]]></PreBuildEvent>
<PostBuildEventIgnoreExitCode>False</PostBuildEventIgnoreExitCode> <PostBuildEventIgnoreExitCode>False</PostBuildEventIgnoreExitCode>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Config)'=='Debug' And '$(Platform)'=='Android'"> <PropertyGroup Condition="'$(Config)'=='Debug' And '$(Platform)'=='Android'">
<PreBuildEvent>brcc32 ..\..\..\resource\facedetectxml\haarcascade.rc -fo.\haarcascade.res</PreBuildEvent> <PreBuildEvent>brcc32 ..\..\..\resource\facedetectxml\haarcascade.rc -fo.\haarcascade.res
</PreBuildEvent>
<PreBuildEventIgnoreExitCode>False</PreBuildEventIgnoreExitCode> <PreBuildEventIgnoreExitCode>False</PreBuildEventIgnoreExitCode>
<PreLinkEvent/> <PreLinkEvent/>
<PreLinkEventIgnoreExitCode>False</PreLinkEventIgnoreExitCode> <PreLinkEventIgnoreExitCode>False</PreLinkEventIgnoreExitCode>
@ -205,7 +211,8 @@ $(PreBuildEvent)]]></PreBuildEvent>
<PostBuildEventIgnoreExitCode>False</PostBuildEventIgnoreExitCode> <PostBuildEventIgnoreExitCode>False</PostBuildEventIgnoreExitCode>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Config)'=='Debug' And '$(Platform)'=='iOSDevice'"> <PropertyGroup Condition="'$(Config)'=='Debug' And '$(Platform)'=='iOSDevice'">
<PreBuildEvent>brcc32 ..\..\..\resource\facedetectxml\haarcascade.rc -fo.\haarcascade.res</PreBuildEvent> <PreBuildEvent>brcc32 ..\..\..\resource\facedetectxml\haarcascade.rc -fo.\haarcascade.res
</PreBuildEvent>
<PreBuildEventIgnoreExitCode>False</PreBuildEventIgnoreExitCode> <PreBuildEventIgnoreExitCode>False</PreBuildEventIgnoreExitCode>
<PreLinkEvent/> <PreLinkEvent/>
<PreLinkEventIgnoreExitCode>False</PreLinkEventIgnoreExitCode> <PreLinkEventIgnoreExitCode>False</PreLinkEventIgnoreExitCode>
@ -213,7 +220,8 @@ $(PreBuildEvent)]]></PreBuildEvent>
<PostBuildEventIgnoreExitCode>False</PostBuildEventIgnoreExitCode> <PostBuildEventIgnoreExitCode>False</PostBuildEventIgnoreExitCode>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Config)'=='Debug' And '$(Platform)'=='iOSSimulator'"> <PropertyGroup Condition="'$(Config)'=='Debug' And '$(Platform)'=='iOSSimulator'">
<PreBuildEvent>brcc32 ..\..\..\resource\facedetectxml\haarcascade.rc -fo.\haarcascade.res</PreBuildEvent> <PreBuildEvent>brcc32 ..\..\..\resource\facedetectxml\haarcascade.rc -fo.\haarcascade.res
</PreBuildEvent>
<PreBuildEventIgnoreExitCode>False</PreBuildEventIgnoreExitCode> <PreBuildEventIgnoreExitCode>False</PreBuildEventIgnoreExitCode>
<PreLinkEvent/> <PreLinkEvent/>
<PreLinkEventIgnoreExitCode>False</PreLinkEventIgnoreExitCode> <PreLinkEventIgnoreExitCode>False</PreLinkEventIgnoreExitCode>
@ -221,7 +229,8 @@ $(PreBuildEvent)]]></PreBuildEvent>
<PostBuildEventIgnoreExitCode>False</PostBuildEventIgnoreExitCode> <PostBuildEventIgnoreExitCode>False</PostBuildEventIgnoreExitCode>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Config)'=='Debug' And '$(Platform)'=='Win32'"> <PropertyGroup Condition="'$(Config)'=='Debug' And '$(Platform)'=='Win32'">
<PreBuildEvent>brcc32 ..\..\..\resource\facedetectxml\haarcascade.rc -fo.\haarcascade.res</PreBuildEvent> <PreBuildEvent>brcc32 ..\..\..\resource\facedetectxml\haarcascade.rc -fo.\haarcascade.res
</PreBuildEvent>
<PreBuildEventIgnoreExitCode>False</PreBuildEventIgnoreExitCode> <PreBuildEventIgnoreExitCode>False</PreBuildEventIgnoreExitCode>
<PreLinkEvent/> <PreLinkEvent/>
<PreLinkEventIgnoreExitCode>False</PreLinkEventIgnoreExitCode> <PreLinkEventIgnoreExitCode>False</PreLinkEventIgnoreExitCode>
@ -229,7 +238,8 @@ $(PreBuildEvent)]]></PreBuildEvent>
<PostBuildEventIgnoreExitCode>False</PostBuildEventIgnoreExitCode> <PostBuildEventIgnoreExitCode>False</PostBuildEventIgnoreExitCode>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Config)'=='Debug' And '$(Platform)'=='Win64'"> <PropertyGroup Condition="'$(Config)'=='Debug' And '$(Platform)'=='Win64'">
<PreBuildEvent>brcc32 ..\..\..\resource\facedetectxml\haarcascade.rc -fo.\haarcascade.res</PreBuildEvent> <PreBuildEvent>brcc32 ..\..\..\resource\facedetectxml\haarcascade.rc -fo.\haarcascade.res
</PreBuildEvent>
<PreBuildEventIgnoreExitCode>False</PreBuildEventIgnoreExitCode> <PreBuildEventIgnoreExitCode>False</PreBuildEventIgnoreExitCode>
<PreLinkEvent/> <PreLinkEvent/>
<PreLinkEventIgnoreExitCode>False</PreLinkEventIgnoreExitCode> <PreLinkEventIgnoreExitCode>False</PreLinkEventIgnoreExitCode>
@ -237,3 +247,11 @@ $(PreBuildEvent)]]></PreBuildEvent>
<PostBuildEventIgnoreExitCode>False</PostBuildEventIgnoreExitCode> <PostBuildEventIgnoreExitCode>False</PostBuildEventIgnoreExitCode>
</PropertyGroup> </PropertyGroup>
</Project> </Project>
<!-- EurekaLog First Line
[Exception Log]
EurekaLog Version=7007
Activate=0
DeleteMapAfterCompile=1
Encrypt Password=""
EurekaLog Last Line -->

View File

@ -64,8 +64,7 @@ Type
procedure detect(image: TccvMat; keypoints: TCVectorKeyPoint; mask: TccvMat = nil); virtual; stdcall; abstract; procedure detect(image: TccvMat; keypoints: TCVectorKeyPoint; mask: TccvMat = nil); virtual; stdcall; abstract;
procedure compute(image: TccvMat; keypoints: TCVectorKeyPoint; Var descriptors: TccvMat); virtual; stdcall; abstract; procedure compute(image: TccvMat; keypoints: TCVectorKeyPoint; Var descriptors: TccvMat); virtual; stdcall; abstract;
// ------------------------------------------------ // ------------------------------------------------
class function Create: TSURF; overload; class function Create(hessianThreshold: double = 400; nOctaves: Integer = 4; nOctaveLayers: Integer = 2; extended: BOOL = true;
class function Create(hessianThreshold: double; nOctaves: Integer = 4; nOctaveLayers: Integer = 2; extended: BOOL = true;
upright: BOOL = false): TSURF; overload; upright: BOOL = false): TSURF; overload;
procedure Free; reintroduce; procedure Free; reintroduce;
end; end;
@ -88,6 +87,147 @@ Type
// features2d // features2d
const
kBytes = 32;
HARRIS_SCORE = 0;
FAST_SCORE = 1;
Type
TBRISK = class
public
procedure detect(image: TccvMat; keypoints: TCVectorKeyPoint; mask: TccvMat = nil); virtual; stdcall; abstract;
procedure compute(image: TccvMat; keypoints: TCVectorKeyPoint; Var descriptors: TccvMat); virtual; stdcall; abstract;
// ------------------------------------------------
class function Create(thresh: Integer = 30; octaves: Integer = 3; patternScale: Single = 1.0): TBRISK; overload;
procedure Free; reintroduce;
end;
TBRISKFeatureDetector = TBRISK;
TBRISKDescriptorExtractor = TBRISK;
TORB = class
public
procedure detect(image: TccvMat; keypoints: TCVectorKeyPoint; mask: TccvMat = nil); virtual; stdcall; abstract;
procedure compute(image: TccvMat; keypoints: TCVectorKeyPoint; Var descriptors: TccvMat); virtual; stdcall; abstract;
// ------------------------------------------------
class function Create(nfeatures: Integer = 500; scaleFactor: Single = 1.2; nlevels: Integer = 8; edgeThreshold: Integer = 31;
firstLevel: Integer = 0; WTA_K: Integer = 2; scoreType: Integer = HARRIS_SCORE; patchSize: Integer = 31): TORB; overload;
procedure Free; reintroduce;
end;
TORBFeatureDetector = TORB;
TORBDescriptorExtractor = TORB;
TFREAK = class
public
procedure compute(image: TccvMat; keypoints: TCVectorKeyPoint; Var descriptors: TccvMat); virtual; stdcall; abstract;
// ------------------------------------------------
class function Create(orientationNormalized: BOOL = true; scaleNormalized: BOOL = true; patternScale: Single = 22.0;
nOctaves: Integer = 4): TFREAK; overload;
procedure Free; reintroduce;
end;
TFREAKDescriptorExtractor = TFREAK;
TMSER = class
public
procedure detect(image: TccvMat; keypoints: TCVectorKeyPoint; mask: TccvMat = nil); virtual; stdcall; abstract;
// ------------------------------------------------
class function Create(_delta: Integer = 5; _min_area: Integer = 60; _max_area: Integer = 14400; _max_variation: double = 0.25;
_min_diversity: double = 0.2; _max_evolution: Integer = 200; _area_threshold: double = 1.01; _min_margin: double = 0.003;
_edge_blur_size: Integer = 5): TMSER; overload;
procedure Free; reintroduce;
end;
TMSERFeatureDetector = TMSER;
TStarDetector = class
public
procedure detect(image: TccvMat; keypoints: TCVectorKeyPoint; mask: TccvMat = nil); virtual; stdcall; abstract;
// ------------------------------------------------
class function Create(_maxSize: Integer = 45; _responseThreshold: Integer = 30; _lineThresholdProjected: Integer = 10;
_lineThresholdBinarized: Integer = 8; _suppressNonmaxSize: Integer = 5): TStarDetector; overload;
procedure Free; reintroduce;
end;
TStarFeatureDetector = TStarDetector;
TFastFeatureDetector = class
public
procedure detect(image: TccvMat; keypoints: TCVectorKeyPoint; mask: TccvMat = nil); virtual; stdcall; abstract;
// ------------------------------------------------
class function Create(threshold: Integer = 10; nonmaxSuppression: BOOL = true): TFastFeatureDetector; overload;
procedure Free; reintroduce;
end;
TGFTTDetector = class
public
procedure detect(image: TccvMat; keypoints: TCVectorKeyPoint; mask: TccvMat = nil); virtual; stdcall; abstract;
// ------------------------------------------------
class function Create(maxCorners: Integer = 1000; qualityLevel: double = 0.01; minDistance: double = 1; blockSize: Integer = 3;
useHarrisDetector: BOOL = false; k: double = 0.04): TGFTTDetector; overload;
procedure Free; reintroduce;
end;
TGFTTFeatureDetector = TGFTTDetector;
TGoodFeaturesToTrackDetector = TGFTTDetector;
TSimpleBlobDetectorParams = record
thresholdStep: Single;
minThreshold: Single;
maxThreshold: Single;
minRepeatability: size_t;
minDistBetweenBlobs: Single;
filterByColor: Boolean;
blobColor: uchar;
filterByArea: BOOL;
minArea: Single;
maxArea: Single;
filterByCircularity: BOOL;
minCircularity: Single;
maxCircularity: Single;
filterByInertia: BOOL;
minInertiaRatio: Single;
maxInertiaRatio: Single;
filterByConvexity: BOOL;
minConvexity: Single;
maxConvexity: Single;
// -------------------------------
procedure SetDefault;
end;
TSimpleBlobDetector = class
public
procedure detect(image: TccvMat; keypoints: TCVectorKeyPoint; mask: TccvMat = nil); virtual; stdcall; abstract;
// ------------------------------------------------
class function Create: TSimpleBlobDetector; overload;
class function Create(SimpleBlobDetectorParams: TSimpleBlobDetectorParams): TSimpleBlobDetector; overload;
procedure Free; reintroduce;
end;
TDenseFeatureDetector = class
public
procedure detect(image: TccvMat; keypoints: TCVectorKeyPoint; mask: TccvMat = nil); virtual; stdcall; abstract;
// ------------------------------------------------
class function Create(initFeatureScale: Single = 1; featureScaleLevels: Integer = 1; featureScaleMul: Single = 0.1;
initXyStep: Integer = 6; initImgBound: Integer = 0; varyXyStepWithScale: BOOL = true; varyImgBoundWithScale: BOOL = false)
: TDenseFeatureDetector; overload;
procedure Free; reintroduce;
end;
TBriefDescriptorExtractor = class
public
procedure detect(image: TccvMat; keypoints: TCVectorKeyPoint; mask: TccvMat = nil); virtual; stdcall; abstract;
// ------------------------------------------------
class function Create(bytes: Integer = 32): TBriefDescriptorExtractor; overload;
procedure Free; reintroduce;
end;
pDMatch = ^TDMatch; pDMatch = ^TDMatch;
TDMatch = record TDMatch = record
@ -122,25 +262,34 @@ const
type type
TBFMatcher = class TBFMatcher = class
public public
procedure match(queryDescriptors: TccvMat; trainDescriptors: TccvMat; matches: TCVectorDMatch; mask: TccvMat = Nil); virtual; procedure match(queryDescriptors: TccvMat; trainDescriptors: TccvMat; matces: TCVectorDMatch; mask: TccvMat = Nil); virtual;
stdcall; abstract; stdcall; abstract;
// --------------------- // ---------------------
class function Create(normType: Integer = NORM_L2; crossCheck: BOOL = false): TBFMatcher; class function Create(normType: Integer = NORM_L2; crossCheck: BOOL = false): TBFMatcher;
procedure Free; reintroduce; procedure Free; reintroduce;
end; end;
TFlannBasedMatcher = class
public
procedure match(queryDescriptors: TccvMat; trainDescriptors: TccvMat; matces: TCVectorDMatch; mask: TccvMat = Nil); virtual;
stdcall; abstract;
// ---------------------
class function Create: TFlannBasedMatcher;
procedure Free; reintroduce;
end;
procedure DrawMatches(img1: TccvMat; keypoints1: TCVectorKeyPoint; img2: TccvMat; keypoints2: TCVectorKeyPoint; matches1to2: TCVectorDMatch; procedure DrawMatches(img1: TccvMat; keypoints1: TCVectorKeyPoint; img2: TccvMat; keypoints2: TCVectorKeyPoint; matches1to2: TCVectorDMatch;
Var outImg: TccvMat); stdcall; Var outImg: TccvMat); stdcall;
implementation implementation
uses uses
ocv.lib; ocv.lib, System.Math;
function CreateSURF: TSURF; stdcall; external opencv_classes_lib; function CreateSURF(hessianThreshold: double; nOctaves: Integer = 4; nOctaveLayers: Integer = 2; extended: BOOL = true;
function CreateSURFFromValue(hessianThreshold: double; nOctaves: Integer = 4; nOctaveLayers: Integer = 2; extended: BOOL = true;
upright: BOOL = false): TSURF; stdcall; external opencv_classes_lib; upright: BOOL = false): TSURF; stdcall; external opencv_classes_lib;
procedure ReleaseSURF(ex: TSURF); stdcall; external opencv_classes_lib; procedure ReleaseSURF(ex: TSURF); stdcall; external opencv_classes_lib;
function CreateSIFT(nfeatures: Integer = 0; nOctaveLayers: Integer = 3; contrastThreshold: double = 0.04; edgeThreshold: double = 10; function CreateSIFT(nfeatures: Integer = 0; nOctaveLayers: Integer = 3; contrastThreshold: double = 0.04; edgeThreshold: double = 10;
sigma: double = 1.6): TSIFT; stdcall; external opencv_classes_lib; sigma: double = 1.6): TSIFT; stdcall; external opencv_classes_lib;
procedure ReleaseSIFT(ex: TSIFT); stdcall; external opencv_classes_lib; procedure ReleaseSIFT(ex: TSIFT); stdcall; external opencv_classes_lib;
@ -156,16 +305,46 @@ procedure ReleaseBFMatcher(ex: TBFMatcher); stdcall; external opencv_classes_lib
procedure DrawMatches; stdcall; external opencv_classes_lib; procedure DrawMatches; stdcall; external opencv_classes_lib;
{ TSURF } function CreateBRISK(thresh: Integer = 30; octaves: Integer = 3; patternScale: Single = 1.0): TBRISK; stdcall; external opencv_classes_lib;
procedure ReleaseBRISK(ex: TBRISK); stdcall; external opencv_classes_lib;
function CreateORB(nfeatures: Integer = 500; scaleFactor: Single = 1.2; nlevels: Integer = 8; edgeThreshold: Integer = 31;
firstLevel: Integer = 0; WTA_K: Integer = 2; scoreType: Integer = HARRIS_SCORE; patchSize: Integer = 31): TORB; stdcall;
external opencv_classes_lib;
procedure ReleaseORB(ex: TORB); stdcall; external opencv_classes_lib;
function CreateFREAK(orientationNormalized: BOOL = true; scaleNormalized: BOOL = true; patternScale: Single = 22.0; nOctaves: Integer = 4)
: TFREAK; stdcall; external opencv_classes_lib;
procedure ReleaseFREAK(ex: TFREAK); stdcall; external opencv_classes_lib;
function CreateMSER(_delta: Integer = 5; _min_area: Integer = 60; _max_area: Integer = 14400; _max_variation: double = 0.25;
_min_diversity: double = 0.2; _max_evolution: Integer = 200; _area_threshold: double = 1.01; _min_margin: double = 0.003;
_edge_blur_size: Integer = 5): TMSER; stdcall; external opencv_classes_lib;
procedure ReleaseMSER(ex: TMSER); stdcall; external opencv_classes_lib;
function CreateStarDetector(_maxSize: Integer = 45; _responseThreshold: Integer = 30; _lineThresholdProjected: Integer = 10;
_lineThresholdBinarized: Integer = 8; _suppressNonmaxSize: Integer = 5): TStarDetector; stdcall; external opencv_classes_lib;
procedure ReleaseStarDetector(ex: TStarDetector); stdcall; external opencv_classes_lib;
function CreateFastFeatureDetector(threshold: Integer = 10; nonmaxSuppression: BOOL = true): TFastFeatureDetector; stdcall;
external opencv_classes_lib;
procedure ReleaseFastFeatureDetector(ex: TFastFeatureDetector); stdcall; external opencv_classes_lib;
function CreateGFTTDetector(maxCorners: Integer = 1000; qualityLevel: double = 0.01; minDistance: double = 1; blockSize: Integer = 3;
useHarrisDetector: BOOL = false; k: double = 0.04): TGFTTDetector; stdcall; external opencv_classes_lib;
procedure ReleaseGFTTDetector(ex: TGFTTDetector); stdcall; external opencv_classes_lib;
function CreateSimpleBlobDetector(SimpleBlobDetectorParams: TSimpleBlobDetectorParams): TSimpleBlobDetector; stdcall;
external opencv_classes_lib;
function CreateSimpleBlobDetectorDefault(): TSimpleBlobDetector; stdcall; external opencv_classes_lib;
procedure ReleaseSimpleBlobDetector(ex: TSimpleBlobDetector); stdcall; external opencv_classes_lib;
function CreateDenseFeatureDetector(initFeatureScale: Single = 1; featureScaleLevels: Integer = 1; featureScaleMul: Single = 0.1;
initXyStep: Integer = 6; initImgBound: Integer = 0; varyXyStepWithScale: BOOL = true; varyImgBoundWithScale: BOOL = false)
: TDenseFeatureDetector; stdcall; external opencv_classes_lib;
procedure ReleaseDenseFeatureDetector(ex: TDenseFeatureDetector); stdcall; external opencv_classes_lib;
function CreateBriefDescriptorExtractor(bytes: Integer = 32): TBriefDescriptorExtractor; stdcall; external opencv_classes_lib;
procedure ReleaseBriefDescriptorExtractor(ex: TBriefDescriptorExtractor); stdcall; external opencv_classes_lib;
function CreateFlannBasedMatcher(): TFlannBasedMatcher; stdcall; external opencv_classes_lib;
procedure ReleaseFlannBasedMatcher(ex: TFlannBasedMatcher); stdcall; external opencv_classes_lib;
class function TSURF.Create: TSURF; { TSURF }
begin
Result := CreateSURF;
end;
class function TSURF.Create(hessianThreshold: double; nOctaves, nOctaveLayers: Integer; extended, upright: BOOL): TSURF; class function TSURF.Create(hessianThreshold: double; nOctaves, nOctaveLayers: Integer; extended, upright: BOOL): TSURF;
begin begin
Result := CreateSURFFromValue(hessianThreshold, nOctaves, nOctaveLayers, extended, upright); Result := CreateSURF(hessianThreshold, nOctaves, nOctaveLayers, extended, upright);
end; end;
procedure TSURF.Free; procedure TSURF.Free;
@ -221,4 +400,180 @@ begin
ReleaseSIFT(Self); ReleaseSIFT(Self);
end; end;
{ TBRISK }
class function TBRISK.Create(thresh, octaves: Integer; patternScale: Single): TBRISK;
begin
Result := CreateBRISK(thresh, octaves, patternScale);
end;
procedure TBRISK.Free;
begin
ReleaseBRISK(Self);
end;
{ TORB }
class function TORB.Create(nfeatures: Integer; scaleFactor: Single; nlevels, edgeThreshold, firstLevel, WTA_K, scoreType,
patchSize: Integer): TORB;
begin
Result := CreateORB(nfeatures, scaleFactor, nlevels, edgeThreshold, firstLevel, WTA_K, scoreType, patchSize);
end;
procedure TORB.Free;
begin
ReleaseORB(Self);
end;
{ TFREAK }
class function TFREAK.Create(orientationNormalized, scaleNormalized: BOOL; patternScale: Single; nOctaves: Integer): TFREAK;
begin
Result := CreateFREAK(orientationNormalized, scaleNormalized, patternScale, nOctaves);
end;
procedure TFREAK.Free;
begin
ReleaseFREAK(Self);
end;
{ TMSER }
class function TMSER.Create(_delta, _min_area, _max_area: Integer; _max_variation, _min_diversity: double; _max_evolution: Integer;
_area_threshold, _min_margin: double; _edge_blur_size: Integer): TMSER;
begin
Result := CreateMSER(_delta, _min_area, _max_area, _max_variation, _min_diversity, _max_evolution, _area_threshold, _min_margin,
_edge_blur_size);
end;
procedure TMSER.Free;
begin
ReleaseMSER(Self);
end;
{ TStarDetector }
class function TStarDetector.Create(_maxSize, _responseThreshold, _lineThresholdProjected, _lineThresholdBinarized,
_suppressNonmaxSize: Integer): TStarDetector;
begin
Result := CreateStarDetector(_maxSize, _responseThreshold, _lineThresholdProjected, _lineThresholdBinarized, _suppressNonmaxSize);
end;
procedure TStarDetector.Free;
begin
ReleaseStarDetector(Self);
end;
{ TFastFeatureDetector }
class function TFastFeatureDetector.Create(threshold: Integer; nonmaxSuppression: BOOL): TFastFeatureDetector;
begin
Result := CreateFastFeatureDetector(threshold, nonmaxSuppression);
end;
procedure TFastFeatureDetector.Free;
begin
ReleaseFastFeatureDetector(Self);
end;
{ TGFTTDetector }
class function TGFTTDetector.Create(maxCorners: Integer; qualityLevel, minDistance: double; blockSize: Integer; useHarrisDetector: BOOL;
k: double): TGFTTDetector;
begin
Result := CreateGFTTDetector(maxCorners, qualityLevel, minDistance, blockSize, useHarrisDetector, k);
end;
procedure TGFTTDetector.Free;
begin
ReleaseGFTTDetector(Self);
end;
{ TSimpleBlobDetectorParams }
procedure TSimpleBlobDetectorParams.SetDefault;
begin
thresholdStep := 10;
minThreshold := 50;
maxThreshold := 220;
minRepeatability := 2;
minDistBetweenBlobs := 10;
filterByColor := true;
blobColor := 0;
filterByArea := true;
minArea := 25;
maxArea := 5000;
filterByCircularity := false;
minCircularity := 0.8;
maxCircularity := MaxSingle;
filterByInertia := true;
// minInertiaRatio := 0.6;
minInertiaRatio := 0.1;
maxInertiaRatio := MaxSingle;
filterByConvexity := true;
// minConvexity := 0.8;
minConvexity := 0.95;
maxConvexity := MaxSingle;
end;
{ TSimpleBlobDetector }
class function TSimpleBlobDetector.Create: TSimpleBlobDetector;
begin
Result := CreateSimpleBlobDetectorDefault;
end;
class function TSimpleBlobDetector.Create(SimpleBlobDetectorParams: TSimpleBlobDetectorParams): TSimpleBlobDetector;
begin
Result := CreateSimpleBlobDetector(SimpleBlobDetectorParams);
end;
procedure TSimpleBlobDetector.Free;
begin
ReleaseSimpleBlobDetector(Self);
end;
{ TDenseFeatureDetector }
class function TDenseFeatureDetector.Create(initFeatureScale: Single; featureScaleLevels: Integer; featureScaleMul: Single;
initXyStep, initImgBound: Integer; varyXyStepWithScale, varyImgBoundWithScale: BOOL): TDenseFeatureDetector;
begin
Result := CreateDenseFeatureDetector(initFeatureScale, featureScaleLevels, featureScaleMul, initXyStep, initImgBound, varyXyStepWithScale,
varyImgBoundWithScale);
end;
procedure TDenseFeatureDetector.Free;
begin
ReleaseDenseFeatureDetector(Self);
end;
{ TBriefDescriptorExtractor }
class function TBriefDescriptorExtractor.Create(bytes: Integer): TBriefDescriptorExtractor;
begin
Result := CreateBriefDescriptorExtractor(bytes);
end;
procedure TBriefDescriptorExtractor.Free;
begin
ReleaseBriefDescriptorExtractor(Self);
end;
{ TFlannBasedMatcher }
class function TFlannBasedMatcher.Create: TFlannBasedMatcher;
begin
Result := CreateFlannBasedMatcher;
end;
procedure TFlannBasedMatcher.Free;
begin
ReleaseFlannBasedMatcher(Self);
end;
end. end.

View File

@ -146,12 +146,7 @@ void ICLASS_API ReleaseCascadeClassifier(TCascadeClassifier* ex)
/////////////////////////////////////////////// ///////////////////////////////////////////////
TSURF* ICLASS_API CreateSURF() TSURF* ICLASS_API CreateSURF(double hessianThreshold,
{
return new TSURF();
};
TSURF* ICLASS_API CreateSURFFromValue(double hessianThreshold,
int nOctaves = 4, int nOctaveLayers = 2, int nOctaves = 4, int nOctaveLayers = 2,
BOOL extended = true, BOOL upright = false) BOOL extended = true, BOOL upright = false)
{ {
@ -175,6 +170,165 @@ void ICLASS_API ReleaseSIFT(TSIFT* ex)
{ {
delete ex; delete ex;
}; };
//----------------------------------------------------
TBRISK* ICLASS_API CreateBRISK(int thresh = 30, int octaves = 3, float patternScale = 1.0f)
{
return new TBRISK(thresh, octaves, patternScale);
};
void ICLASS_API ReleaseBRISK(TBRISK* ex)
{
delete ex;
};
TORB* ICLASS_API CreateORB(int nfeatures = 500, float scaleFactor = 1.2f, int nlevels = 8, int edgeThreshold = 31,
int firstLevel = 0, int WTA_K = 2, int scoreType = ORB::HARRIS_SCORE, int patchSize = 31)
{
return new TORB(nfeatures, scaleFactor, nlevels, edgeThreshold,
firstLevel, WTA_K, scoreType, patchSize);
};
void ICLASS_API ReleaseORB(TORB* ex)
{
delete ex;
};
TFREAK* ICLASS_API CreateFREAK(BOOL orientationNormalized = true,
BOOL scaleNormalized = true,
float patternScale = 22.0f,
int nOctaves = 4)
{
return new TFREAK(orientationNormalized, scaleNormalized, patternScale, nOctaves);
};
void ICLASS_API ReleaseFREAK(TFREAK* ex)
{
delete ex;
};
TMSER* ICLASS_API CreateMSER(int _delta = 5, int _min_area = 60, int _max_area = 14400,
double _max_variation = 0.25, double _min_diversity = .2,
int _max_evolution = 200, double _area_threshold = 1.01,
double _min_margin = 0.003, int _edge_blur_size = 5)
{
return new TMSER(_delta, _min_area, _max_area, _max_variation, _min_diversity,
_max_evolution, _area_threshold,
_min_margin, _edge_blur_size);
};
void ICLASS_API ReleaseMSER(TMSER* ex)
{
delete ex;
};
TStarDetector* ICLASS_API CreateStarDetector(int _maxSize = 45, int _responseThreshold = 30,
int _lineThresholdProjected = 10,
int _lineThresholdBinarized = 8,
int _suppressNonmaxSize = 5)
{
return new TStarDetector(_maxSize, _responseThreshold,
_lineThresholdProjected, _lineThresholdBinarized, _suppressNonmaxSize);
};
void ICLASS_API ReleaseStarDetector(TStarDetector* ex)
{
delete ex;
};
TFastFeatureDetector* ICLASS_API CreateFastFeatureDetector(int threshold = 10, BOOL nonmaxSuppression = true)
{
return new TFastFeatureDetector(threshold, nonmaxSuppression);
};
void ICLASS_API ReleaseFastFeatureDetector(TFastFeatureDetector* ex)
{
delete ex;
};
TGFTTDetector* ICLASS_API CreateGFTTDetector(int maxCorners = 1000, double qualityLevel = 0.01, double minDistance = 1,
int blockSize = 3, BOOL useHarrisDetector = false, double k = 0.04)
{
return new TGFTTDetector(maxCorners, qualityLevel, minDistance,
blockSize, useHarrisDetector, k);
};
void ICLASS_API ReleaseGFTTDetector(TGFTTDetector* ex)
{
delete ex;
};
TSimpleBlobDetector* ICLASS_API CreateSimpleBlobDetector(TSimpleBlobDetectorParams SimpleBlobDetectorParams)
{
SimpleBlobDetector::Params parameters;
parameters.thresholdStep = SimpleBlobDetectorParams.thresholdStep;
parameters.minThreshold = SimpleBlobDetectorParams.minThreshold;
parameters.maxThreshold = SimpleBlobDetectorParams.maxThreshold;
parameters.minRepeatability = SimpleBlobDetectorParams.minRepeatability;
parameters.minDistBetweenBlobs = SimpleBlobDetectorParams.minDistBetweenBlobs;
parameters.filterByColor = SimpleBlobDetectorParams.filterByColor;
parameters.blobColor = SimpleBlobDetectorParams.blobColor;
parameters.filterByArea = SimpleBlobDetectorParams.filterByArea;
parameters.minArea = SimpleBlobDetectorParams.minArea;
parameters.maxArea = SimpleBlobDetectorParams.maxArea;
parameters.filterByCircularity = SimpleBlobDetectorParams.filterByCircularity;
parameters.minCircularity = SimpleBlobDetectorParams.minCircularity;
parameters.maxCircularity = SimpleBlobDetectorParams.maxCircularity;
parameters.filterByInertia = SimpleBlobDetectorParams.filterByInertia;
parameters.minInertiaRatio = SimpleBlobDetectorParams.minInertiaRatio;
parameters.maxInertiaRatio = SimpleBlobDetectorParams.maxInertiaRatio;
parameters.filterByConvexity = SimpleBlobDetectorParams.filterByConvexity;
parameters.minConvexity = SimpleBlobDetectorParams.minConvexity;
parameters.maxConvexity = SimpleBlobDetectorParams.maxConvexity;
return new TSimpleBlobDetector(parameters);
};
TSimpleBlobDetector* ICLASS_API CreateSimpleBlobDetectorDefault()
{
return new TSimpleBlobDetector();
};
void ICLASS_API ReleaseSimpleBlobDetector(TSimpleBlobDetector* ex)
{
delete ex;
};
TDenseFeatureDetector* ICLASS_API CreateDenseFeatureDetector(float initFeatureScale = 1.f, int featureScaleLevels = 1,
float featureScaleMul = 0.1f,
int initXyStep = 6, int initImgBound = 0,
BOOL varyXyStepWithScale = true,
BOOL varyImgBoundWithScale = false)
{
return new TDenseFeatureDetector(initFeatureScale, featureScaleLevels,
featureScaleMul, initXyStep, initImgBound, varyXyStepWithScale, varyImgBoundWithScale);
};
void ICLASS_API ReleaseDenseFeatureDetector(TDenseFeatureDetector* ex)
{
delete ex;
};
TBriefDescriptorExtractor* ICLASS_API CreateBriefDescriptorExtractor(int bytes = 32)
{
return new TBriefDescriptorExtractor(bytes);
};
void ICLASS_API ReleaseBriefDescriptorExtractor(TBriefDescriptorExtractor* ex)
{
delete ex;
};
TFlannBasedMatcher* ICLASS_API CreateFlannBasedMatcher()
{
return new TFlannBasedMatcher();
};
void ICLASS_API ReleaseFlannBasedMatcher(TFlannBasedMatcher* ex)
{
delete ex;
};
//----------------------------------------------------
TBFMatcher* ICLASS_API CreateBFMatcher(int normType = NORM_L2, BOOL crossCheck = false) TBFMatcher* ICLASS_API CreateBFMatcher(int normType = NORM_L2, BOOL crossCheck = false)
{ {

View File

@ -41,15 +41,42 @@ EXPORTS
CreateCascadeClassifierFromFile CreateCascadeClassifierFromFile
ReleaseCascadeClassifier ReleaseCascadeClassifier
CreateSURF CreateSURF
CreateSURFFromValue
ReleaseSURF ReleaseSURF
CreateSIFT
ReleaseSIFT
CreateCVectorKeyPoint CreateCVectorKeyPoint
ReleaseCVectorKeyPoint ReleaseCVectorKeyPoint
CreateCVectorDMatch CreateCVectorDMatch
ReleaseCVectorDMatch ReleaseCVectorDMatch
CreateBFMatcher CreateBFMatcher
ReleaseBFMatcher ReleaseBFMatcher
DrawMatches DrawMatches
CreateSIFT
ReleaseSIFT CreateBRISK
ReleaseBRISK
CreateORB
ReleaseORB
CreateFREAK
ReleaseFREAK
CreateMSER
ReleaseMSER
CreateStarDetector
ReleaseStarDetector
CreateFastFeatureDetector
ReleaseFastFeatureDetector
CreateGFTTDetector
ReleaseGFTTDetector
CreateSimpleBlobDetector
CreateSimpleBlobDetectorDefault
ReleaseSimpleBlobDetector
CreateDenseFeatureDetector
ReleaseDenseFeatureDetector
CreateBriefDescriptorExtractor
ReleaseBriefDescriptorExtractor
CreateFlannBasedMatcher
ReleaseFlannBasedMatcher

View File

@ -279,7 +279,7 @@ class OCV_CLASS_EXPORT TSURF
{ {
private: private:
SURF FSURF; SURF FSURF;
public: public:
TSURF() : FSURF() {}; TSURF() : FSURF() {};
TSURF(double hessianThreshold, TSURF(double hessianThreshold,
int nOctaves = 4, int nOctaveLayers = 2, int nOctaves = 4, int nOctaveLayers = 2,
@ -316,8 +316,7 @@ class OCV_CLASS_EXPORT TBFMatcher
{ {
private: private:
BFMatcher FBFMatcher; BFMatcher FBFMatcher;
public: public:
TBFMatcher() : FBFMatcher() {};
TBFMatcher(int normType = NORM_L2, BOOL crossCheck = false) : FBFMatcher(normType, crossCheck) {}; TBFMatcher(int normType = NORM_L2, BOOL crossCheck = false) : FBFMatcher(normType, crossCheck) {};
~TBFMatcher(){}; ~TBFMatcher(){};
virtual void ICLASS_API match(TMat* queryDescriptors, TMat* trainDescriptors, virtual void ICLASS_API match(TMat* queryDescriptors, TMat* trainDescriptors,
@ -338,8 +337,7 @@ class OCV_CLASS_EXPORT TSIFT
{ {
private: private:
SIFT FSIFT; SIFT FSIFT;
public: public:
TSIFT() : FSIFT() {};
TSIFT(int nfeatures = 0, int nOctaveLayers = 3, TSIFT(int nfeatures = 0, int nOctaveLayers = 3,
double contrastThreshold = 0.04, double edgeThreshold = 10, double contrastThreshold = 0.04, double edgeThreshold = 10,
double sigma = 1.6) : FSIFT(nfeatures, nOctaveLayers, double sigma = 1.6) : FSIFT(nfeatures, nOctaveLayers,
@ -375,8 +373,7 @@ class OCV_CLASS_EXPORT TBRISK
{ {
private: private:
BRISK FBRISK; BRISK FBRISK;
public: public:
TBRISK() : FBRISK() {};
TBRISK(int thresh = 30, int octaves = 3, float patternScale = 1.0f) : FBRISK(thresh, octaves, patternScale) {}; TBRISK(int thresh = 30, int octaves = 3, float patternScale = 1.0f) : FBRISK(thresh, octaves, patternScale) {};
~TBRISK(){}; ~TBRISK(){};
@ -570,6 +567,31 @@ public:
}; };
typedef struct TSimpleBlobDetectorParams
{
float thresholdStep;
float minThreshold;
float maxThreshold;
size_t minRepeatability;
float minDistBetweenBlobs;
bool filterByColor;
uchar blobColor;
BOOL filterByArea;
float minArea, maxArea;
BOOL filterByCircularity;
float minCircularity, maxCircularity;
BOOL filterByInertia;
float minInertiaRatio, maxInertiaRatio;
BOOL filterByConvexity;
float minConvexity, maxConvexity;
} TSimpleBlobDetectorParams;
class OCV_CLASS_EXPORT TSimpleBlobDetector class OCV_CLASS_EXPORT TSimpleBlobDetector
{ {
private: private:
@ -617,46 +639,46 @@ public:
}; };
}; };
class OCV_CLASS_EXPORT TGridAdaptedFeatureDetector class OCV_CLASS_EXPORT TBriefDescriptorExtractor
{ {
private: private:
GridAdaptedFeatureDetector Detector; BriefDescriptorExtractor Detector;
public: public:
TGridAdaptedFeatureDetector(const Ptr<FeatureDetector>& detector = 0, TBriefDescriptorExtractor() : Detector() {};
int maxTotalKeypoints = 1000, TBriefDescriptorExtractor(int bytes = 32) : Detector(bytes) {};
int gridRows = 4, int gridCols = 4) : Detector(detector,maxTotalKeypoints,gridRows, gridCols) {}; ~TBriefDescriptorExtractor(){};
~TGridAdaptedFeatureDetector(){};
virtual void ICLASS_API detect(TMat* image, CV_OUT TCVectorKeyPoint* keypoints, TMat* mask = NULL) virtual void ICLASS_API compute(TMat* image, TCVectorKeyPoint* keypoints, TMat** descriptors)
{ {
vector<KeyPoint> keypoints1; vector<KeyPoint> keypoints1;
if (mask) for (size_t i = 0; i < keypoints->size(); i++)
Detector.detect(*image->Mat(), keypoints1, *mask->Mat()); else
Detector.detect(*image->Mat(), keypoints1);
for (size_t i = 0; i < keypoints1.size(); i++)
{ {
keypoints->Vector()->push_back(CKeyPoint(keypoints1[i])); TKeyPoint K = *keypoints->at(i);
} keypoints1.push_back(KeyPoint(K.x, K.y, K.size, K.angle, K.response, K.octave, K.class_id));
};
Mat m;
Detector.compute(*image->Mat(), keypoints1, m);
*descriptors = new TMat(m);
}; };
}; };
class OCV_CLASS_EXPORT TPyramidAdaptedFeatureDetector class OCV_CLASS_EXPORT TFlannBasedMatcher
{ {
private: private:
PyramidAdaptedFeatureDetector Detector; FlannBasedMatcher FBFMatcher;
public: public:
TPyramidAdaptedFeatureDetector(const Ptr<FeatureDetector>& detector, int maxLevel = 2) : Detector(detector, maxLevel) {}; TFlannBasedMatcher() : FBFMatcher() {};
~TPyramidAdaptedFeatureDetector(){}; ~TFlannBasedMatcher(){};
virtual void ICLASS_API match(TMat* queryDescriptors, TMat* trainDescriptors,
virtual void ICLASS_API detect(TMat* image, CV_OUT TCVectorKeyPoint* keypoints, TMat* mask = NULL) CV_OUT TCVectorDMatch* matches, TMat* mask = NULL)
{ {
vector<KeyPoint> keypoints1; vector<DMatch> m;
if (mask) if (mask)
Detector.detect(*image->Mat(), keypoints1, *mask->Mat()); else FBFMatcher.match(*queryDescriptors->Mat(), *trainDescriptors->Mat(), m, *mask->Mat()); else
Detector.detect(*image->Mat(), keypoints1); FBFMatcher.match(*queryDescriptors->Mat(), *trainDescriptors->Mat(), m);
for (size_t i = 0; i < keypoints1.size(); i++) for (size_t i = 0; i < m.size(); i++)
{ {
keypoints->Vector()->push_back(CKeyPoint(keypoints1[i])); matches->push_back(CDMatch(m[i]));
} }
}; };
}; };

View File

@ -37,8 +37,7 @@ ICLASS_EXPORT TCascadeClassifier* ICLASS_API CreateCascadeClassifier();
ICLASS_EXPORT TCascadeClassifier* ICLASS_API CreateCascadeClassifierFromFile(const char* filename); ICLASS_EXPORT TCascadeClassifier* ICLASS_API CreateCascadeClassifierFromFile(const char* filename);
ICLASS_EXPORT void ICLASS_API ReleaseCascadeClassifier(TCascadeClassifier* ex); ICLASS_EXPORT void ICLASS_API ReleaseCascadeClassifier(TCascadeClassifier* ex);
ICLASS_EXPORT TSURF* ICLASS_API CreateSURF(); ICLASS_EXPORT TSURF* ICLASS_API CreateSURF(double hessianThreshold, int nOctaves, int nOctaveLayers, BOOL extended, BOOL upright);
ICLASS_EXPORT TSURF* ICLASS_API CreateSURFFromValue(double hessianThreshold,int nOctaves, int nOctaveLayers,BOOL extended, BOOL upright);
ICLASS_EXPORT void ICLASS_API ReleaseSURF(TSURF* ex); ICLASS_EXPORT void ICLASS_API ReleaseSURF(TSURF* ex);
ICLASS_EXPORT TCVectorKeyPoint* ICLASS_API CreateCVectorKeyPoint(); ICLASS_EXPORT TCVectorKeyPoint* ICLASS_API CreateCVectorKeyPoint();
ICLASS_EXPORT void ICLASS_API ReleaseCVectorKeyPoint(TCVectorKeyPoint* ex); ICLASS_EXPORT void ICLASS_API ReleaseCVectorKeyPoint(TCVectorKeyPoint* ex);
@ -53,4 +52,43 @@ ICLASS_EXPORT void ICLASS_API DrawMatches(
ICLASS_EXPORT TSIFT* ICLASS_API CreateSIFT(int nfeatures = 0, int nOctaveLayers = 3, ICLASS_EXPORT TSIFT* ICLASS_API CreateSIFT(int nfeatures = 0, int nOctaveLayers = 3,
double contrastThreshold = 0.04, double edgeThreshold = 10, double contrastThreshold = 0.04, double edgeThreshold = 10,
double sigma = 1.6); double sigma = 1.6);
ICLASS_EXPORT void ICLASS_API ReleaseSIFT(TSIFT* ex); ICLASS_EXPORT void ICLASS_API ReleaseSIFT(TSIFT* ex);
ICLASS_EXPORT TBRISK* ICLASS_API CreateBRISK(int thresh = 30, int octaves = 3, float patternScale = 1.0f);
ICLASS_EXPORT void ICLASS_API ReleaseBRISK(TBRISK* ex);
ICLASS_EXPORT TORB* ICLASS_API CreateORB(int nfeatures = 500, float scaleFactor = 1.2f, int nlevels = 8, int edgeThreshold = 31,
int firstLevel = 0, int WTA_K = 2, int scoreType = ORB::HARRIS_SCORE, int patchSize = 31);
ICLASS_EXPORT void ICLASS_API ReleaseORB(TORB* ex);
ICLASS_EXPORT TFREAK* ICLASS_API CreateFREAK(BOOL orientationNormalized = true,
BOOL scaleNormalized = true,
float patternScale = 22.0f,
int nOctaves = 4);
ICLASS_EXPORT void ICLASS_API ReleaseFREAK(TFREAK* ex);
ICLASS_EXPORT TMSER* ICLASS_API CreateMSER(int _delta = 5, int _min_area = 60, int _max_area = 14400,
double _max_variation = 0.25, double _min_diversity = .2,
int _max_evolution = 200, double _area_threshold = 1.01,
double _min_margin = 0.003, int _edge_blur_size = 5);
ICLASS_EXPORT void ICLASS_API ReleaseMSER(TMSER* ex);
ICLASS_EXPORT TStarDetector* ICLASS_API CreateStarDetector(int _maxSize = 45, int _responseThreshold = 30,
int _lineThresholdProjected = 10,
int _lineThresholdBinarized = 8,
int _suppressNonmaxSize = 5);
ICLASS_EXPORT void ICLASS_API ReleaseStarDetector(TStarDetector* ex);
ICLASS_EXPORT TFastFeatureDetector* ICLASS_API CreateFastFeatureDetector(int threshold = 10, BOOL nonmaxSuppression = true);
ICLASS_EXPORT void ICLASS_API ReleaseFastFeatureDetector(TFastFeatureDetector* ex);
ICLASS_EXPORT TGFTTDetector* ICLASS_API CreateGFTTDetector(int maxCorners = 1000, double qualityLevel = 0.01, double minDistance = 1,
int blockSize = 3, BOOL useHarrisDetector = false, double k = 0.04);
ICLASS_EXPORT void ICLASS_API ReleaseGFTTDetector(TGFTTDetector* ex);
ICLASS_EXPORT TSimpleBlobDetector* ICLASS_API CreateSimpleBlobDetector(TSimpleBlobDetectorParams SimpleBlobDetectorParams);
ICLASS_EXPORT TSimpleBlobDetector* ICLASS_API CreateSimpleBlobDetectorDefault();
ICLASS_EXPORT void ICLASS_API ReleaseSimpleBlobDetector(TSimpleBlobDetector* ex);
ICLASS_EXPORT TDenseFeatureDetector* ICLASS_API CreateDenseFeatureDetector(float initFeatureScale = 1.f, int featureScaleLevels = 1,
float featureScaleMul = 0.1f,
int initXyStep = 6, int initImgBound = 0,
BOOL varyXyStepWithScale = true,
BOOL varyImgBoundWithScale = false);
ICLASS_EXPORT void ICLASS_API ReleaseDenseFeatureDetector(TDenseFeatureDetector* ex);
ICLASS_EXPORT TBriefDescriptorExtractor* ICLASS_API CreateBriefDescriptorExtractor(int bytes = 32);
ICLASS_EXPORT void ICLASS_API ReleaseBriefDescriptorExtractor(TBriefDescriptorExtractor* ex);
ICLASS_EXPORT TFlannBasedMatcher* ICLASS_API CreateFlannBasedMatcher();
ICLASS_EXPORT void ICLASS_API ReleaseFlannBasedMatcher(TFlannBasedMatcher* ex);