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

Commit 410e37b

Browse files
committed
ADD: BFMatcher
1 parent 4abd1bc commit 410e37b

File tree

4 files changed

+74
-1
lines changed

4 files changed

+74
-1
lines changed

binding.gyp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@
9191
"cc/modules/features2d/KeyPoint.cc",
9292
"cc/modules/features2d/KeyPointMatch.cc",
9393
"cc/modules/features2d/DescriptorMatch.cc",
94+
"cc/modules/features2d/BFMatcher.cc",
9495
"cc/modules/features2d/FeatureDetector.cc",
9596
"cc/modules/features2d/descriptorMatching.cc",
9697
"cc/modules/features2d/descriptorMatchingKnn.cc",

cc/modules/features2d/BFMatcher.cc

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#include "BFMatcher.h"
2+
3+
Nan::Persistent<v8::FunctionTemplate> BFMatcher::constructor;
4+
5+
NAN_MODULE_INIT(BFMatcher::Init) {
6+
v8::Local<v8::FunctionTemplate> ctor = Nan::New<v8::FunctionTemplate>(BFMatcher::New);
7+
constructor.Reset(ctor);
8+
ctor->InstanceTemplate()->SetInternalFieldCount(1);
9+
ctor->SetClassName(Nan::New("BFMatcher").ToLocalChecked());
10+
11+
Nan::SetAccessor(ctor->InstanceTemplate(), Nan::New("normType").ToLocalChecked(), GetNormType);
12+
Nan::SetAccessor(ctor->InstanceTemplate(), Nan::New("crossCheck").ToLocalChecked(), GetCrossCheck);
13+
14+
target->Set(Nan::New("BFMatcher").ToLocalChecked(), ctor->GetFunction());
15+
};
16+
17+
NAN_METHOD(BFMatcher::New) {
18+
FF_METHOD_CONTEXT("BFMatcher::New");
19+
BFMatcher* self = new BFMatcher();
20+
if (info.Length() > 0) {
21+
FF_ARG_INT(0, int normType);
22+
FF_ARG_INT(1, bool crossCheck);
23+
24+
self->bfmatcher = cv::BFMatcher(normType, crossCheck);
25+
}
26+
self->Wrap(info.Holder());
27+
info.GetReturnValue().Set(info.Holder());
28+
}
29+
30+
NAN_METHOD(BFMatcher::Clone) {
31+
GaussianBlurWorker worker(Mat::Converter::unwrap(info.This()));
32+
FF_WORKER_SYNC("Mat::GaussianBlur", worker);
33+
info.GetReturnValue().Set(worker.getReturnValue());
34+
}

cc/modules/features2d/BFMatcher.h

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#include "macros.h"
2+
#include "NativeNodeUtils.h"
3+
#include <opencv2/features2d.hpp>
4+
5+
#ifndef FF_BFMATCHER_H_
6+
#define FF_BFMATCHER_H_
7+
8+
class BFMatcher : public Nan::ObjectWrap {
9+
public:
10+
cv::BFMatcher BFMatcher;
11+
12+
static NAN_MODULE_INIT(Init);
13+
static NAN_METHOD(New);
14+
15+
static FF_GETTER(BFMatcher, GetNormType, bfmatcher.normType)
16+
static FF_GETTER(BFMatcher, GetCrossCheck, bfmatcher.crossCheck)
17+
18+
static Nan::Persistent<v8::FunctionTemplate> constructor;
19+
20+
cv::DMatch* getNativeObjectPtr() { return &bfmatcher; }
21+
cv::DMatch getNativeObject() { return bfmatcher; }
22+
23+
typedef InstanceConverter<BFMatcher, cv::BFMatcher> Converter;
24+
25+
static NAN_METHOD(Clone);
26+
static NAN_METHOD(Create);
27+
static NAN_METHOD(IsMaskSupported);
28+
static NAN_METHOD(KnnMatchImpl);
29+
static NAN_METHOD(RadiusMatchImpl);
30+
31+
static const char* getClassName() {
32+
return "BFMatcher";
33+
}
34+
35+
}
36+
37+
#endif

cc/modules/features2d/features2d.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#include "KeyPoint.h"
33
#include "KeyPointMatch.h"
44
#include "DescriptorMatch.h"
5+
#include "BFMatcher.h"
56
#include "descriptorMatching.h"
67
#include "descriptorMatchingKnn.h"
78
#include "detectors/AGASTDetector.h"
@@ -102,4 +103,4 @@ NAN_METHOD(Features2d::DrawMatches) {
102103
FF_OBJ jsMat = FF_NEW_INSTANCE(Mat::constructor);
103104
cv::drawMatches(img1, kps1, img2, kps2, dMatches, FF_UNWRAP_MAT_AND_GET(jsMat));
104105
FF_RETURN(jsMat);
105-
}
106+
}

0 commit comments

Comments
 (0)