mirror of
https://github.com/peterbraden/node-opencv.git
synced 2025-12-08 19:45:55 +00:00
Merge pull request #395 from andreasgal/subtract
add subtract() to Matrix
This commit is contained in:
commit
a3db0acb0a
@ -109,6 +109,7 @@ void Matrix::Init(Local<Object> target) {
|
|||||||
Nan::SetPrototypeMethod(ctor, "shift", Shift);
|
Nan::SetPrototypeMethod(ctor, "shift", Shift);
|
||||||
Nan::SetPrototypeMethod(ctor, "reshape", Reshape);
|
Nan::SetPrototypeMethod(ctor, "reshape", Reshape);
|
||||||
Nan::SetPrototypeMethod(ctor, "release", Release);
|
Nan::SetPrototypeMethod(ctor, "release", Release);
|
||||||
|
Nan::SetPrototypeMethod(ctor, "subtract", Subtract);
|
||||||
|
|
||||||
target->Set(Nan::New("Matrix").ToLocalChecked(), ctor->GetFunction());
|
target->Set(Nan::New("Matrix").ToLocalChecked(), ctor->GetFunction());
|
||||||
};
|
};
|
||||||
@ -2569,3 +2570,17 @@ NAN_METHOD(Matrix::Release) {
|
|||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NAN_METHOD(Matrix::Subtract) {
|
||||||
|
SETUP_FUNCTION(Matrix)
|
||||||
|
|
||||||
|
if (info.Length() < 1) {
|
||||||
|
Nan::ThrowTypeError("Invalid number of arguments");
|
||||||
|
}
|
||||||
|
|
||||||
|
Matrix *other = Nan::ObjectWrap::Unwrap<Matrix>(info[0]->ToObject());
|
||||||
|
|
||||||
|
self->mat -= other->mat;
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|||||||
@ -125,6 +125,8 @@ public:
|
|||||||
JSFUNC(Reshape)
|
JSFUNC(Reshape)
|
||||||
|
|
||||||
JSFUNC(Release)
|
JSFUNC(Release)
|
||||||
|
|
||||||
|
JSFUNC(Subtract)
|
||||||
/*
|
/*
|
||||||
static Handle<Value> Val(const Arguments& info);
|
static Handle<Value> Val(const Arguments& info);
|
||||||
static Handle<Value> RowRange(const Arguments& info);
|
static Handle<Value> RowRange(const Arguments& info);
|
||||||
|
|||||||
@ -341,6 +341,15 @@ test('Native Matrix', function(assert) {
|
|||||||
assert.end();
|
assert.end();
|
||||||
})
|
})
|
||||||
|
|
||||||
|
test('Subtract', function(assert) {
|
||||||
|
var a = new cv.Matrix.Zeros(1,1);
|
||||||
|
a.set(0, 0, 3);
|
||||||
|
var b = new cv.Matrix.Zeros(1,1);
|
||||||
|
b.set(0, 0, 1);
|
||||||
|
a.subtract(b);
|
||||||
|
assert.deepEqual(a.get(0, 0), 2);
|
||||||
|
assert.end();
|
||||||
|
});
|
||||||
|
|
||||||
// Test the examples folder.
|
// Test the examples folder.
|
||||||
require('./examples')()
|
require('./examples')()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user