wrap add function

This commit is contained in:
Pierre Colle 2016-11-09 10:20:33 +01:00
parent fe2b18e0a7
commit 430976cb1a
2 changed files with 26 additions and 1 deletions

View File

@ -68,6 +68,7 @@ void Matrix::Init(Local<Object> target) {
Nan::SetPrototypeMethod(ctor, "dct", Dct);
Nan::SetPrototypeMethod(ctor, "idct", Idct);
Nan::SetPrototypeMethod(ctor, "addWeighted", AddWeighted);
Nan::SetPrototypeMethod(ctor, "add", Add);
Nan::SetPrototypeMethod(ctor, "bitwiseXor", BitwiseXor);
Nan::SetPrototypeMethod(ctor, "bitwiseNot", BitwiseNot);
Nan::SetPrototypeMethod(ctor, "bitwiseAnd", BitwiseAnd);
@ -1342,6 +1343,29 @@ NAN_METHOD(Matrix::AddWeighted) {
info.GetReturnValue().Set(Nan::Null());
}
NAN_METHOD(Matrix::Add) {
Nan::HandleScope scope;
Matrix *self = Nan::ObjectWrap::Unwrap<Matrix>(info.This());
int cols = self->mat.cols;
int rows = self->mat.rows;
Matrix *src1 = Nan::ObjectWrap::Unwrap<Matrix>(info[0]->ToObject());
Local<Object> out = Nan::New(Matrix::constructor)->GetFunction()->NewInstance();
Matrix *m_out = Nan::ObjectWrap::Unwrap<Matrix>(out);
m_out->mat.create(cols, rows, self->mat.type());
try {
cv::add(self->mat, src1->mat, m_out->mat);
} catch(cv::Exception& e ) {
const char* err_msg = e.what();
Nan::ThrowError(err_msg);
}
info.GetReturnValue().Set(out);
}
NAN_METHOD(Matrix::BitwiseXor) {
Nan::HandleScope scope;

View File

@ -69,8 +69,9 @@ public:
JSFUNC(Ptr)
JSFUNC(AbsDiff)
JSFUNC(Dct)
JSFUNC(Idct)
JSFUNC(Idct)
JSFUNC(AddWeighted)
JSFUNC(Add)
JSFUNC(BitwiseXor)
JSFUNC(BitwiseNot)
JSFUNC(BitwiseAnd)