mirror of
https://github.com/peterbraden/node-opencv.git
synced 2025-12-08 19:45:55 +00:00
Merge branch 'issue-150' of github.com:salmanulhaq/node-opencv
Conflicts: examples/convert_image.js
This commit is contained in:
commit
25c79cd653
@ -6,6 +6,7 @@ cv.readImage("./mona.png", function(err, im) {
|
||||
img_hsv = im.copy();
|
||||
img_gray = im.copy();
|
||||
|
||||
|
||||
img_hsv.convertHSVscale();
|
||||
img_gray.convertGrayscale();
|
||||
|
||||
@ -15,6 +16,9 @@ cv.readImage("./mona.png", function(err, im) {
|
||||
img_hsv.save("/tmp/hsv.png");
|
||||
img_gray.save("/tmp/gray.png");
|
||||
|
||||
img_crop = im.crop(50,50,250,250);
|
||||
img_crop.save("crop.png");
|
||||
|
||||
console.log("Guardado");
|
||||
});
|
||||
|
||||
|
||||
@ -55,6 +55,8 @@ Matrix::Init(Handle<Object> target) {
|
||||
NODE_SET_PROTOTYPE_METHOD(constructor, "pyrUp", PyrUp);
|
||||
NODE_SET_PROTOTYPE_METHOD(constructor, "channels", Channels);
|
||||
|
||||
NODE_SET_PROTOTYPE_METHOD(constructor, "crop", Crop);
|
||||
|
||||
NODE_SET_PROTOTYPE_METHOD(constructor, "convertGrayscale", ConvertGrayscale);
|
||||
NODE_SET_PROTOTYPE_METHOD(constructor, "convertHSVscale", ConvertHSVscale);
|
||||
NODE_SET_PROTOTYPE_METHOD(constructor, "gaussianBlur", GaussianBlur);
|
||||
@ -318,6 +320,31 @@ Matrix::Clone(const Arguments& args){
|
||||
return scope.Close(im_h);
|
||||
}
|
||||
|
||||
Handle<Value>
|
||||
Matrix::Crop(const Arguments& args){
|
||||
|
||||
SETUP_FUNCTION(Matrix)
|
||||
|
||||
if ((args.Length() == 4) && (args[0]->IsNumber()) && (args[1]->IsNumber()) && (args[2]->IsNumber()) && (args[3]->IsNumber())){
|
||||
|
||||
int x = args[0]->IntegerValue();
|
||||
int y = args[1]->IntegerValue();
|
||||
int width = args[2]->IntegerValue();
|
||||
int height = args[3]->IntegerValue();
|
||||
|
||||
cv::Rect roi(x, y, width, height);
|
||||
|
||||
Local<Object> im_h = Matrix::constructor->GetFunction()->NewInstance();
|
||||
Matrix *m = ObjectWrap::Unwrap<Matrix>(im_h);
|
||||
m->mat = self->mat(roi);
|
||||
|
||||
return scope.Close(im_h);
|
||||
}
|
||||
else{
|
||||
return scope.Close(v8::String::New("Insufficient or wrong arguments"));
|
||||
}
|
||||
}
|
||||
|
||||
Handle<Value>
|
||||
Matrix::Row(const Arguments& args){
|
||||
SETUP_FUNCTION(Matrix)
|
||||
|
||||
@ -73,6 +73,8 @@ class Matrix: public node::ObjectWrap {
|
||||
JSFUNC(GoodFeaturesToTrack)
|
||||
JSFUNC(HoughLinesP)
|
||||
|
||||
JSFUNC(Crop)
|
||||
|
||||
JSFUNC(inRange)
|
||||
|
||||
JSFUNC(LocateROI)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user