mirror of
https://github.com/peterbraden/node-opencv.git
synced 2025-12-08 19:45:55 +00:00
fix convert image (crop was missing) and other file paths
This commit is contained in:
parent
d5021b1bcc
commit
9b3b82fbbe
@ -1,6 +1,6 @@
|
|||||||
var cv = require('../lib/opencv');
|
var cv = require('../lib/opencv');
|
||||||
|
|
||||||
cv.readImage('./files/mona.png', function(err, im) {
|
cv.readImage('./examples/files/mona.png', function(err, im) {
|
||||||
if (err) throw err;
|
if (err) throw err;
|
||||||
if (im.width() < 1 || im.height() < 1) throw new Error('Image has no size');
|
if (im.width() < 1 || im.height() < 1) throw new Error('Image has no size');
|
||||||
|
|
||||||
@ -10,12 +10,12 @@ cv.readImage('./files/mona.png', function(err, im) {
|
|||||||
img_hsv.convertHSVscale();
|
img_hsv.convertHSVscale();
|
||||||
img_gray.convertGrayscale();
|
img_gray.convertGrayscale();
|
||||||
|
|
||||||
im.save('./tmp/nor.png');
|
im.save('./examples/tmp/nor.png');
|
||||||
img_hsv.save('./tmp/hsv.png');
|
img_hsv.save('./examples/tmp/hsv.png');
|
||||||
img_gray.save('./tmp/gray.png');
|
img_gray.save('./examples/tmp/gray.png');
|
||||||
|
|
||||||
img_crop = im.crop(50,50,250,250);
|
img_crop = im.crop(50,50,250,250);
|
||||||
img_crop.save('./tmp/crop.png');
|
img_crop.save('./examples/tmp/crop.png');
|
||||||
|
|
||||||
console.log('Image saved to ./tmp/{crop|nor|hsv|gray}.png');
|
console.log('Image saved to ./examples/tmp/{crop|nor|hsv|gray}.png');
|
||||||
});
|
});
|
||||||
|
|||||||
@ -12,7 +12,7 @@ var GREEN = [0, 255, 0]; // B, G, R
|
|||||||
var WHITE = [255, 255, 255]; // B, G, R
|
var WHITE = [255, 255, 255]; // B, G, R
|
||||||
|
|
||||||
|
|
||||||
cv.readImage('./files/shapes.jpg', function(err, im) {
|
cv.readImage('./examples/files/shapes.jpg', function(err, im) {
|
||||||
if (err) throw err;
|
if (err) throw err;
|
||||||
|
|
||||||
width = im.width()
|
width = im.width()
|
||||||
@ -46,6 +46,6 @@ cv.readImage('./files/shapes.jpg', function(err, im) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
out.save('./tmp/detect-shapes.png');
|
out.save('./examples/tmp/detect-shapes.png');
|
||||||
console.log('Image saved to ./tmp/detect-shapes.png');
|
console.log('Image saved to ./examples/tmp/detect-shapes.png');
|
||||||
});
|
});
|
||||||
|
|||||||
@ -1,10 +1,10 @@
|
|||||||
var cv = require('../lib/opencv');
|
var cv = require('../lib/opencv');
|
||||||
|
|
||||||
cv.readImage("./files/mona.png", function(err, im){
|
cv.readImage("./examples/files/mona.png", function(err, im){
|
||||||
if (err) throw err;
|
if (err) throw err;
|
||||||
if (im.width() < 1 || im.height() < 1) throw new Error('Image has no size');
|
if (im.width() < 1 || im.height() < 1) throw new Error('Image has no size');
|
||||||
|
|
||||||
im.detectObject("../data/haarcascade_frontalface_alt.xml", {}, function(err, faces){
|
im.detectObject("./data/haarcascade_frontalface_alt.xml", {}, function(err, faces){
|
||||||
if (err) throw err;
|
if (err) throw err;
|
||||||
|
|
||||||
for (var i = 0; i < faces.length; i++){
|
for (var i = 0; i < faces.length; i++){
|
||||||
@ -12,7 +12,7 @@ cv.readImage("./files/mona.png", function(err, im){
|
|||||||
im.ellipse(face.x + face.width / 2, face.y + face.height / 2, face.width / 2, face.height / 2);
|
im.ellipse(face.x + face.width / 2, face.y + face.height / 2, face.width / 2, face.height / 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
im.save('./tmp/face-detection.png');
|
im.save('./examples/tmp/face-detection.png');
|
||||||
console.log('Image saved to ./tmp/face-detection.png');
|
console.log('Image saved to ./examples/tmp/face-detection.png');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@ -47,6 +47,6 @@ cv.readImage('./examples/files/quads.jpg', function(err, im) {
|
|||||||
out.line([points[1].x,points[1].y], [points[3].x, points[3].y], RED);
|
out.line([points[1].x,points[1].y], [points[3].x, points[3].y], RED);
|
||||||
}
|
}
|
||||||
|
|
||||||
out.save('./tmp/quad-crosses.png');
|
out.save('./examples/tmp/quad-crosses.png');
|
||||||
console.log('Image saved to ./tmp/quad-crosses.png');
|
console.log('Image saved to ./examples/tmp/quad-crosses.png');
|
||||||
});
|
});
|
||||||
|
|||||||
@ -68,6 +68,7 @@ Matrix::Init(Handle<Object> target) {
|
|||||||
NODE_SET_PROTOTYPE_METHOD(ctor, "drawAllContours", DrawAllContours);
|
NODE_SET_PROTOTYPE_METHOD(ctor, "drawAllContours", DrawAllContours);
|
||||||
NODE_SET_PROTOTYPE_METHOD(ctor, "goodFeaturesToTrack", GoodFeaturesToTrack);
|
NODE_SET_PROTOTYPE_METHOD(ctor, "goodFeaturesToTrack", GoodFeaturesToTrack);
|
||||||
NODE_SET_PROTOTYPE_METHOD(ctor, "houghLinesP", HoughLinesP);
|
NODE_SET_PROTOTYPE_METHOD(ctor, "houghLinesP", HoughLinesP);
|
||||||
|
NODE_SET_PROTOTYPE_METHOD(ctor, "crop", Crop);
|
||||||
NODE_SET_PROTOTYPE_METHOD(ctor, "inRange", inRange);
|
NODE_SET_PROTOTYPE_METHOD(ctor, "inRange", inRange);
|
||||||
NODE_SET_PROTOTYPE_METHOD(ctor, "adjustROI", AdjustROI);
|
NODE_SET_PROTOTYPE_METHOD(ctor, "adjustROI", AdjustROI);
|
||||||
NODE_SET_PROTOTYPE_METHOD(ctor, "locateROI", LocateROI);
|
NODE_SET_PROTOTYPE_METHOD(ctor, "locateROI", LocateROI);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user