forked from udarrr/opencv4nodejs-prebuilt-install
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBFMatcherBindings.h
68 lines (51 loc) · 1.75 KB
/
BFMatcherBindings.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#include "BFMatcher.h"
#include "DescriptorMatch.h"
#ifndef __FF_BFMATCHERBINDINGS_H_
#define __FF_BFMATCHERBINDINGS_H_
namespace BFMatcherBindings {
struct MatchWorker : public CatchCvExceptionWorker {
public:
cv::BFMatcher bfmatcher;
MatchWorker(cv::BFMatcher _bfmatcher) {
this->bfmatcher = _bfmatcher;
}
cv::Mat descFrom;
cv::Mat descTo;
std::vector<cv::DMatch> dmatches;
std::string executeCatchCvExceptionWorker() {
bfmatcher.match(descFrom, descTo, dmatches);
return "";
}
bool unwrapRequiredArgs(Nan::NAN_METHOD_ARGS_TYPE info) {
return Mat::Converter::arg(0, &descFrom, info)
|| Mat::Converter::arg(1, &descTo, info);
}
v8::Local<v8::Value> getReturnValue() {
return DescriptorMatch::ArrayConverter::wrap(dmatches);
}
};
struct MatchKnnWorker : public CatchCvExceptionWorker {
public:
cv::BFMatcher bfmatcher;
MatchKnnWorker(cv::BFMatcher _bfmatcher) {
this->bfmatcher = _bfmatcher;
}
cv::Mat descFrom;
cv::Mat descTo;
int k;
std::vector<std::vector<cv::DMatch>> dmatches;
std::string executeCatchCvExceptionWorker() {
bfmatcher.knnMatch(descFrom, descTo, dmatches, k);
return "";
}
bool unwrapRequiredArgs(Nan::NAN_METHOD_ARGS_TYPE info) {
return Mat::Converter::arg(0, &descFrom, info)
|| Mat::Converter::arg(1, &descTo, info)
|| FF::IntConverter::arg(2, &k, info);
}
v8::Local<v8::Value> getReturnValue() {
return DescriptorMatch::ArrayOfArraysConverter::wrap(dmatches);
}
};
}
#endif