mirror of
https://github.com/peterbraden/node-opencv.git
synced 2025-12-08 19:45:55 +00:00
Merge pull request #343 from jainanshul/rotation_matrix
Make GetRotationMatrix2D static
This commit is contained in:
commit
6e2552825c
@ -48,7 +48,6 @@ void Matrix::Init(Local<Object> target) {
|
|||||||
Nan::SetPrototypeMethod(ctor, "saveAsync", SaveAsync);
|
Nan::SetPrototypeMethod(ctor, "saveAsync", SaveAsync);
|
||||||
Nan::SetPrototypeMethod(ctor, "resize", Resize);
|
Nan::SetPrototypeMethod(ctor, "resize", Resize);
|
||||||
Nan::SetPrototypeMethod(ctor, "rotate", Rotate);
|
Nan::SetPrototypeMethod(ctor, "rotate", Rotate);
|
||||||
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, "convertTo", ConvertTo);
|
||||||
@ -101,6 +100,7 @@ void Matrix::Init(Local<Object> target) {
|
|||||||
Nan::SetMethod(ctor, "Zeros", Zeros);
|
Nan::SetMethod(ctor, "Zeros", Zeros);
|
||||||
Nan::SetMethod(ctor, "Ones", Ones);
|
Nan::SetMethod(ctor, "Ones", Ones);
|
||||||
Nan::SetMethod(ctor, "Eye", Eye);
|
Nan::SetMethod(ctor, "Eye", Eye);
|
||||||
|
Nan::SetMethod(ctor, "getRotationMatrix2D", GetRotationMatrix2D);
|
||||||
Nan::SetPrototypeMethod(ctor, "copyWithMask", CopyWithMask);
|
Nan::SetPrototypeMethod(ctor, "copyWithMask", CopyWithMask);
|
||||||
Nan::SetPrototypeMethod(ctor, "setWithMask", SetWithMask);
|
Nan::SetPrototypeMethod(ctor, "setWithMask", SetWithMask);
|
||||||
Nan::SetPrototypeMethod(ctor, "meanWithMask", MeanWithMask);
|
Nan::SetPrototypeMethod(ctor, "meanWithMask", MeanWithMask);
|
||||||
@ -1625,24 +1625,23 @@ NAN_METHOD(Matrix::Rotate) {
|
|||||||
|
|
||||||
NAN_METHOD(Matrix::GetRotationMatrix2D) {
|
NAN_METHOD(Matrix::GetRotationMatrix2D) {
|
||||||
Nan::HandleScope scope;
|
Nan::HandleScope scope;
|
||||||
|
if (info.Length() < 3) {
|
||||||
Matrix *self = Nan::ObjectWrap::Unwrap<Matrix>(info.This());
|
JSTHROW("Invalid number of arguments");
|
||||||
cv::Mat res;
|
}
|
||||||
|
|
||||||
float angle = info[0]->ToNumber()->Value();
|
float angle = info[0]->ToNumber()->Value();
|
||||||
int x = info[1]->IsUndefined() ? round(self->mat.size().width / 2) :
|
int x = info[1]->Uint32Value();
|
||||||
info[1]->Uint32Value();
|
int y = info[2]->Uint32Value();
|
||||||
int y = info[2]->IsUndefined() ? round(self->mat.size().height / 2) :
|
|
||||||
info[2]->Uint32Value();
|
|
||||||
double scale = info[3]->IsUndefined() ? 1.0 : info[3]->NumberValue();
|
double scale = info[3]->IsUndefined() ? 1.0 : info[3]->NumberValue();
|
||||||
|
|
||||||
|
Local<Object> img_to_return =
|
||||||
|
Nan::New(Matrix::constructor)->GetFunction()->NewInstance();
|
||||||
|
Matrix *img = Nan::ObjectWrap::Unwrap<Matrix>(img_to_return);
|
||||||
|
|
||||||
cv::Point center = cv::Point(x,y);
|
cv::Point center = cv::Point(x,y);
|
||||||
res = getRotationMatrix2D(center, angle, scale);
|
img->mat = getRotationMatrix2D(center, angle, scale);
|
||||||
|
|
||||||
~self->mat;
|
info.GetReturnValue().Set(img_to_return);
|
||||||
self->mat = res;
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
NAN_METHOD(Matrix::WarpAffine) {
|
NAN_METHOD(Matrix::WarpAffine) {
|
||||||
|
|||||||
@ -112,6 +112,10 @@ test('Matrix functions', function(assert) {
|
|||||||
assert.equal(matNew.height(), 1);
|
assert.equal(matNew.height(), 1);
|
||||||
assert.equal(matNew.width(), 5625);
|
assert.equal(matNew.width(), 5625);
|
||||||
|
|
||||||
|
// GetRotationMatrix2D
|
||||||
|
mat = cv.Matrix.getRotationMatrix2D(0, 0, 90, 1.0);
|
||||||
|
assert.deepEqual(mat.size(), [2,3], 'GetRotationMatrix2D');
|
||||||
|
|
||||||
assert.end();
|
assert.end();
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user