Skip to content
This repository was archived by the owner on Oct 18, 2023. It is now read-only.

Commit 903afa4

Browse files
committed
ADD: BFMatcher to features2d to be detected
Small changes to BFMatcher
1 parent 45fbd39 commit 903afa4

File tree

4 files changed

+31
-24
lines changed

4 files changed

+31
-24
lines changed

cc/modules/features2d/BFMatcher.cc

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,22 @@ NAN_MODULE_INIT(BFMatcher::Init) {
66
v8::Local<v8::FunctionTemplate> ctor = Nan::New<v8::FunctionTemplate>(BFMatcher::New);
77
v8::Local<v8::ObjectTemplate> instanceTemplate = ctor->InstanceTemplate();
88

9-
BFMatcher::Init(ctor);
109
constructor.Reset(ctor);
1110
instanceTemplate->SetInternalFieldCount(1);
1211

13-
// ctor->SetClassName(Nan::New("BFMatcher").ToLocalChecked());
14-
ctor->SetClassName(FF_NEW_STRING("BFMatcher"));
12+
ctor->SetClassName(Nan::New("BFMatcher").ToLocalChecked());
13+
// ctor->SetClassName(FF_NEW_STRING("BFMatcher"));
1514

1615

1716
Nan::SetAccessor(instanceTemplate, Nan::New("normType").ToLocalChecked(), BFMatcher::GetNormType);
1817
Nan::SetAccessor(instanceTemplate, Nan::New("crossCheck").ToLocalChecked(), BFMatcher::GetCrossCheck);
1918

20-
// target->Set(Nan::New("BFMatcher").ToLocalChecked(), ctor->GetFunction());
21-
target->Set(FF_NEW_STRING("CascadeClassifier"), ctor->GetFunction());
19+
// Nan::SetPrototypeMethod(ctor, "create", create);
20+
21+
22+
target->Set(Nan::New("BFMatcher").ToLocalChecked(), ctor->GetFunction());
23+
// target->Set(FF_NEW_STRING("BFMatcher"), ctor->GetFunction());
24+
2225
};
2326

2427
NAN_METHOD(BFMatcher::New) {
@@ -29,18 +32,21 @@ NAN_METHOD(BFMatcher::New) {
2932
bool hasOptArgsObj = FF_HAS_ARG(0) && info[0]->IsObject();
3033
FF_OBJ optArgs = hasOptArgsObj ? info[0]->ToObject() : FF_NEW_OBJ();
3134

32-
FF_GET_NUMBER_IFDEF(optArgs, double normType, "normType", cv::NORM_L2);
33-
FF_GET_BOOL_IFDEF(optArgs, bool crossCheck, "crossCheck", false);
35+
FF_GET_NUMBER_IFDEF(optArgs, self->normType, "normType", cv::NORM_L2);
36+
FF_GET_BOOL_IFDEF(optArgs, self->crossCheck, "crossCheck", false);
3437

3538
if (!hasOptArgsObj) {
36-
FF_ARG_NUMBER_IFDEF(0, normType, normType);
37-
FF_ARG_INT_IFDEF(1, crossCheck, crossCheck);
39+
FF_ARG_INT_IFDEF(0, self->normType, self->normType);
40+
FF_ARG_BOOL_IFDEF(1, self->crossCheck, self->crossCheck);
3841
}
3942

4043
self->Wrap(info.Holder());
41-
self->bfmatcher = cv::BFMatcher::create(
42-
normType,
43-
crossCheck
44+
self->bfmatcher = cv::BFMatcher(
45+
self->normType,
46+
self->crossCheck
4447
);
45-
FF_RETURN(info.Holder());
48+
49+
info.GetReturnValue().Set(info.Holder());
4650
}
51+
52+

cc/modules/features2d/BFMatcher.h

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
#include "NativeNodeUtils.h"
33
#include <opencv2/features2d.hpp>
44

5-
#ifndef FF_BFMATCHER_H_
6-
#define FF_BFMATCHER_H_
5+
#ifndef __FF_BFMATCHER_H__
6+
#define __FF_BFMATCHER_H__
77

88
class BFMatcher : public Nan::ObjectWrap {
99
public:
@@ -12,9 +12,6 @@ class BFMatcher : public Nan::ObjectWrap {
1212
int normType;
1313
bool crossCheck;
1414

15-
static NAN_MODULE_INIT(Init);
16-
static NAN_METHOD(New);
17-
1815
static FF_GETTER(BFMatcher, GetNormType, normType)
1916
static FF_GETTER(BFMatcher, GetCrossCheck, crossCheck)
2017

@@ -25,11 +22,14 @@ class BFMatcher : public Nan::ObjectWrap {
2522

2623
typedef InstanceConverter<BFMatcher, cv::BFMatcher> Converter;
2724

28-
static NAN_METHOD(Clone);
29-
static NAN_METHOD(Create);
30-
static NAN_METHOD(IsMaskSupported);
31-
static NAN_METHOD(KnnMatchImpl);
32-
static NAN_METHOD(RadiusMatchImpl);
25+
static NAN_MODULE_INIT(Init);
26+
27+
static NAN_METHOD(New);
28+
// static NAN_METHOD(Clone);
29+
// static NAN_METHOD(Create);
30+
// static NAN_METHOD(IsMaskSupported);
31+
// static NAN_METHOD(KnnMatchImpl);
32+
// static NAN_METHOD(RadiusMatchImpl);
3333

3434
static const char* getClassName() {
3535
return "BFMatcher";

cc/modules/features2d/features2d.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ NAN_MODULE_INIT(Features2d::Init) {
2424
AGASTDetector::Init(target);
2525
AKAZEDetector::Init(target);
2626
BRISKDetector::Init(target);
27+
BFMatcher::Init(target);
2728
FASTDetector::Init(target);
2829
GFTTDetector::Init(target);
2930
KAZEDetector::Init(target);

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
"gypfile": true,
4040
"dependencies": {
4141
"macro-inferno": "^0.2.1",
42-
"nan": "^2.10.0",
42+
"nan": "^2.11.0",
4343
"native-node-utils": "0.1.2",
4444
"opencv-build": "0.0.14"
4545
},

0 commit comments

Comments
 (0)