Skip to content

Commit 08762da

Browse files
fix version 3.0, 3.1, 3.3
1 parent 61bde49 commit 08762da

File tree

13 files changed

+89
-44
lines changed

13 files changed

+89
-44
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@ vs
33
.vscode
44
build
55
bin
6-
node_modules
6+
node_modules
7+
crash.log

.npmignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ vs
44
build
55
bin
66
node_modules
7+
crash.log
78

89
./data
910
./test

cc/index.cc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@
2222
#endif // HAVE_XFEATURES2D
2323

2424
void init(v8::Local<v8::Object> target) {
25+
v8::Local<v8::Object> version = Nan::New<v8::Object>();
26+
Nan::Set(version, FF_V8STRING("major"), Nan::New(CV_MAJOR_VERSION));
27+
Nan::Set(version, FF_V8STRING("minor"), Nan::New(CV_MINOR_VERSION));
28+
Nan::Set(target, FF_V8STRING("version"), version);
29+
2530
v8::Local<v8::Object> xmodules = Nan::New<v8::Object>();
2631
Nan::Set(target, FF_V8STRING("xmodules"), xmodules);
2732
CvTypes::Init(target);

cc/modules/features2d/FeatureDetector.cc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ NAN_METHOD(FeatureDetector::Detect) {
1111
cv::Mat mat = FF_UNWRAP_MAT_AND_GET(info[0]->ToObject());
1212
std::vector<cv::KeyPoint> kps;
1313
FF_TRY(self->getDetector()->detect(mat, kps);)
14-
1514
v8::Local<v8::Array> jsKps = Nan::New<v8::Array>(kps.size());
1615
uint i = 0;
1716
for (auto kp : kps) {

cc/modules/features2d/descriptorMatching.cc

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,32 @@ NAN_MODULE_INIT(DescriptorMatching::Init) {
55
Nan::SetMethod(target, "matchBruteForce", MatchBruteForce);
66
Nan::SetMethod(target, "matchBruteForceL1", MatchBruteForceL1);
77
Nan::SetMethod(target, "matchBruteForceHamming", MatchBruteForceHamming);
8+
#if 2 <= CV_VERSION_MINOR
89
Nan::SetMethod(target, "matchBruteForceHammingLut", MatchBruteForceHammingLut);
910
Nan::SetMethod(target, "matchBruteForceSL2", MatchBruteForceSL2);
11+
#endif
1012
};
1113

14+
#if CV_VERSION_MINOR < 2
15+
16+
NAN_METHOD(DescriptorMatching::MatchFlannBased) {
17+
match(info, "FlannBased");
18+
}
19+
20+
NAN_METHOD(DescriptorMatching::MatchBruteForce) {
21+
match(info, "BruteForce");
22+
}
23+
24+
NAN_METHOD(DescriptorMatching::MatchBruteForceL1) {
25+
match(info, "BruteForce-L1");
26+
}
27+
28+
NAN_METHOD(DescriptorMatching::MatchBruteForceHamming) {
29+
match(info, "BruteForce-Hamming");
30+
}
31+
32+
#else
33+
1234
NAN_METHOD(DescriptorMatching::MatchFlannBased) {
1335
match(info, cv::DescriptorMatcher::FLANNBASED);
1436
}
@@ -33,7 +55,13 @@ NAN_METHOD(DescriptorMatching::MatchBruteForceSL2) {
3355
match(info, cv::DescriptorMatcher::BRUTEFORCE_SL2);
3456
}
3557

58+
#endif
59+
60+
#if CV_VERSION_MINOR < 2
61+
void DescriptorMatching::match(Nan::NAN_METHOD_ARGS_TYPE info, std::string matcherType) {
62+
#else
3663
void DescriptorMatching::match(Nan::NAN_METHOD_ARGS_TYPE info, int matcherType) {
64+
#endif
3765
if (!info[0]->IsObject() || !info[1]->IsObject()) {
3866
return Nan::ThrowError("required argument descriptorsFrom, descriptorsTo");
3967
}

cc/modules/features2d/descriptorMatching.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,11 @@ class DescriptorMatching : public Nan::ObjectWrap {
1818
static NAN_METHOD(MatchBruteForceHamming);
1919
static NAN_METHOD(MatchBruteForceHammingLut);
2020
static NAN_METHOD(MatchBruteForceSL2);
21-
21+
#if CV_VERSION_MINOR < 2
22+
static void match(Nan::NAN_METHOD_ARGS_TYPE info, std::string matcherType);
23+
#else
2224
static void match(Nan::NAN_METHOD_ARGS_TYPE info, int matcherType);
25+
#endif
2326
};
2427

2528
#endif

cc/modules/imgproc/imgproc.cc

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -174,17 +174,27 @@ NAN_METHOD(Imgproc::Plot1DHist) {
174174
NAN_METHOD(Imgproc::Canny) {
175175
FF_REQUIRE_ARGS_OBJ("Canny");
176176

177-
cv::Mat dx, dy;
178177
double threshold1, threshold2;
179-
FF_GET_JSOBJ_REQUIRED(args, dx, dx, Mat::constructor, FF_UNWRAP_MAT_AND_GET, Mat);
180-
FF_GET_JSOBJ_REQUIRED(args, dy, dy, Mat::constructor, FF_UNWRAP_MAT_AND_GET, Mat);
181178
FF_DESTRUCTURE_TYPECHECKED_JSPROP_REQUIRED(args, threshold1, IsNumber, NumberValue);
182179
FF_DESTRUCTURE_TYPECHECKED_JSPROP_REQUIRED(args, threshold2, IsNumber, NumberValue);
183180

184181
bool L2gradient = false;
185182
FF_DESTRUCTURE_TYPECHECKED_JSPROP_IFDEF(args, L2gradient, IsBoolean, BooleanValue);
186183

187184
v8::Local<v8::Object> jsMat = FF_NEW(Mat::constructor);
185+
186+
#if CV_VERSION_MINOR < 2
187+
cv::Mat image;
188+
FF_GET_JSOBJ_REQUIRED(args, image, image, Mat::constructor, FF_UNWRAP_MAT_AND_GET, Mat);
189+
int apertureSize = 3;
190+
FF_DESTRUCTURE_TYPECHECKED_JSPROP_REQUIRED(args, apertureSize, IsUint32, Uint32Value);
191+
cv::Canny(image, FF_UNWRAP_MAT_AND_GET(jsMat), threshold1, threshold2, apertureSize, L2gradient);
192+
#else
193+
cv::Mat dx, dy;
194+
FF_GET_JSOBJ_REQUIRED(args, dx, dx, Mat::constructor, FF_UNWRAP_MAT_AND_GET, Mat);
195+
FF_GET_JSOBJ_REQUIRED(args, dy, dy, Mat::constructor, FF_UNWRAP_MAT_AND_GET, Mat);
188196
cv::Canny(dx, dy, FF_UNWRAP_MAT_AND_GET(jsMat), threshold1, threshold2, L2gradient);
197+
#endif
198+
189199
info.GetReturnValue().Set(jsMat);
190-
}
200+
}

test/cc/core/Mat/Mat.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,7 @@ describe('Mat', () => {
183183
});
184184
});
185185

186+
// TODO figure out whats wrong with 3.3.0
186187
it('should normalize range of CV_64F', () => {
187188
const mat = new Mat([
188189
[0.5, 1000.12345, 1000],

test/cc/modules/calib3d.js

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -22,29 +22,5 @@ describe('calib3d', () => {
2222
const homography = calib3d.findHomography({ srcPoints, dstPoints });
2323
assertPropsWithValue(homography)({ type: cvTypes.CV_64F, rows: 3, cols: 3 });
2424
});
25-
26-
/*
27-
it('should catch cv exception if set of points is empty', () => {
28-
let errMsg = '';
29-
try {
30-
calib3d.findHomography({ srcPoints: [], dstPoints: [] });
31-
} catch (err) {
32-
errMsg = err.toString();
33-
}
34-
assert.include(errMsg, 'findHomography');
35-
});
36-
37-
it('should catch cv exception if number of points mismatch', () => {
38-
const srcPoints = [{ x: 0, y: 0 }, { x: 1000, y: 0 }];
39-
const dstPoints = [{ x: 0, y: 0 }];
40-
let errMsg = '';
41-
try {
42-
calib3d.findHomography({ srcPoints, dstPoints });
43-
} catch (err) {
44-
errMsg = err.toString();
45-
}
46-
assert.include(errMsg, 'findHomography');
47-
});
48-
*/
4925
});
5026
});

test/cc/modules/detectorTests.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@ import opencv from 'dut';
22
import { assert, expect } from 'chai';
33
import { assertError, assertPropsWithValue, readTestImage } from 'utils';
44

5-
// TODO test return values of compute, detect
6-
75
exports.detectorTests = (defaults, customProps, Detector, implementsCompute = true) => {
86
let testImg;
97
let keyPoints;

0 commit comments

Comments
 (0)