mirror of
https://github.com/peterbraden/node-opencv.git
synced 2025-12-08 19:45:55 +00:00
Added Zeros, Ones constructors
This commit is contained in:
parent
dcf6ae4571
commit
ee3ae4c196
@ -108,6 +108,8 @@ Matrix::Init(Handle<Object> target) {
|
||||
NODE_SET_PROTOTYPE_METHOD(constructor, "getPerspectiveTransform", GetPerspectiveTransform);
|
||||
NODE_SET_PROTOTYPE_METHOD(constructor, "warpPerspective", WarpPerspective);
|
||||
|
||||
NODE_SET_METHOD(constructor, "Zeros", Zeros);
|
||||
NODE_SET_METHOD(constructor, "Ones", Ones);
|
||||
NODE_SET_METHOD(constructor, "Eye", Eye);
|
||||
|
||||
NODE_SET_PROTOTYPE_METHOD(constructor, "copyWithMask", CopyWithMask);
|
||||
@ -820,6 +822,37 @@ void AfterSaveAsync(uv_work_t *req) {
|
||||
delete baton;
|
||||
}
|
||||
|
||||
Handle<Value>
|
||||
Matrix::Zeros(const v8::Arguments& args){
|
||||
HandleScope scope;
|
||||
|
||||
int w = args[0]->Uint32Value();
|
||||
int h = args[1]->Uint32Value();
|
||||
int type = (args.Length() > 2) ? args[2]->IntegerValue() : CV_64FC1;
|
||||
|
||||
Local<Object> im_h = Matrix::constructor->GetFunction()->NewInstance();
|
||||
Matrix *img = ObjectWrap::Unwrap<Matrix>(im_h);
|
||||
cv::Mat mat = cv::Mat::zeros(w, h, type);
|
||||
|
||||
img->mat = mat;
|
||||
return scope.Close(im_h);
|
||||
}
|
||||
|
||||
Handle<Value>
|
||||
Matrix::Ones(const v8::Arguments& args){
|
||||
HandleScope scope;
|
||||
|
||||
int w = args[0]->Uint32Value();
|
||||
int h = args[1]->Uint32Value();
|
||||
int type = (args.Length() > 2) ? args[2]->IntegerValue() : CV_64FC1;
|
||||
|
||||
Local<Object> im_h = Matrix::constructor->GetFunction()->NewInstance();
|
||||
Matrix *img = ObjectWrap::Unwrap<Matrix>(im_h);
|
||||
cv::Mat mat = cv::Mat::ones(w, h, type);
|
||||
|
||||
img->mat = mat;
|
||||
return scope.Close(im_h);
|
||||
}
|
||||
|
||||
Handle<Value>
|
||||
Matrix::Eye(const v8::Arguments& args){
|
||||
@ -827,16 +860,16 @@ Matrix::Eye(const v8::Arguments& args){
|
||||
|
||||
int w = args[0]->Uint32Value();
|
||||
int h = args[1]->Uint32Value();
|
||||
int type = (args.Length() > 2) ? args[2]->IntegerValue() : CV_64FC1;
|
||||
|
||||
Local<Object> im_h = Matrix::constructor->GetFunction()->NewInstance();
|
||||
Matrix *img = ObjectWrap::Unwrap<Matrix>(im_h);
|
||||
cv::Mat mat = cv::Mat::eye(w, h, CV_64FC1);
|
||||
cv::Mat mat = cv::Mat::eye(w, h, type);
|
||||
|
||||
img->mat = mat;
|
||||
return scope.Close(im_h);
|
||||
}
|
||||
|
||||
|
||||
Handle<Value>
|
||||
Matrix::ConvertGrayscale(const v8::Arguments& args) {
|
||||
HandleScope scope;
|
||||
|
||||
@ -14,6 +14,8 @@ class Matrix: public node::ObjectWrap {
|
||||
|
||||
static double DblGet(cv::Mat mat, int i, int j);
|
||||
|
||||
JSFUNC(Zeros) // factory
|
||||
JSFUNC(Ones) // factory
|
||||
JSFUNC(Eye) // factory
|
||||
|
||||
JSFUNC(Get) // at
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user