mirror of
https://github.com/peterbraden/node-opencv.git
synced 2025-12-08 19:45:55 +00:00
Add support for matrix convertTo function
This commit is contained in:
parent
85749436a6
commit
fa008d86a4
@ -51,6 +51,7 @@ void Matrix::Init(Local<Object> target) {
|
|||||||
Nan::SetPrototypeMethod(ctor, "getRotationMatrix2D", GetRotationMatrix2D);
|
Nan::SetPrototypeMethod(ctor, "getRotationMatrix2D", GetRotationMatrix2D);
|
||||||
Nan::SetPrototypeMethod(ctor, "warpAffine", WarpAffine);
|
Nan::SetPrototypeMethod(ctor, "warpAffine", WarpAffine);
|
||||||
Nan::SetPrototypeMethod(ctor, "copyTo", CopyTo);
|
Nan::SetPrototypeMethod(ctor, "copyTo", CopyTo);
|
||||||
|
Nan::SetPrototypeMethod(ctor, "convertTo", ConvertTo);
|
||||||
Nan::SetPrototypeMethod(ctor, "pyrDown", PyrDown);
|
Nan::SetPrototypeMethod(ctor, "pyrDown", PyrDown);
|
||||||
Nan::SetPrototypeMethod(ctor, "pyrUp", PyrUp);
|
Nan::SetPrototypeMethod(ctor, "pyrUp", PyrUp);
|
||||||
Nan::SetPrototypeMethod(ctor, "channels", Channels);
|
Nan::SetPrototypeMethod(ctor, "channels", Channels);
|
||||||
@ -1864,6 +1865,41 @@ NAN_METHOD(Matrix::CopyTo) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Converts an array to another data type with optional scaling
|
||||||
|
* Reference: http://docs.opencv.org/2.4/modules/core/doc/basic_structures.html#mat-convertto
|
||||||
|
*/
|
||||||
|
NAN_METHOD(Matrix::ConvertTo) {
|
||||||
|
SETUP_FUNCTION(Matrix)
|
||||||
|
|
||||||
|
if (info.Length() < 2) {
|
||||||
|
JSTHROW("Invalid number of arguments");
|
||||||
|
}
|
||||||
|
|
||||||
|
// param 0 - destination image
|
||||||
|
Matrix *dest = Nan::ObjectWrap::Unwrap<Matrix>(info[0]->ToObject());
|
||||||
|
|
||||||
|
// param 1 - desired matrix type
|
||||||
|
int rtype = -1;
|
||||||
|
INT_FROM_ARGS(rtype, 1);
|
||||||
|
|
||||||
|
// param 2 - alpha
|
||||||
|
double alpha = 1;
|
||||||
|
if (info.Length() >= 3) {
|
||||||
|
DOUBLE_FROM_ARGS(alpha, 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
// param 3 - beta
|
||||||
|
double beta = 0;
|
||||||
|
if (info.Length() >= 4) {
|
||||||
|
DOUBLE_FROM_ARGS(alpha, 3);
|
||||||
|
}
|
||||||
|
|
||||||
|
self->mat.convertTo(dest->mat, rtype, alpha, beta);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// @author SergeMv
|
// @author SergeMv
|
||||||
// Does in-place color transformation
|
// Does in-place color transformation
|
||||||
// img.cvtColor('CV_BGR2YCrCb');
|
// img.cvtColor('CV_BGR2YCrCb');
|
||||||
|
|||||||
@ -98,6 +98,7 @@ public:
|
|||||||
JSFUNC(MeanStdDev)
|
JSFUNC(MeanStdDev)
|
||||||
|
|
||||||
JSFUNC(CopyTo)
|
JSFUNC(CopyTo)
|
||||||
|
JSFUNC(ConvertTo)
|
||||||
JSFUNC(CvtColor)
|
JSFUNC(CvtColor)
|
||||||
JSFUNC(Split)
|
JSFUNC(Split)
|
||||||
JSFUNC(Merge)
|
JSFUNC(Merge)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user