add Matrix.prototype.mul

This commit is contained in:
Pierre Colle 2017-08-31 15:53:45 +02:00
parent 688d721465
commit 2754367628
2 changed files with 25 additions and 2 deletions

View File

@ -116,6 +116,7 @@ void Matrix::Init(Local<Object> target) {
Nan::SetPrototypeMethod(ctor, "reshape", Reshape);
Nan::SetPrototypeMethod(ctor, "release", Release);
Nan::SetPrototypeMethod(ctor, "subtract", Subtract);
Nan::SetPrototypeMethod(ctor, "mul", Mul);
target->Set(Nan::New("Matrix").ToLocalChecked(), ctor->GetFunction());
};
@ -1936,6 +1937,8 @@ NAN_METHOD(Matrix::WarpAffine) {
int dstCols = info[2]->IsUndefined() ? self->mat.cols : info[2]->Uint32Value();
cv::Size resSize = cv::Size(dstRows, dstCols);
printf("dstRows %i", dstRows);
cv::warpAffine(self->mat, res, rotMatrix->mat, resSize);
~self->mat;
self->mat = res;
@ -2835,3 +2838,22 @@ NAN_METHOD(Matrix::Subtract) {
return;
}
NAN_METHOD(Matrix::Mul) {
SETUP_FUNCTION(Matrix)
if (info.Length() < 1) {
Nan::ThrowTypeError("Invalid number of arguments");
}
Matrix *other = Nan::ObjectWrap::Unwrap<Matrix>(info[0]->ToObject());
cv::Mat res = self->mat.mul(other->mat);
Local<Object> out = Nan::NewInstance(Nan::GetFunction(Nan::New(Matrix::constructor)).ToLocalChecked()).ToLocalChecked();
Matrix *m_out = Nan::ObjectWrap::Unwrap<Matrix>(out);
m_out->mat = res;
info.GetReturnValue().Set(out);
return;
}

View File

@ -134,6 +134,7 @@ public:
JSFUNC(Release)
JSFUNC(Subtract)
JSFUNC(Mul)
/*
static Handle<Value> Val(const Arguments& info);
static Handle<Value> RowRange(const Arguments& info);