Skip to content

Commit c328205

Browse files
Merge pull request #239 from pchmelar/master
return mask from findHomography
2 parents 8782a6a + 4827455 commit c328205

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

cc/modules/calib3d/calib3d.cc

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,19 +73,22 @@ NAN_METHOD(Calib3d::FindHomography) {
7373
FF_GET_UINT_IFDEF(optArgs, uint method, "method", 0);
7474
FF_GET_NUMBER_IFDEF(optArgs, double ransacReprojThreshold, "ransacReprojThreshold", 3);
7575
FF_GET_UINT_IFDEF(optArgs, uint maxIters, "maxIters", 2000);
76-
FF_GET_INSTANCE_IFDEF(optArgs, cv::Mat mask, "mask", Mat::constructor, FF_UNWRAP_MAT_AND_GET, Mat, cv::noArray().getMat())
7776
FF_GET_NUMBER_IFDEF(optArgs, double confidence, "confidence", 0.995);
7877
if (!hasOptArgsObj) {
7978
FF_ARG_UINT_IFDEF(2, method, method);
8079
FF_ARG_NUMBER_IFDEF(3, ransacReprojThreshold, ransacReprojThreshold);
8180
FF_ARG_UINT_IFDEF(4, maxIters, maxIters);
82-
FF_ARG_INSTANCE_IFDEF(5, mask, Mat::constructor, FF_UNWRAP_MAT_AND_GET, mask);
83-
FF_ARG_NUMBER_IFDEF(4, confidence, confidence);
81+
FF_ARG_NUMBER_IFDEF(5, confidence, confidence);
8482
}
8583

8684
FF_OBJ jsMat = FF_NEW_INSTANCE(Mat::constructor);
87-
FF_UNWRAP_MAT_AND_GET(jsMat) = cv::findHomography(srcPoints, dstPoints, method, ransacReprojThreshold, mask, maxIters, confidence);
88-
FF_RETURN(jsMat);
85+
FF_OBJ mask = FF_NEW_INSTANCE(Mat::constructor);
86+
FF_UNWRAP_MAT_AND_GET(jsMat) = cv::findHomography(srcPoints, dstPoints, method, ransacReprojThreshold, FF_UNWRAP_MAT_AND_GET(mask), maxIters, confidence);
87+
88+
v8::Local<v8::Object> output = Nan::New<v8::Object>();
89+
Nan::Set(output, Nan::New("homography").ToLocalChecked(), jsMat);
90+
Nan::Set(output, Nan::New("mask").ToLocalChecked(), mask);
91+
info.GetReturnValue().Set(output);
8992
}
9093

9194
struct Calib3d::ComposeRTWorker : public SimpleWorker {

test/tests/modules/calib3d.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@ describe('calib3d', () => {
6565
});
6666

6767
it('should calculate a valid homography', () => {
68-
const homography = cv.findHomography(srcPoints, dstPoints);
69-
assertPropsWithValue(homography)({ type: cv.CV_64F, rows: 3, cols: 3 });
68+
const output = cv.findHomography(srcPoints, dstPoints);
69+
assertPropsWithValue(output.homography)({ type: cv.CV_64F, rows: 3, cols: 3 });
7070
});
7171
});
7272

0 commit comments

Comments
 (0)