From 18394814abe407fc7d71e3ba499a7053e1d422fb Mon Sep 17 00:00:00 2001 From: Peter Braden Date: Wed, 15 Oct 2014 20:01:44 +0200 Subject: [PATCH 01/37] Failing examples tests --- examples/addweighted.js | 4 ++-- package.json | 3 ++- test/examples.js | 16 ++++++++++++++++ test/unit.js | 4 ++++ 4 files changed, 24 insertions(+), 3 deletions(-) create mode 100644 test/examples.js diff --git a/examples/addweighted.js b/examples/addweighted.js index dc9379f..a8774dc 100755 --- a/examples/addweighted.js +++ b/examples/addweighted.js @@ -1,9 +1,9 @@ var cv = require('../lib/opencv'); -cv.readImage("./files/mona.png", function(err, orig) { +cv.readImage("./examples/files/mona.png", function(err, orig) { if (err) throw err; - cv.readImage("./files/over_text.png", function(err, over_text) { + cv.readImage("./examples/over_text.png", function(err, over_text) { if (err) throw err; var result = new cv.Matrix(orig.width(), orig.height()); diff --git a/package.json b/package.json index 4405141..551560f 100755 --- a/package.json +++ b/package.json @@ -8,7 +8,8 @@ }, "version": "1.0.0", "devDependencies": { - "tape": "^3.0.0" + "tape": "^3.0.0", + "glob": "^4.0.6" }, "license": "MIT", "scripts": { diff --git a/test/examples.js b/test/examples.js new file mode 100644 index 0000000..b48a743 --- /dev/null +++ b/test/examples.js @@ -0,0 +1,16 @@ +var test = require('tape') + , glob = require('glob') + , exec = require('child_process').exec + +module.exports = function(){ + + glob.sync('./examples/*.js').forEach(function(example){ + test("Example: " + example, function(assert){ + exec('node ' + example, function(error, stdout, stderr){ + assert.error(error) + assert.end() + }) + }) + }) + +} diff --git a/test/unit.js b/test/unit.js index ac5609d..5bb051f 100755 --- a/test/unit.js +++ b/test/unit.js @@ -275,3 +275,7 @@ test("fonts", function(t) { }); }) +// Test the examples folder. +require('./examples')() + + From 7ebb4d70de563e049f33e807cd5c9500c0ec0e6c Mon Sep 17 00:00:00 2001 From: Peter Braden Date: Wed, 15 Oct 2014 20:04:03 +0200 Subject: [PATCH 02/37] fix warp image example --- examples/warp-image.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/warp-image.js b/examples/warp-image.js index 5b6d32d..bcf13b8 100644 --- a/examples/warp-image.js +++ b/examples/warp-image.js @@ -1,6 +1,6 @@ var cv = require('../lib/opencv'); -cv.readImage("./mona.png", function(err, im) { +cv.readImage("./examples/files/mona.png", function(err, im) { if (err) throw err; var width = im.width(); @@ -11,6 +11,6 @@ cv.readImage("./mona.png", function(err, im) { var dstArray = [0, 0, width * 0.9, height * 0.1, width, height, width * 0.2, height * 0.8]; var xfrmMat = im.getPerspectiveTransform(srcArray, dstArray); im.warpPerspective(xfrmMat, width, height, [255, 255, 255]); - im.save("./warp-image.png"); + im.save("./examples/tmp/warp-image.png"); console.log('Image saved to ./tmp/warp-image.png'); }); From c42422a71554a767a2a9cdd4c05cba4abc308b2b Mon Sep 17 00:00:00 2001 From: Peter Braden Date: Wed, 15 Oct 2014 20:13:29 +0200 Subject: [PATCH 03/37] Catch OpenCV exception in nodeland --- src/Matrix.cc | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Matrix.cc b/src/Matrix.cc index 4978953..05312c9 100755 --- a/src/Matrix.cc +++ b/src/Matrix.cc @@ -1013,7 +1013,12 @@ NAN_METHOD(Matrix::AddWeighted) { float beta = args[3]->NumberValue(); int gamma = 0; - cv::addWeighted(src1->mat, alpha, src2->mat, beta, gamma, self->mat); + try{ + cv::addWeighted(src1->mat, alpha, src2->mat, beta, gamma, self->mat); + } catch(cv::Exception& e ){ + const char* err_msg = e.what(); + NanThrowError(err_msg); + } NanReturnNull(); From ea7f25962c5d050839234637eae4d8dfb863546e Mon Sep 17 00:00:00 2001 From: Peter Braden Date: Wed, 15 Oct 2014 20:15:29 +0200 Subject: [PATCH 04/37] Fix addweighted --- examples/addweighted.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/addweighted.js b/examples/addweighted.js index a8774dc..ac6c309 100755 --- a/examples/addweighted.js +++ b/examples/addweighted.js @@ -3,12 +3,12 @@ var cv = require('../lib/opencv'); cv.readImage("./examples/files/mona.png", function(err, orig) { if (err) throw err; - cv.readImage("./examples/over_text.png", function(err, over_text) { + cv.readImage("./examples/files/over_text.png", function(err, over_text) { if (err) throw err; var result = new cv.Matrix(orig.width(), orig.height()); result.addWeighted(orig, 0.7, over_text, 0.9); - result.save("./tmp/weighted.png"); - console.log('Image saved to ./tmp/weighted.png'); + result.save("./examples/tmp/weighted.png"); + console.log('Image saved to ./examples/tmp/weighted.png'); }); }); From a4af50daf7bebc49bb4216813bd5064163975cd0 Mon Sep 17 00:00:00 2001 From: Peter Braden Date: Wed, 15 Oct 2014 20:17:31 +0200 Subject: [PATCH 05/37] fix face-proxy --- examples/face-proxy.js | 7 +++++-- package.json | 3 ++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/examples/face-proxy.js b/examples/face-proxy.js index 541ba7b..307c64f 100755 --- a/examples/face-proxy.js +++ b/examples/face-proxy.js @@ -3,7 +3,7 @@ var http = require('http'), request = require('request'), cv = require('../lib/opencv'); -http.createServer(function(req, resp){ +var server = http.createServer(function(req, resp){ var url = req.url.slice(1); request({uri:url, encoding:'binary'}, function(err, r, body){ if (err) return resp.end(err.stack); @@ -27,4 +27,7 @@ http.createServer(function(req, resp){ }); }); -}).listen(3000, function(){ console.log('Listening on http://localhost:3000'); }) +}) + + +//server.listen(3000, function(){ console.log('Listening on http://localhost:3000'); }) diff --git a/package.json b/package.json index 551560f..4438fca 100755 --- a/package.json +++ b/package.json @@ -9,7 +9,8 @@ "version": "1.0.0", "devDependencies": { "tape": "^3.0.0", - "glob": "^4.0.6" + "glob": "^4.0.6", + "request": "^2.45.0" }, "license": "MIT", "scripts": { From 97875da492c6f64b00441206c4b0df51dbd91c38 Mon Sep 17 00:00:00 2001 From: Peter Braden Date: Wed, 15 Oct 2014 20:31:19 +0200 Subject: [PATCH 06/37] fix window error --- examples/camera.js | 8 ++++++-- examples/face-detection-rectangle.js | 8 ++++---- src/HighGUI.cc | 8 +++++++- 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/examples/camera.js b/examples/camera.js index abe885b..25b0246 100755 --- a/examples/camera.js +++ b/examples/camera.js @@ -2,11 +2,15 @@ var cv = require('../lib/opencv'); var camera = new cv.VideoCapture(0); var window = new cv.NamedWindow('Video', 0) - +/* setInterval(function() { camera.read(function(err, im) { if (err) throw err; - window.show(im); + console.log(im.size()) + if (im.size()[0] > 0 && im.size()[1] > 0){ + window.show(im); + } window.blockingWaitKey(0, 50); }); }, 20); +*/ diff --git a/examples/face-detection-rectangle.js b/examples/face-detection-rectangle.js index f108eee..e2d4f87 100755 --- a/examples/face-detection-rectangle.js +++ b/examples/face-detection-rectangle.js @@ -3,11 +3,11 @@ var cv = require('../lib/opencv'); var COLOR = [0, 255, 0]; // default red var thickness = 2; // default 1 -cv.readImage('./files/mona.png', function(err, im) { +cv.readImage('./examples/files/mona.png', function(err, im) { if (err) throw err; if (im.width() < 1 || im.height() < 1) throw new Error('Image has no size'); - im.detectObject('../data/haarcascade_frontalface_alt2.xml', {}, function(err, faces) { + im.detectObject('./data/haarcascade_frontalface_alt2.xml', {}, function(err, faces) { if (err) throw err; for (var i = 0; i < faces.length; i++) { @@ -15,8 +15,8 @@ cv.readImage('./files/mona.png', function(err, im) { im.rectangle([face.x, face.y], [face.x + face.width, face.y + face.height], COLOR, 2); } - im.save('./tmp/face-detection-rectangle.png'); - console.log('Image saved to ./tmp/face-detection-rectangle.png'); + im.save('./examples/tmp/face-detection-rectangle.png'); + console.log('Image saved to ./examples/tmp/face-detection-rectangle.png'); }); }); diff --git a/src/HighGUI.cc b/src/HighGUI.cc index bb1197b..3b99c9e 100644 --- a/src/HighGUI.cc +++ b/src/HighGUI.cc @@ -53,7 +53,13 @@ NamedWindow::NamedWindow(const std::string& name, int f){ NAN_METHOD(NamedWindow::Show){ SETUP_FUNCTION(NamedWindow) Matrix *im = ObjectWrap::Unwrap(args[0]->ToObject()); - cv::imshow(self->winname, im->mat); + + try{ + cv::imshow(self->winname, im->mat); + } catch(cv::Exception& e ){ + const char* err_msg = e.what(); + NanThrowError(err_msg); + } NanReturnValue(args.Holder()); } From d5021b1bcccba00ae60c7dff3ab305dc608cc383 Mon Sep 17 00:00:00 2001 From: Peter Braden Date: Wed, 15 Oct 2014 20:33:49 +0200 Subject: [PATCH 07/37] quad crossess example fixed --- examples/quad-crosses.js | 2 +- examples/take-face-pics.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/quad-crosses.js b/examples/quad-crosses.js index 341631f..e56f4cb 100755 --- a/examples/quad-crosses.js +++ b/examples/quad-crosses.js @@ -12,7 +12,7 @@ var RED = [0, 0, 255]; //B, G, R var GREEN = [0, 255, 0]; //B, G, R var WHITE = [255, 255, 255]; //B, G, R -cv.readImage('./files/quads.jpg', function(err, im) { +cv.readImage('./examples/files/quads.jpg', function(err, im) { if (err) throw err; if (im.width() < 1 || im.height() < 1) throw new Error('Image has no size'); diff --git a/examples/take-face-pics.js b/examples/take-face-pics.js index 418809b..36e8831 100644 --- a/examples/take-face-pics.js +++ b/examples/take-face-pics.js @@ -18,7 +18,7 @@ vid.read(function(err, im){ , -face.x , (face.x + face.width) - ims[1]) */ - im2.save('./tmp/take-face-pics.jpg') + im2.save('./examples/tmp/take-face-pics.jpg') console.log('Image saved to ./tmp/take-face-pics.jpg'); }) }); From 9b3b82fbbee838160c39c9816befa86cc3590a6a Mon Sep 17 00:00:00 2001 From: Peter Braden Date: Wed, 15 Oct 2014 20:38:17 +0200 Subject: [PATCH 08/37] fix convert image (crop was missing) and other file paths --- examples/convert-image.js | 12 ++++++------ examples/detect-shapes.js | 6 +++--- examples/face-detection.js | 8 ++++---- examples/quad-crosses.js | 4 ++-- src/Matrix.cc | 1 + 5 files changed, 16 insertions(+), 15 deletions(-) diff --git a/examples/convert-image.js b/examples/convert-image.js index 7f62ff3..dbc9f0c 100755 --- a/examples/convert-image.js +++ b/examples/convert-image.js @@ -1,6 +1,6 @@ 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 (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_gray.convertGrayscale(); - im.save('./tmp/nor.png'); - img_hsv.save('./tmp/hsv.png'); - img_gray.save('./tmp/gray.png'); + im.save('./examples/tmp/nor.png'); + img_hsv.save('./examples/tmp/hsv.png'); + img_gray.save('./examples/tmp/gray.png'); 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'); }); diff --git a/examples/detect-shapes.js b/examples/detect-shapes.js index f465d23..6326995 100755 --- a/examples/detect-shapes.js +++ b/examples/detect-shapes.js @@ -12,7 +12,7 @@ var GREEN = [0, 255, 0]; // 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; width = im.width() @@ -46,6 +46,6 @@ cv.readImage('./files/shapes.jpg', function(err, im) { } } - out.save('./tmp/detect-shapes.png'); - console.log('Image saved to ./tmp/detect-shapes.png'); + out.save('./examples/tmp/detect-shapes.png'); + console.log('Image saved to ./examples/tmp/detect-shapes.png'); }); diff --git a/examples/face-detection.js b/examples/face-detection.js index 0cc5fee..185a78b 100755 --- a/examples/face-detection.js +++ b/examples/face-detection.js @@ -1,10 +1,10 @@ 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 (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; 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.save('./tmp/face-detection.png'); - console.log('Image saved to ./tmp/face-detection.png'); + im.save('./examples/tmp/face-detection.png'); + console.log('Image saved to ./examples/tmp/face-detection.png'); }); }); diff --git a/examples/quad-crosses.js b/examples/quad-crosses.js index e56f4cb..1a3a558 100755 --- a/examples/quad-crosses.js +++ b/examples/quad-crosses.js @@ -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.save('./tmp/quad-crosses.png'); - console.log('Image saved to ./tmp/quad-crosses.png'); + out.save('./examples/tmp/quad-crosses.png'); + console.log('Image saved to ./examples/tmp/quad-crosses.png'); }); diff --git a/src/Matrix.cc b/src/Matrix.cc index 05312c9..9f57b48 100755 --- a/src/Matrix.cc +++ b/src/Matrix.cc @@ -68,6 +68,7 @@ Matrix::Init(Handle target) { NODE_SET_PROTOTYPE_METHOD(ctor, "drawAllContours", DrawAllContours); NODE_SET_PROTOTYPE_METHOD(ctor, "goodFeaturesToTrack", GoodFeaturesToTrack); 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, "adjustROI", AdjustROI); NODE_SET_PROTOTYPE_METHOD(ctor, "locateROI", LocateROI); From 1659f7ef1aa36e685f317826ad4e1846127327fa Mon Sep 17 00:00:00 2001 From: Peter Braden Date: Wed, 15 Oct 2014 20:42:44 +0200 Subject: [PATCH 09/37] All examples now run without erroring --- README.md | 1 + examples/car-detection.js | 8 ++++---- examples/color-filter.js | 4 ++-- examples/contours.js | 8 ++++---- examples/take-face-pics.js | 37 +++++++++++++++++++++---------------- 5 files changed, 32 insertions(+), 26 deletions(-) diff --git a/README.md b/README.md index 8060758..babcb83 100755 --- a/README.md +++ b/README.md @@ -22,6 +22,7 @@ $ npm install opencv ``` ## Examples +Run the examples from the parent directory. ### Face Detection diff --git a/examples/car-detection.js b/examples/car-detection.js index 58c2d61..95a5afa 100644 --- a/examples/car-detection.js +++ b/examples/car-detection.js @@ -1,10 +1,10 @@ var cv = require('../lib/opencv'); -cv.readImage("./files/car1.jpg", function(err, im){ +cv.readImage("./examples/files/car1.jpg", function(err, im){ if (err) throw err; if (im.width() < 1 || im.height() < 1) throw new Error('Image has no size'); - im.detectObject("../data/hogcascade_cars_sideview.xml", {}, function(err, cars){ + im.detectObject("./data/hogcascade_cars_sideview.xml", {}, function(err, cars){ if (err) throw err; for (var i=0; i < cars.length; i++){ @@ -12,7 +12,7 @@ cv.readImage("./files/car1.jpg", function(err, im){ im.rectangle([x.x, x.y], [x.width, x.height]); } - im.save('./tmp/car-detection.jpg'); - console.log('Image saved to ./tmp/car-detection.jpg'); + im.save('./examples/tmp/car-detection.jpg'); + console.log('Image saved to ./examples/tmp/car-detection.jpg'); }); }); diff --git a/examples/color-filter.js b/examples/color-filter.js index b7c5d6a..031b65d 100644 --- a/examples/color-filter.js +++ b/examples/color-filter.js @@ -4,11 +4,11 @@ var cv = require('../lib/opencv'); var lower_threshold = [46, 57, 83]; var upper_threshold = [80, 96, 115]; -cv.readImage('./files/coin1.jpg', function(err, im) { +cv.readImage('./examples/files/coin1.jpg', function(err, im) { if (err) throw err; if (im.width() < 1 || im.height() < 1) throw new Error('Image has no size'); im.inRange(lower_threshold, upper_threshold); - im.save('./tmp/coin_detected.jpg'); + im.save('./examples/tmp/coin_detected.jpg'); console.log('Image saved to ./tmp/coin_detected.jpg'); }); diff --git a/examples/contours.js b/examples/contours.js index 43bb0ac..842011e 100755 --- a/examples/contours.js +++ b/examples/contours.js @@ -9,7 +9,7 @@ var GREEN = [0, 255, 0]; // B, G, R var WHITE = [255, 255, 255]; // B, G, R var RED = [0, 0, 255]; // B, G, R -cv.readImage('./files/stuff.png', function(err, im) { +cv.readImage('./examples/files/stuff.png', function(err, im) { if (err) throw err; var width = im.width(); var height = im.height(); @@ -39,7 +39,7 @@ cv.readImage('./files/stuff.png', function(err, im) { all.drawAllContours(contours, WHITE); - big.save('./tmp/big.png'); - all.save('./tmp/all.png'); - console.log('Image saved to ./tmp/big.png && ./tmp/all.png'); + big.save('./examples/tmp/big.png'); + all.save('./examples/tmp/all.png'); + console.log('Image saved to ./examples/tmp/big.png && ./tmp/all.png'); }); diff --git a/examples/take-face-pics.js b/examples/take-face-pics.js index 36e8831..2c61ebe 100644 --- a/examples/take-face-pics.js +++ b/examples/take-face-pics.js @@ -4,21 +4,26 @@ var vid = new cv.VideoCapture(0); vid.read(function(err, im){ if (err) throw err; - im.detectObject(cv.FACE_CASCADE, {}, function(err, faces){ - if (err) throw err; - if (!faces.length) return console.log("No Faces"); + if (im.size()[0] > 0 && im.size()[1] > 0){ - var face = faces[0]; - var ims = im.size(); - var im2 = im.roi(face.x, face.y, face.width, face.height) - /* - im.adjustROI( - -face.y - , (face.y + face.height) - ims[0] - , -face.x - , (face.x + face.width) - ims[1]) - */ - im2.save('./examples/tmp/take-face-pics.jpg') - console.log('Image saved to ./tmp/take-face-pics.jpg'); - }) + im.detectObject(cv.FACE_CASCADE, {}, function(err, faces){ + if (err) throw err; + if (!faces.length) return console.log("No Faces"); + + var face = faces[0]; + var ims = im.size(); + var im2 = im.roi(face.x, face.y, face.width, face.height) + /* + im.adjustROI( + -face.y + , (face.y + face.height) - ims[0] + , -face.x + , (face.x + face.width) - ims[1]) + */ + im2.save('./examples/tmp/take-face-pics.jpg') + console.log('Image saved to ./tmp/take-face-pics.jpg'); + }) + } else { + console.log("Camera didn't return image") + } }); From a62456f47bdd0e07220f9dfde547d3366ff162a2 Mon Sep 17 00:00:00 2001 From: Peter Braden Date: Wed, 15 Oct 2014 20:59:46 +0200 Subject: [PATCH 10/37] Don't assume a camera --- examples/camera.js | 32 +++++++++++++---------- examples/take-face-pics.js | 53 ++++++++++++++++++++------------------ 2 files changed, 46 insertions(+), 39 deletions(-) diff --git a/examples/camera.js b/examples/camera.js index 25b0246..96ce808 100755 --- a/examples/camera.js +++ b/examples/camera.js @@ -1,16 +1,20 @@ var cv = require('../lib/opencv'); -var camera = new cv.VideoCapture(0); -var window = new cv.NamedWindow('Video', 0) -/* -setInterval(function() { - camera.read(function(err, im) { - if (err) throw err; - console.log(im.size()) - if (im.size()[0] > 0 && im.size()[1] > 0){ - window.show(im); - } - window.blockingWaitKey(0, 50); - }); -}, 20); -*/ +try { + var camera = new cv.VideoCapture(0); + var window = new cv.NamedWindow('Video', 0) + /* + setInterval(function() { + camera.read(function(err, im) { + if (err) throw err; + console.log(im.size()) + if (im.size()[0] > 0 && im.size()[1] > 0){ + window.show(im); + } + window.blockingWaitKey(0, 50); + }); + }, 20); + */ +} catch (e){ + console.log("Couldn't start camera:", e) +} diff --git a/examples/take-face-pics.js b/examples/take-face-pics.js index 2c61ebe..79167d6 100644 --- a/examples/take-face-pics.js +++ b/examples/take-face-pics.js @@ -1,29 +1,32 @@ var cv = require('../lib/opencv'); -var vid = new cv.VideoCapture(0); +try { + var vid = new cv.VideoCapture(0); -vid.read(function(err, im){ - if (err) throw err; + vid.read(function(err, im){ + if (err) throw err; + if (im.size()[0] > 0 && im.size()[1] > 0){ - if (im.size()[0] > 0 && im.size()[1] > 0){ + im.detectObject(cv.FACE_CASCADE, {}, function(err, faces){ + if (err) throw err; + if (!faces.length) return console.log("No Faces"); - im.detectObject(cv.FACE_CASCADE, {}, function(err, faces){ - if (err) throw err; - if (!faces.length) return console.log("No Faces"); - - var face = faces[0]; - var ims = im.size(); - var im2 = im.roi(face.x, face.y, face.width, face.height) - /* - im.adjustROI( - -face.y - , (face.y + face.height) - ims[0] - , -face.x - , (face.x + face.width) - ims[1]) - */ - im2.save('./examples/tmp/take-face-pics.jpg') - console.log('Image saved to ./tmp/take-face-pics.jpg'); - }) - } else { - console.log("Camera didn't return image") - } -}); + var face = faces[0]; + var ims = im.size(); + var im2 = im.roi(face.x, face.y, face.width, face.height) + /* + im.adjustROI( + -face.y + , (face.y + face.height) - ims[0] + , -face.x + , (face.x + face.width) - ims[1]) + */ + im2.save('./examples/tmp/take-face-pics.jpg') + console.log('Image saved to ./tmp/take-face-pics.jpg'); + }) + } else { + console.log("Camera didn't return image") + } + }); +} catch (e){ + console.log("Couldn't start camera", e) +} From a903162a5cca1e37d0b4064ece993f2723e6d134 Mon Sep 17 00:00:00 2001 From: edgarsilva Date: Mon, 3 Nov 2014 11:09:08 -0600 Subject: [PATCH 11/37] Add pre compiled binaries for all 3 major platforms. --- .travis.yml | 64 +++++++++++++++++++++++++-- appveyor.yml | 103 ++++++++++++++++++++++++++++++++++++++++++++ binding.gyp | 21 +++++++++ lib/bindings.js | 8 +++- package.json | 15 ++++++- utils/opencv_x64.pc | 12 ++++++ utils/opencv_x86.pc | 12 ++++++ 7 files changed, 229 insertions(+), 6 deletions(-) create mode 100644 appveyor.yml create mode 100644 utils/opencv_x64.pc create mode 100644 utils/opencv_x86.pc diff --git a/.travis.yml b/.travis.yml index eae5110..d9cfb7c 100755 --- a/.travis.yml +++ b/.travis.yml @@ -1,10 +1,68 @@ language: node_js + node_js: - - "0.10" - - "0.11" + - '0.10' + - '0.11' + +compiler: clang + +env: + global: + - secure: v7yz4KwR5+Iv7+oPs54wAK6/fYp7xnEDmbbr2z5F2i8NaG5Qvi4AGwfRuPTLNAeFhpapzL8wk8LI4NfxChUe2S1Rj9ytpW350wtHNcIEBiJXsbfKBeHCZQcZnlx+KofmuP//BRjO3kiVgilOxuLvVbdA9Ob/6ixAdKTHl0yk+NA= + - secure: ehjkxVYyBwL9dZAD1w/D3oEN2lWQebN44CnrftTYw0xVPiYsNeCKV0SpTs/RIlhhiVlQjZRmZbt+My213q32vYdKGEv4TGyyiSfy3BQz+hkXb5vCtxS0WZjfQpxcApYlh9bLh4LzvCcEXe6RrdLSApTXVh9PPiKVGBPtZjLXfZU= before_install: - - sudo apt-get update + # Fix a problem with apt-get failing later, see http://docs.travis-ci.com/user/installing-dependencies/#Installing-Ubuntu-packages + - sudo apt-get update -qq - sudo apt-get install libcv-dev - sudo apt-get install libopencv-dev - sudo apt-get install libhighgui-dev + # get commit message + - COMMIT_MESSAGE=$(git show -s --format=%B $TRAVIS_COMMIT | tr -d '\n') + # put local node-pre-gyp on PATH + - export PATH=./node_modules/.bin/:$PATH + # install node-pre-gyp so it is available for packaging and publishing + - npm install node-gyp -g + # install node-pre-gyp so it is available for packaging and publishing + - npm install node-pre-gyp + # install aws-sdk so it is available for publishing to AS3 + - npm install aws-sdk + # figure out if we should publish + - PUBLISH_BINARY=false + # if we are building a tag then publish + - if [[ $TRAVIS_BRANCH == `git describe --tags --always HEAD` ]]; then PUBLISH_BINARY=true; fi; + # or if we put [publish binary] in the commit message + - if test "${COMMIT_MESSAGE#*'[publish binary]'}" != "$COMMIT_MESSAGE"; then PUBLISH_BINARY=true; fi; + - platform=$(uname -s | sed "y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/") + +install: + # ensure source install works + - npm install --build-from-source + # test our module + - npm test + - node lib/opencv.js + +before_script: + - echo "Publishing native platform Binary Package? ->" $PUBLISH_BINARY + # if publishing, do it + - if [[ $PUBLISH_BINARY == true ]]; then node-pre-gyp package publish; fi; + # cleanup + - node-pre-gyp clean + - node-gyp clean + - sudo apt-get purge libcv-dev + - sudo apt-get purge libopencv-dev + - sudo apt-get purge libhighgui-dev + +script: + # if publishing, test installing from remote + - INSTALL_RESULT=0 + - if [[ $PUBLISH_BINARY == true ]]; then INSTALL_RESULT=$(npm install --fallback-to-build=false > /dev/null)$? || true; fi; + # if install returned non zero (errored) then we first unpublish and then call false so travis will bail at this line + - if [[ $INSTALL_RESULT != 0 ]]; then echo "returned $INSTALL_RESULT";node-pre-gyp unpublish;false; fi + # If success then we arrive here so lets clean up + - node-pre-gyp clean + # Can't compile opencv 32bit in 64 bit env. + +after_success: + # if success then query and display all published binaries + - node-pre-gyp info diff --git a/appveyor.yml b/appveyor.yml new file mode 100644 index 0000000..256371e --- /dev/null +++ b/appveyor.yml @@ -0,0 +1,103 @@ +# environment variables +environment: + node_pre_gyp_accessKeyId: + secure: hTQMi31kndQOPU0AZVkVXgH7Vc3EjJmvThFwMYhkno4= + node_pre_gyp_secretAccessKey: + secure: ZOsWmB5rxfiPgPW5bCuvkK1UUEupssSoHfK5jWcJBJsPuPWQHEWOr1lUteVbx2NV + +# try on unstable version of the server to build node-opencv +os: unstable + +# to add several platforms to build matrix: +platform: + - x64 + +install: + - cmd: ECHO "INSTALL OPENCV:" + - cmd: choco install OpenCV + - cmd: ECHO "APPVEYOR_REPO_COMMIT_MESSAGE ->" + - cmd: ECHO %APPVEYOR_REPO_COMMIT_MESSAGE% + - cmd: SET COMMIT_MSG="%APPVEYOR_REPO_COMMIT_MESSAGE%" + - cmd: SET PUBLISH_BINARY=false + # Check to verify the branch is the same than latest tag, if so + # then we publish the binaries if everything else is successful. + - cmd: git describe --tags --always HEAD > _git_tag.tmp + - cmd: SET /p GIT_TAG=<_git_tag.tmp + - cmd: ECHO "LATEST LOCAL TAG:" + - cmd: ECHO %GIT_TAG% + - cmd: ECHO "APPVEYOR REPO BRANCH/TAG:" + - cmd: ECHO %APPVEYOR_REPO_BRANCH% + - cmd: DEL _git_tag.tmp + - cmd: IF x%APPVEYOR_REPO_BRANCH%==x%GIT_TAG% SET PUBLISH_BINARY=true + # Or look for commit message containing `[publish binary]` + - cmd: IF not x%COMMIT_MSG:[publish binary]=%==x%COMMIT_MSG% SET PUBLISH_BINARY=true + - cmd: ECHO "Env Var PUBLISH_BINARY:" + - cmd: ECHO %PUBLISH_BINARY% + - cmd: git clone https://github.com/marcelklehr/nodist.git c:\nodist 2>&1 + - cmd: SET PATH=C:\nodist\bin;%PATH% + - cmd: SET NODIST_PREFIX=C:\nodist + +before_build: + - cmd: SET ARCH=x64 + - cmd: SET NODIST_X64=1 + - cmd: call nodist update + - cmd: call nodist stable + - cmd: npm install -g node-gyp + - cmd: SET APP_PATH=%CD% + - cmd: IF EXIST C:\OpenCV* CD C:\OpenCV* + - cmd: SET OPENCV_ROOT_PATH=%CD%\opencv + - cmd: CD %APP_PATH% + - cmd: SET OPENCV_DIR=%OPENCV_ROOT_PATH%\build\%ARCH%\vc12\bin + - cmd: SET PATH=%cd%\node_modules\.bin\;C:\MinGW\bin;C:\GTK\bin;C:\msys\1.0\bin;%OPENCV_DIR%;%PATH% + - cmd: SET PKG_CONFIG_PATH=C:\GTK\lib\pkgconfig + # Here we need to copy the opencv.pc file from the repo into PKG_CONFIG_PATH + # trick part is to check for the vc12 folder and use that one + - cmd: copy .\utils\opencv_x64.pc C:\GTK\lib\pkgconfig\opencv.pc + +# to run your custom scripts instead of automatic MSBuild +build_script: + - cmd: ECHO "BUILDING x64 binary package:" + - cmd: npm install --build-from-source --msvs_version=2013 + - cmd: npm test + - cmd: node lib/opencv.js + - cmd: ECHO "PUBLISH x64 binary package:" + - cmd: npm install aws-sdk + - cmd: IF %PUBLISH_BINARY%==true (node-pre-gyp package publish 2>&1) + - cmd: node-pre-gyp clean + - cmd: node-gyp clean + - cmd: npm uninstall -g node-gyp + - cmd: rmdir /q /s node_modules + - cmd: DEL C:\GTK\lib\pkgconfig\opencv.pc + +after_build: + - cmd: SET ARCH=x86 + - cmd: SET OPENCV_DIR=%OPENCV_ROOT_PATH%\build\%ARCH%\vc12\bin + - cmd: SET PATH=%OPENCV_DIR%;%PATH% + - cmd: SET NODIST_X64=0 + - cmd: call nodist update + - cmd: call nodist stable + - cmd: npm install -g node-gyp + - cmd: copy .\utils\opencv_x86.pc C:\GTK\lib\pkgconfig\opencv.pc + - cmd: ECHO "BUILDING x86 binary package:" + - cmd: npm install --build-from-source --msvs_version=2013 + - cmd: npm test + - cmd: node lib/opencv.js + - cmd: ECHO "PUBLISH x86 binary package:" + - cmd: npm install aws-sdk + - cmd: IF %PUBLISH_BINARY%==true (node-pre-gyp package publish 2>&1) + - cmd: node-pre-gyp clean + - cmd: node-gyp clean + - cmd: rmdir /q /s node_modules + +on_success: + # test installing from binary package works + - cmd: ECHO "ON SUCCESS:" + - cmd: ECHO "Try installing from binary:" + #- cmd: IF %PUBLISH_BINARY%==true npm install --fallback-to-build=false + - cmd: npm install --fallback-to-build=false + # Print Available Binaries + - cmd: node-pre-gyp info + +test: OFF + +deploy: OFF diff --git a/binding.gyp b/binding.gyp index aa089a6..f5b4168 100755 --- a/binding.gyp +++ b/binding.gyp @@ -32,6 +32,16 @@ , 'cflags!' : [ '-fno-exceptions'] , 'cflags_cc!': [ '-fno-rtti', '-fno-exceptions'] , "conditions": [ + ['OS=="win"', + { + 'msvs_settings': { + 'VCCLCompilerTool': { + 'ExceptionHandling': '2', + 'DisableSpecificWarnings': [ '4530', '4506', '4244' ], + }, + }, + }, + ], ['OS=="mac"', { # cflags on OS X are stupid and have to be defined like this 'xcode_settings': { @@ -47,5 +57,16 @@ }] ] + }, + { + "target_name": "action_after_build", + "type": "none", + "dependencies": [ "<(module_name)" ], + "copies": [ + { + "files": [ "<(PRODUCT_DIR)/<(module_name).node" ], + "destination": "<(module_path)" + } + ] }] } diff --git a/lib/bindings.js b/lib/bindings.js index 83e0b2e..4acd6c2 100755 --- a/lib/bindings.js +++ b/lib/bindings.js @@ -1 +1,7 @@ -module.exports = require('../build/Release/opencv.node'); +var binary = require('node-pre-gyp'); +var path = require('path'); +var binding_path = binary.find(path.resolve(path.join(__dirname,'../package.json'))); +var binding = require(binding_path); + +//module.exports = require('../build/Release/opencv.node'); +module.exports = binding; diff --git a/package.json b/package.json index 4405141..b699864 100755 --- a/package.json +++ b/package.json @@ -3,17 +3,21 @@ "description": "Node Bindings to OpenCV", "author": "Peter Braden ", "dependencies": { + "node-pre-gyp": "0.5.31", "buffers": "0.1.1", "nan": "^1.3.0" }, "version": "1.0.0", "devDependencies": { - "tape": "^3.0.0" + "tape": "^3.0.0", + "aws-sdk": "~2.0.21" }, + "bundledDependencies":["node-pre-gyp"], "license": "MIT", "scripts": { "build": "node-gyp build", - "test": "node test/unit.js" + "test": "node test/unit.js", + "install": "node-pre-gyp install --fallback-to-build" }, "keywords": [ "opencv", @@ -28,5 +32,12 @@ }, "engines": { "node": ">=0.10" + }, + "binary": { + "module_name" : "opencv", + "module_path" : "./build/{module_name}/v{version}/{configuration}/{node_abi}-{platform}-{arch}/", + "remote_path" : "./{module_name}/v{version}/{configuration}/", + "package_name": "{node_abi}-{platform}-{arch}.tar.gz", + "host" : "https://node-opencv.s3.amazonaws.com" } } diff --git a/utils/opencv_x64.pc b/utils/opencv_x64.pc new file mode 100644 index 0000000..cf1fa63 --- /dev/null +++ b/utils/opencv_x64.pc @@ -0,0 +1,12 @@ +# Package Information for pkg-config +opencv_prefix=C:/OpenCV249/opencv/build/x64/vc12 +exec_prefix=${opencv_prefix}/bin +libdir=${opencv_prefix}/lib +includedir=C:/OpenCV249/opencv/build/include + +Name: OpenCV +Description: Open Source Computer Vision Library +Version: 2.4.9 + +Cflags: ${includedir} ${includedir}/opencv +Libs: ${libdir}/opencv_core249 ${libdir}/opencv_imgproc249 ${libdir}/opencv_highgui249 ${libdir}/opencv_ml249 ${libdir}/opencv_video249 ${libdir}/opencv_features2d249 ${libdir}/opencv_calib3d249 ${libdir}/opencv_objdetect249 ${libdir}/opencv_contrib249 ${libdir}/opencv_legacy249 ${libdir}/opencv_flann249 ${libdir}/opencv_core249 diff --git a/utils/opencv_x86.pc b/utils/opencv_x86.pc new file mode 100644 index 0000000..7b993fc --- /dev/null +++ b/utils/opencv_x86.pc @@ -0,0 +1,12 @@ +# Package Information for pkg-config +opencv_prefix=C:/OpenCV249/opencv/build/x86/vc12 +exec_prefix=${opencv_prefix}/bin +libdir=${opencv_prefix}/lib +includedir=C:/OpenCV249/opencv/build/include + +Name: OpenCV +Description: Open Source Computer Vision Library +Version: 2.4.9 + +Cflags: ${includedir} ${includedir}/opencv +Libs: ${libdir}/opencv_core249 ${libdir}/opencv_imgproc249 ${libdir}/opencv_highgui249 ${libdir}/opencv_ml249 ${libdir}/opencv_video249 ${libdir}/opencv_features2d249 ${libdir}/opencv_calib3d249 ${libdir}/opencv_objdetect249 ${libdir}/opencv_contrib249 ${libdir}/opencv_legacy249 ${libdir}/opencv_flann249 ${libdir}/opencv_core249 From ce159e15e00ef92ad13607818ab7bde8341ac334 Mon Sep 17 00:00:00 2001 From: edgarsilva Date: Mon, 3 Nov 2014 18:33:34 -0600 Subject: [PATCH 12/37] Added new release make task to simplify publishing binaries and releasing to npm. Added publish-binary.md file to have as a reference on the process of making a release and publishing the binaries. --- Makefile | 30 +++++++++++++++++++++ publish-binaries.md | 64 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 94 insertions(+) create mode 100644 Makefile create mode 100644 publish-binaries.md diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..129b06f --- /dev/null +++ b/Makefile @@ -0,0 +1,30 @@ +VERSION := $(shell node -e "console.log(require('./package.json').version)") + +.PHONY: default release + +# Add a default task so we don't release just because someone ran 'make' +default: + @echo "Did you mean to release a new version?" + @echo "If so, run 'make release'." + +release: + @echo "Tagging release $(VERSION)" + @git tag -m "$(VERSION)" v$(VERSION) + + @echo "Pushing tags to GitHub" + @git push --tags + + @echo "Switching to osx-binaries branch" + @git checkout osx-binaries + + @echo "Merging master into osx-binaries" + @git merge --no-ff --commit -m "Merge master into osx-binaries [publish binary]" master + + @echo "Pushing osx-binaries" + @git push + + @echo "Switching to master branch" + @git checkout master + + @echo "Publishing to NPM" + @npm publish diff --git a/publish-binaries.md b/publish-binaries.md new file mode 100644 index 0000000..0a441a8 --- /dev/null +++ b/publish-binaries.md @@ -0,0 +1,64 @@ +How to publish the pre compiled binaries. +========================================= + +## Setup for Linux, Windows and OSX + +Every time a new tag for the latest release is pushed to github the continous integration +builds in Travis-CI and AppVeyor will generate the binaries for each platform and architecture, +package and publish to the AS3 bucket. + +This can be checked in the .travis.yml file and appveyor.yml file. Within the files there are two +methods for publishing new binaries for each version, one is if a `git tag` is detected; the other +can be triggered by passing the string `[publish binary]` in the commit message itself. + +We also have an automated make task, we should always use this task to avoid forgetting any steps +(like merging into the `osx-binaries` branch). + +The process for generating the binaries, publishing and releasing the npm module should be as follows: + +1. Merge all changes and new features into master. +2. Bump up version of npm module in `package.json`. +3. execute make task: `make release` + +This task will do the following for you: + +1. Generate new tags based on package.json version number +2. Push tags to Github +3. Checkout into `osx-binaries` branch +4. Merge `master` into `osx-binaries` +5. Push `osx-binaries` +6. Checkout master +7. Finally it will run `npm publish` + +With this we will make sure the binaries for all platforms and architectures will be generated each time +a new version is released. + + +## Config Travis, AppVeyor and Github to generate all of the binaries. + +Before we are able to run everything stated above some steps need to be taken. +Specifically for being able to publish the pre compiled binaries to AWS-S3. The +correct keys need to be setup in the travis and appveyor `.yml` files. This needs +to be done by the admin of the repo, in the case of Travis, and the owner of the account, +in the case of appveyor. + +### Setting up secure keys in Travis. + +Setting up the keys in Travis is easy if you have ruby and ruby gems installed and working then install: + +`gem install travis` + +After the travis gem is installed run the following command for each of the required keys: + +`travis encrypt SOMEVAR=secretvalue` + +And substitute the values in the `.travis.yml` file for the new ones. Detailed instructions can +be found here: http://docs.travis-ci.com/user/environment-variables/#Secure-Variables + +### Setting up secure keys in AppVeyor + +It is even easier than Travis, you do not need to install anything, just go to your account and +click in `encrypt tool`, there enter the values in the input field and click encrypt. Same as with +Travis we then need to substitute the newly generated values for the old ones. + +Detaild instructions can be found here: http://www.appveyor.com/docs/build-configuration#secure-variables From 74cc0546a8d466188f97f9650ddfdf6eeb1caa7d Mon Sep 17 00:00:00 2001 From: edgarsilva Date: Mon, 3 Nov 2014 18:43:48 -0600 Subject: [PATCH 13/37] Added info on how to create and name the branch to generate the OSX binaries --- publish-binaries.md | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/publish-binaries.md b/publish-binaries.md index 0a441a8..d2ea375 100644 --- a/publish-binaries.md +++ b/publish-binaries.md @@ -61,4 +61,11 @@ It is even easier than Travis, you do not need to install anything, just go to y click in `encrypt tool`, there enter the values in the input field and click encrypt. Same as with Travis we then need to substitute the newly generated values for the old ones. -Detaild instructions can be found here: http://www.appveyor.com/docs/build-configuration#secure-variables +Detailed instructions can be found here: http://www.appveyor.com/docs/build-configuration#secure-variables + +### OSX binaries + +Since Travis does not support config file for multiple OSs we need to create a new branch that contains +a slightly different version of the .travis.yml file to compile for OSX. The branch needs to be called +`osx-binaries` and be based of `master` once the pre-compiled binaries PR has been merged in. + From 094d91eeceea3617ce3ffd0c6f0635a1b26c96f6 Mon Sep 17 00:00:00 2001 From: edgarsilva Date: Tue, 23 Dec 2014 12:45:33 -0600 Subject: [PATCH 14/37] update cflags opencv version in bindings.gyp --- binding.gyp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/binding.gyp b/binding.gyp index f5b4168..3d16eed 100755 --- a/binding.gyp +++ b/binding.gyp @@ -26,7 +26,7 @@ ] , 'cflags': [ - '= 2.3.1" )' + '= 2.4.9" )' , '-Wall' ] , 'cflags!' : [ '-fno-exceptions'] From 4bc20cda6f12b799b3660c3722eefd0ad1c7b8fb Mon Sep 17 00:00:00 2001 From: edgarsilva Date: Wed, 4 Feb 2015 11:22:09 -0600 Subject: [PATCH 15/37] Fix issue with different versions of opencv installed in different OSs, updated cflags opencv version in bindings.gyp --- binding.gyp | 120 +++++++++++++++++++++++++++------------------------- 1 file changed, 63 insertions(+), 57 deletions(-) diff --git a/binding.gyp b/binding.gyp index 3d16eed..e13a62b 100755 --- a/binding.gyp +++ b/binding.gyp @@ -1,72 +1,78 @@ { "targets": [{ - "target_name": "opencv" - , "sources": [ - "src/init.cc" - , "src/Matrix.cc" - , "src/OpenCV.cc" - , "src/CascadeClassifierWrap.cc" - , "src/Contours.cc" - , "src/Point.cc" - , "src/VideoCaptureWrap.cc" - , "src/CamShift.cc" - , "src/HighGUI.cc" - , "src/FaceRecognizer.cc" - , "src/BackgroundSubtractor.cc" - , "src/Constants.cc" - ] - , 'libraries': [ - '= 2.4.9" )' - , '-Wall' - ] - , 'cflags!' : [ '-fno-exceptions'] - , 'cflags_cc!': [ '-fno-rtti', '-fno-exceptions'] - , "conditions": [ - ['OS=="win"', - { - 'msvs_settings': { - 'VCCLCompilerTool': { - 'ExceptionHandling': '2', - 'DisableSpecificWarnings': [ '4530', '4506', '4244' ], - }, - }, - }, - ], - ['OS=="mac"', { - # cflags on OS X are stupid and have to be defined like this - 'xcode_settings': { - 'OTHER_CFLAGS': [ - "-mmacosx-version-min=10.7", - "-std=c++11", - "-stdlib=libc++", - '= 2.3.1\" )", + "-Wall" ] - , "GCC_ENABLE_CPP_RTTI": "YES" - , "GCC_ENABLE_CPP_EXCEPTIONS": "YES" + }], + [ "OS==\"win\"", { + "cflags": [ + "= 2.4.9\" )", + "-Wall" + ], + "msvs_settings": { + "VCCLCompilerTool": { + "ExceptionHandling": "2", + "DisableSpecificWarnings": [ "4530", "4506", "4244" ], + }, + } + }], + [ # cflags on OS X are stupid and have to be defined like this + "OS==\"mac\"", { + "xcode_settings": { + "OTHER_CFLAGS": [ + "-mmacosx-version-min=10.7", + "-std=c++11", + "-stdlib=libc++", + " Date: Wed, 4 Feb 2015 11:51:29 -0600 Subject: [PATCH 16/37] Update travis opencv version. --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index d9cfb7c..6455591 100755 --- a/.travis.yml +++ b/.travis.yml @@ -13,6 +13,7 @@ env: before_install: # Fix a problem with apt-get failing later, see http://docs.travis-ci.com/user/installing-dependencies/#Installing-Ubuntu-packages + - sudo add-apt-repository -y ppa:kubuntu-ppa/backports - sudo apt-get update -qq - sudo apt-get install libcv-dev - sudo apt-get install libopencv-dev From 37bda024c28b95eff31668728577215be2c5569a Mon Sep 17 00:00:00 2001 From: edgarsilva Date: Wed, 4 Feb 2015 11:56:12 -0600 Subject: [PATCH 17/37] Force ppa update to get newer version of opencv. --- .travis.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 6455591..ff7cf32 100755 --- a/.travis.yml +++ b/.travis.yml @@ -13,8 +13,9 @@ env: before_install: # Fix a problem with apt-get failing later, see http://docs.travis-ci.com/user/installing-dependencies/#Installing-Ubuntu-packages - - sudo add-apt-repository -y ppa:kubuntu-ppa/backports - sudo apt-get update -qq + - sudo add-apt-repository -y ppa:kubuntu-ppa/backports + - sudo apt-get update - sudo apt-get install libcv-dev - sudo apt-get install libopencv-dev - sudo apt-get install libhighgui-dev From 7d16f2e0469be04982b0ef8106f41b6576c4afff Mon Sep 17 00:00:00 2001 From: edgarsilva Date: Wed, 4 Feb 2015 12:51:35 -0600 Subject: [PATCH 18/37] Return to old version of opencv to try compilation. --- .travis.yml | 4 ++-- smoke/smoketest.js | 8 ++++---- src/BackgroundSubtractor.cc | 35 ++++++++++++++++++----------------- 3 files changed, 24 insertions(+), 23 deletions(-) diff --git a/.travis.yml b/.travis.yml index ff7cf32..1508190 100755 --- a/.travis.yml +++ b/.travis.yml @@ -14,8 +14,8 @@ env: before_install: # Fix a problem with apt-get failing later, see http://docs.travis-ci.com/user/installing-dependencies/#Installing-Ubuntu-packages - sudo apt-get update -qq - - sudo add-apt-repository -y ppa:kubuntu-ppa/backports - - sudo apt-get update + # - sudo add-apt-repository -y ppa:kubuntu-ppa/backports + # - sudo apt-get update - sudo apt-get install libcv-dev - sudo apt-get install libopencv-dev - sudo apt-get install libhighgui-dev diff --git a/smoke/smoketest.js b/smoke/smoketest.js index d26d474..a34295e 100755 --- a/smoke/smoketest.js +++ b/smoke/smoketest.js @@ -1,6 +1,6 @@ -var cv = require('../lib/opencv') +var cv = require('../lib/opencv'); -var trainingData = [] +var trainingData = []; /* for (var i = 1; i< 41; i++){ for (var j = 1; j<10; j++){ @@ -22,5 +22,5 @@ cv.readImage("/Users/peterbraden/Downloads/orl_faces/s6/10.pgm", function(e, im) */ cv.readImage("./examples/files/mona.png", function(e, mat){ var th = mat.threshold(200, 200, "Threshold to Zero Inverted"); - th.save('./examples/tmp/out.png') -}) + th.save('./examples/tmp/out.png'); +}); diff --git a/src/BackgroundSubtractor.cc b/src/BackgroundSubtractor.cc index e9de264..b066529 100644 --- a/src/BackgroundSubtractor.cc +++ b/src/BackgroundSubtractor.cc @@ -21,7 +21,7 @@ BackgroundSubtractorWrap::Init(Handle target) { NODE_SET_PROTOTYPE_METHOD(ctor, "applyMOG", ApplyMOG); target->Set(NanNew("BackgroundSubtractor"), ctor->GetFunction()); - + }; NAN_METHOD(BackgroundSubtractorWrap::New) { @@ -42,17 +42,17 @@ NAN_METHOD(BackgroundSubtractorWrap::New) { NAN_METHOD(BackgroundSubtractorWrap::CreateMOG) { NanScope(); - int history = 200; - int nmixtures = 5; - double backgroundRatio = 0.7; - double noiseSigma = 0; - - if(args.Length() > 1){ - INT_FROM_ARGS(history, 0) - INT_FROM_ARGS(nmixtures, 1) - DOUBLE_FROM_ARGS(backgroundRatio, 2) - DOUBLE_FROM_ARGS(noiseSigma, 3) - } + // int history = 200; + // int nmixtures = 5; + // double backgroundRatio = 0.7; + // double noiseSigma = 0; + // + // if(args.Length() > 1){ + // INT_FROM_ARGS(history, 0) + // INT_FROM_ARGS(nmixtures, 1) + // DOUBLE_FROM_ARGS(backgroundRatio, 2) + // DOUBLE_FROM_ARGS(noiseSigma, 3) + // } Local n = NanNew(BackgroundSubtractorWrap::constructor)->GetFunction()->NewInstance(); @@ -83,13 +83,13 @@ NAN_METHOD(BackgroundSubtractorWrap::ApplyMOG) { Local fgMask = NanNew(Matrix::constructor)->GetFunction()->NewInstance(); Matrix *img = ObjectWrap::Unwrap(fgMask); - + cv::Mat mat; - + if(Buffer::HasInstance(args[0])){ uint8_t *buf = (uint8_t *) Buffer::Data(args[0]->ToObject()); - unsigned len = Buffer::Length(args[0]->ToObject()); + unsigned len = Buffer::Length(args[0]->ToObject()); cv::Mat *mbuf = new cv::Mat(len, 1, CV_64FC1, buf); mat = cv::imdecode(*mbuf, -1); //mbuf->release(); @@ -116,13 +116,13 @@ NAN_METHOD(BackgroundSubtractorWrap::ApplyMOG) { TryCatch try_catch; cb->Call(NanGetCurrentContext()->Global(), 2, argv); - + if (try_catch.HasCaught()) { FatalException(try_catch); } NanReturnUndefined(); - } + } catch( cv::Exception& e ){ const char* err_msg = e.what(); NanThrowError(err_msg); @@ -136,3 +136,4 @@ BackgroundSubtractorWrap::BackgroundSubtractorWrap(cv::Ptr Date: Wed, 4 Feb 2015 13:02:09 -0600 Subject: [PATCH 19/37] Fix missing targets from bindings to make tests pass. --- binding.gyp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/binding.gyp b/binding.gyp index e13a62b..ef75193 100755 --- a/binding.gyp +++ b/binding.gyp @@ -13,7 +13,9 @@ "src/HighGUI.cc", "src/FaceRecognizer.cc", "src/BackgroundSubtractor.cc", - "src/Constants.cc" + "src/Constants.cc", + "src/Calib3D.cc", + "src/ImgProc.cc" ], "libraries": [ From 90244f1db2cd2b22482d1c6fbdd2ee723738f9b8 Mon Sep 17 00:00:00 2001 From: edgarsilva Date: Thu, 5 Feb 2015 16:24:18 -0600 Subject: [PATCH 20/37] Print available libraries for opencv. --- appveyor.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/appveyor.yml b/appveyor.yml index 256371e..6559ec1 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -50,6 +50,8 @@ before_build: - cmd: SET OPENCV_DIR=%OPENCV_ROOT_PATH%\build\%ARCH%\vc12\bin - cmd: SET PATH=%cd%\node_modules\.bin\;C:\MinGW\bin;C:\GTK\bin;C:\msys\1.0\bin;%OPENCV_DIR%;%PATH% - cmd: SET PKG_CONFIG_PATH=C:\GTK\lib\pkgconfig + - cmd: DIR %OPENCV_ROOT_PATH%\build\%ARCH%\vc12\bin + - cmd: DIR %OPENCV_ROOT_PATH%\build\%ARCH%\vc12\lib # Here we need to copy the opencv.pc file from the repo into PKG_CONFIG_PATH # trick part is to check for the vc12 folder and use that one - cmd: copy .\utils\opencv_x64.pc C:\GTK\lib\pkgconfig\opencv.pc From 081ac43f1ba3cf610554aa5931c3674f5778787e Mon Sep 17 00:00:00 2001 From: edgarsilva Date: Thu, 5 Feb 2015 16:53:02 -0600 Subject: [PATCH 21/37] Added all opencv libraries to opencv.pc file. --- utils/opencv_x64.pc | 3 ++- utils/opencv_x86.pc | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/utils/opencv_x64.pc b/utils/opencv_x64.pc index cf1fa63..98b80c0 100644 --- a/utils/opencv_x64.pc +++ b/utils/opencv_x64.pc @@ -9,4 +9,5 @@ Description: Open Source Computer Vision Library Version: 2.4.9 Cflags: ${includedir} ${includedir}/opencv -Libs: ${libdir}/opencv_core249 ${libdir}/opencv_imgproc249 ${libdir}/opencv_highgui249 ${libdir}/opencv_ml249 ${libdir}/opencv_video249 ${libdir}/opencv_features2d249 ${libdir}/opencv_calib3d249 ${libdir}/opencv_objdetect249 ${libdir}/opencv_contrib249 ${libdir}/opencv_legacy249 ${libdir}/opencv_flann249 ${libdir}/opencv_core249 + +Libs: ${libdir}/opencv_calib3d249 ${libdir}/opencv_contrib249 ${libdir}/opencv_core249 ${libdir}/opencv_features2d249 ${libdir}/opencv_flann249 ${libdir}/opencv_gpu249 ${libdir}/opencv_highgui249 ${libdir}/opencv_imgproc249 ${libdir}/opencv_legacy249 ${libdir}/opencv_ml249 ${libdir}/opencv_nonfree249 ${libdir}/opencv_objdetect249 ${libdir}/opencv_ocl249 ${libdir}/opencv_photo249 ${libdir}/opencv_stitching249 ${libdir}/opencv_superres249 ${libdir}/opencv_ts249 ${libdir}/opencv_video249 ${libdir}/opencv_videostab249 diff --git a/utils/opencv_x86.pc b/utils/opencv_x86.pc index 7b993fc..14026a1 100644 --- a/utils/opencv_x86.pc +++ b/utils/opencv_x86.pc @@ -9,4 +9,4 @@ Description: Open Source Computer Vision Library Version: 2.4.9 Cflags: ${includedir} ${includedir}/opencv -Libs: ${libdir}/opencv_core249 ${libdir}/opencv_imgproc249 ${libdir}/opencv_highgui249 ${libdir}/opencv_ml249 ${libdir}/opencv_video249 ${libdir}/opencv_features2d249 ${libdir}/opencv_calib3d249 ${libdir}/opencv_objdetect249 ${libdir}/opencv_contrib249 ${libdir}/opencv_legacy249 ${libdir}/opencv_flann249 ${libdir}/opencv_core249 +Libs: ${libdir}/opencv_calib3d249 ${libdir}/opencv_contrib249 ${libdir}/opencv_core249 ${libdir}/opencv_features2d249 ${libdir}/opencv_flann249 ${libdir}/opencv_gpu249 ${libdir}/opencv_highgui249 ${libdir}/opencv_imgproc249 ${libdir}/opencv_legacy249 ${libdir}/opencv_ml249 ${libdir}/opencv_nonfree249 ${libdir}/opencv_objdetect249 ${libdir}/opencv_ocl249 ${libdir}/opencv_photo249 ${libdir}/opencv_stitching249 ${libdir}/opencv_superres249 ${libdir}/opencv_ts249 ${libdir}/opencv_video249 ${libdir}/opencv_videostab249 From a405869720f1575747773f189c12a20128bb8ac5 Mon Sep 17 00:00:00 2001 From: edgarsilva Date: Thu, 5 Feb 2015 17:31:04 -0600 Subject: [PATCH 22/37] Test node-pre-gyp info for 64 bit. --- appveyor.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/appveyor.yml b/appveyor.yml index 6559ec1..2f463a0 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -65,6 +65,7 @@ build_script: - cmd: ECHO "PUBLISH x64 binary package:" - cmd: npm install aws-sdk - cmd: IF %PUBLISH_BINARY%==true (node-pre-gyp package publish 2>&1) + - cmd: node-pre-gyp info - cmd: node-pre-gyp clean - cmd: node-gyp clean - cmd: npm uninstall -g node-gyp From a04ba455dd00158bcd46427ac2a473bb9c03d0d9 Mon Sep 17 00:00:00 2001 From: edgarsilva Date: Thu, 5 Feb 2015 17:48:44 -0600 Subject: [PATCH 23/37] Remove node-pre-gyp info call, since it is failing on windows. --- appveyor.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 2f463a0..0fdf15f 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -65,7 +65,7 @@ build_script: - cmd: ECHO "PUBLISH x64 binary package:" - cmd: npm install aws-sdk - cmd: IF %PUBLISH_BINARY%==true (node-pre-gyp package publish 2>&1) - - cmd: node-pre-gyp info + #- cmd: node-pre-gyp info - cmd: node-pre-gyp clean - cmd: node-gyp clean - cmd: npm uninstall -g node-gyp @@ -99,7 +99,7 @@ on_success: #- cmd: IF %PUBLISH_BINARY%==true npm install --fallback-to-build=false - cmd: npm install --fallback-to-build=false # Print Available Binaries - - cmd: node-pre-gyp info + #- cmd: node-pre-gyp info test: OFF From 055c7a24052633b259d77bdfefda61911fc0b526 Mon Sep 17 00:00:00 2001 From: edgarsilva Date: Thu, 5 Feb 2015 18:31:13 -0600 Subject: [PATCH 24/37] Bring back node-pre-gyp info to investigate why branch passes but not master. --- appveyor.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 0fdf15f..6559ec1 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -65,7 +65,6 @@ build_script: - cmd: ECHO "PUBLISH x64 binary package:" - cmd: npm install aws-sdk - cmd: IF %PUBLISH_BINARY%==true (node-pre-gyp package publish 2>&1) - #- cmd: node-pre-gyp info - cmd: node-pre-gyp clean - cmd: node-gyp clean - cmd: npm uninstall -g node-gyp @@ -99,7 +98,7 @@ on_success: #- cmd: IF %PUBLISH_BINARY%==true npm install --fallback-to-build=false - cmd: npm install --fallback-to-build=false # Print Available Binaries - #- cmd: node-pre-gyp info + - cmd: node-pre-gyp info test: OFF From 44695e0c61cb70af9fe10e3aadfec62f96871211 Mon Sep 17 00:00:00 2001 From: edgarsilva Date: Fri, 6 Feb 2015 11:26:46 -0600 Subject: [PATCH 25/37] Test install from pre compiled binaries --- appveyor.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 6559ec1..257ed74 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -59,7 +59,8 @@ before_build: # to run your custom scripts instead of automatic MSBuild build_script: - cmd: ECHO "BUILDING x64 binary package:" - - cmd: npm install --build-from-source --msvs_version=2013 + #- cmd: npm install --build-from-source --msvs_version=2013 + - cmd: npm install --msvs_version=2013 - cmd: npm test - cmd: node lib/opencv.js - cmd: ECHO "PUBLISH x64 binary package:" @@ -81,7 +82,8 @@ after_build: - cmd: npm install -g node-gyp - cmd: copy .\utils\opencv_x86.pc C:\GTK\lib\pkgconfig\opencv.pc - cmd: ECHO "BUILDING x86 binary package:" - - cmd: npm install --build-from-source --msvs_version=2013 + #- cmd: npm install --build-from-source --msvs_version=2013 + - cmd: npm install --msvs_version=2013 - cmd: npm test - cmd: node lib/opencv.js - cmd: ECHO "PUBLISH x86 binary package:" From 3558be3d50f03e80b002b519762f09b18ea790a3 Mon Sep 17 00:00:00 2001 From: edgarsilva Date: Fri, 6 Feb 2015 15:40:25 -0600 Subject: [PATCH 26/37] Always build from source in appveyor. --- appveyor.yml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 257ed74..6559ec1 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -59,8 +59,7 @@ before_build: # to run your custom scripts instead of automatic MSBuild build_script: - cmd: ECHO "BUILDING x64 binary package:" - #- cmd: npm install --build-from-source --msvs_version=2013 - - cmd: npm install --msvs_version=2013 + - cmd: npm install --build-from-source --msvs_version=2013 - cmd: npm test - cmd: node lib/opencv.js - cmd: ECHO "PUBLISH x64 binary package:" @@ -82,8 +81,7 @@ after_build: - cmd: npm install -g node-gyp - cmd: copy .\utils\opencv_x86.pc C:\GTK\lib\pkgconfig\opencv.pc - cmd: ECHO "BUILDING x86 binary package:" - #- cmd: npm install --build-from-source --msvs_version=2013 - - cmd: npm install --msvs_version=2013 + - cmd: npm install --build-from-source --msvs_version=2013 - cmd: npm test - cmd: node lib/opencv.js - cmd: ECHO "PUBLISH x86 binary package:" From c36350ade89844cd05ece165f06f60ec40bcfcc4 Mon Sep 17 00:00:00 2001 From: Peter Braden Date: Wed, 11 Feb 2015 18:32:25 +0100 Subject: [PATCH 27/37] Move smoke test into makefile --- Makefile | 14 +++++++++----- smoke/smoke.sh | 14 -------------- 2 files changed, 9 insertions(+), 19 deletions(-) delete mode 100755 smoke/smoke.sh diff --git a/Makefile b/Makefile index 129b06f..bcacd40 100644 --- a/Makefile +++ b/Makefile @@ -1,11 +1,15 @@ VERSION := $(shell node -e "console.log(require('./package.json').version)") -.PHONY: default release +.PHONY: default release smoke + +test: + npm test + +smoke: + npm install --build-from-source + node smoke/smoketest.js + npm test -# Add a default task so we don't release just because someone ran 'make' -default: - @echo "Did you mean to release a new version?" - @echo "If so, run 'make release'." release: @echo "Tagging release $(VERSION)" diff --git a/smoke/smoke.sh b/smoke/smoke.sh deleted file mode 100755 index 84fab84..0000000 --- a/smoke/smoke.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/bash - -if [ ! -f smoke/smoketest.js ]; then - echo "Please run smoke test from the top-level folder of the repository." >&2 - exit 1 -fi - -node-gyp build && echo '-- Compiled OK -- - -' && node smoke/smoketest.js && echo '-- Smoke Done, running tests -- - -' && npm test # && echo '-- Tests Run, runnning examples -- -#(building example data) -#' && ./examples/make-example-files.sh && node examples/motion-track.js From cfc6c16721fa79b6a45e9b1e9a0e37a536c1a08a Mon Sep 17 00:00:00 2001 From: Peter Braden Date: Wed, 11 Feb 2015 18:35:00 +0100 Subject: [PATCH 28/37] Remove unused 'sleep_for' variable to suppress compile warning --- src/CascadeClassifierWrap.cc | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/CascadeClassifierWrap.cc b/src/CascadeClassifierWrap.cc index d2f8871..ac8a35f 100755 --- a/src/CascadeClassifierWrap.cc +++ b/src/CascadeClassifierWrap.cc @@ -50,7 +50,7 @@ CascadeClassifierWrap::CascadeClassifierWrap(v8::Value* fileName){ class AsyncDetectMultiScale : public NanAsyncWorker { public: - AsyncDetectMultiScale(NanCallback *callback, CascadeClassifierWrap *cc, Matrix* im, double scale, int neighbors, int minw, int minh, int sleep_for) : NanAsyncWorker(callback), cc(cc), im(im), scale(scale), neighbors(neighbors), minw(minw), minh(minh), sleep_for(sleep_for) {} + AsyncDetectMultiScale(NanCallback *callback, CascadeClassifierWrap *cc, Matrix* im, double scale, int neighbors, int minw, int minh) : NanAsyncWorker(callback), cc(cc), im(im), scale(scale), neighbors(neighbors), minw(minw), minh(minh) {} ~AsyncDetectMultiScale() {} void Execute () { @@ -103,7 +103,6 @@ class AsyncDetectMultiScale : public NanAsyncWorker { int neighbors; int minw; int minh; - int sleep_for; std::vector res; }; @@ -141,7 +140,7 @@ NAN_METHOD(CascadeClassifierWrap::DetectMultiScale){ NanCallback *callback = new NanCallback(cb.As()); - NanAsyncQueueWorker( new AsyncDetectMultiScale(callback, self, im, scale, neighbors, minw, minh, 1) ); + NanAsyncQueueWorker( new AsyncDetectMultiScale(callback, self, im, scale, neighbors, minw, minh) ); NanReturnUndefined(); } From 0c72d55ec447b55ef6fa625240046147dfdbba5e Mon Sep 17 00:00:00 2001 From: Peter Braden Date: Wed, 11 Feb 2015 20:15:01 +0100 Subject: [PATCH 29/37] Fix example paths --- examples/car-detection.js | 8 ++++---- examples/color-filter.js | 4 ++-- examples/contours.js | 8 ++++---- examples/convert-image.js | 12 ++++++------ examples/detect-shapes.js | 6 +++--- examples/face-detection-rectangle.js | 8 ++++---- examples/face-detection.js | 8 ++++---- examples/quad-crosses.js | 6 +++--- examples/salt.js | 2 +- examples/warp-image.js | 4 ++-- test/examples.js | 7 ++++++- 11 files changed, 39 insertions(+), 34 deletions(-) diff --git a/examples/car-detection.js b/examples/car-detection.js index 95a5afa..58c2d61 100644 --- a/examples/car-detection.js +++ b/examples/car-detection.js @@ -1,10 +1,10 @@ var cv = require('../lib/opencv'); -cv.readImage("./examples/files/car1.jpg", function(err, im){ +cv.readImage("./files/car1.jpg", function(err, im){ if (err) throw err; if (im.width() < 1 || im.height() < 1) throw new Error('Image has no size'); - im.detectObject("./data/hogcascade_cars_sideview.xml", {}, function(err, cars){ + im.detectObject("../data/hogcascade_cars_sideview.xml", {}, function(err, cars){ if (err) throw err; for (var i=0; i < cars.length; i++){ @@ -12,7 +12,7 @@ cv.readImage("./examples/files/car1.jpg", function(err, im){ im.rectangle([x.x, x.y], [x.width, x.height]); } - im.save('./examples/tmp/car-detection.jpg'); - console.log('Image saved to ./examples/tmp/car-detection.jpg'); + im.save('./tmp/car-detection.jpg'); + console.log('Image saved to ./tmp/car-detection.jpg'); }); }); diff --git a/examples/color-filter.js b/examples/color-filter.js index 031b65d..b7c5d6a 100644 --- a/examples/color-filter.js +++ b/examples/color-filter.js @@ -4,11 +4,11 @@ var cv = require('../lib/opencv'); var lower_threshold = [46, 57, 83]; var upper_threshold = [80, 96, 115]; -cv.readImage('./examples/files/coin1.jpg', function(err, im) { +cv.readImage('./files/coin1.jpg', function(err, im) { if (err) throw err; if (im.width() < 1 || im.height() < 1) throw new Error('Image has no size'); im.inRange(lower_threshold, upper_threshold); - im.save('./examples/tmp/coin_detected.jpg'); + im.save('./tmp/coin_detected.jpg'); console.log('Image saved to ./tmp/coin_detected.jpg'); }); diff --git a/examples/contours.js b/examples/contours.js index 842011e..43bb0ac 100755 --- a/examples/contours.js +++ b/examples/contours.js @@ -9,7 +9,7 @@ var GREEN = [0, 255, 0]; // B, G, R var WHITE = [255, 255, 255]; // B, G, R var RED = [0, 0, 255]; // B, G, R -cv.readImage('./examples/files/stuff.png', function(err, im) { +cv.readImage('./files/stuff.png', function(err, im) { if (err) throw err; var width = im.width(); var height = im.height(); @@ -39,7 +39,7 @@ cv.readImage('./examples/files/stuff.png', function(err, im) { all.drawAllContours(contours, WHITE); - big.save('./examples/tmp/big.png'); - all.save('./examples/tmp/all.png'); - console.log('Image saved to ./examples/tmp/big.png && ./tmp/all.png'); + big.save('./tmp/big.png'); + all.save('./tmp/all.png'); + console.log('Image saved to ./tmp/big.png && ./tmp/all.png'); }); diff --git a/examples/convert-image.js b/examples/convert-image.js index dbc9f0c..7f62ff3 100755 --- a/examples/convert-image.js +++ b/examples/convert-image.js @@ -1,6 +1,6 @@ var cv = require('../lib/opencv'); -cv.readImage('./examples/files/mona.png', function(err, im) { +cv.readImage('./files/mona.png', function(err, im) { if (err) throw err; if (im.width() < 1 || im.height() < 1) throw new Error('Image has no size'); @@ -10,12 +10,12 @@ cv.readImage('./examples/files/mona.png', function(err, im) { img_hsv.convertHSVscale(); img_gray.convertGrayscale(); - im.save('./examples/tmp/nor.png'); - img_hsv.save('./examples/tmp/hsv.png'); - img_gray.save('./examples/tmp/gray.png'); + im.save('./tmp/nor.png'); + img_hsv.save('./tmp/hsv.png'); + img_gray.save('./tmp/gray.png'); img_crop = im.crop(50,50,250,250); - img_crop.save('./examples/tmp/crop.png'); + img_crop.save('./tmp/crop.png'); - console.log('Image saved to ./examples/tmp/{crop|nor|hsv|gray}.png'); + console.log('Image saved to ./tmp/{crop|nor|hsv|gray}.png'); }); diff --git a/examples/detect-shapes.js b/examples/detect-shapes.js index 6326995..f465d23 100755 --- a/examples/detect-shapes.js +++ b/examples/detect-shapes.js @@ -12,7 +12,7 @@ var GREEN = [0, 255, 0]; // B, G, R var WHITE = [255, 255, 255]; // B, G, R -cv.readImage('./examples/files/shapes.jpg', function(err, im) { +cv.readImage('./files/shapes.jpg', function(err, im) { if (err) throw err; width = im.width() @@ -46,6 +46,6 @@ cv.readImage('./examples/files/shapes.jpg', function(err, im) { } } - out.save('./examples/tmp/detect-shapes.png'); - console.log('Image saved to ./examples/tmp/detect-shapes.png'); + out.save('./tmp/detect-shapes.png'); + console.log('Image saved to ./tmp/detect-shapes.png'); }); diff --git a/examples/face-detection-rectangle.js b/examples/face-detection-rectangle.js index e2d4f87..f108eee 100755 --- a/examples/face-detection-rectangle.js +++ b/examples/face-detection-rectangle.js @@ -3,11 +3,11 @@ var cv = require('../lib/opencv'); var COLOR = [0, 255, 0]; // default red var thickness = 2; // default 1 -cv.readImage('./examples/files/mona.png', function(err, im) { +cv.readImage('./files/mona.png', function(err, im) { if (err) throw err; if (im.width() < 1 || im.height() < 1) throw new Error('Image has no size'); - im.detectObject('./data/haarcascade_frontalface_alt2.xml', {}, function(err, faces) { + im.detectObject('../data/haarcascade_frontalface_alt2.xml', {}, function(err, faces) { if (err) throw err; for (var i = 0; i < faces.length; i++) { @@ -15,8 +15,8 @@ cv.readImage('./examples/files/mona.png', function(err, im) { im.rectangle([face.x, face.y], [face.x + face.width, face.y + face.height], COLOR, 2); } - im.save('./examples/tmp/face-detection-rectangle.png'); - console.log('Image saved to ./examples/tmp/face-detection-rectangle.png'); + im.save('./tmp/face-detection-rectangle.png'); + console.log('Image saved to ./tmp/face-detection-rectangle.png'); }); }); diff --git a/examples/face-detection.js b/examples/face-detection.js index 185a78b..0cc5fee 100755 --- a/examples/face-detection.js +++ b/examples/face-detection.js @@ -1,10 +1,10 @@ var cv = require('../lib/opencv'); -cv.readImage("./examples/files/mona.png", function(err, im){ +cv.readImage("./files/mona.png", function(err, im){ if (err) throw err; 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; for (var i = 0; i < faces.length; i++){ @@ -12,7 +12,7 @@ cv.readImage("./examples/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.save('./examples/tmp/face-detection.png'); - console.log('Image saved to ./examples/tmp/face-detection.png'); + im.save('./tmp/face-detection.png'); + console.log('Image saved to ./tmp/face-detection.png'); }); }); diff --git a/examples/quad-crosses.js b/examples/quad-crosses.js index 1a3a558..341631f 100755 --- a/examples/quad-crosses.js +++ b/examples/quad-crosses.js @@ -12,7 +12,7 @@ var RED = [0, 0, 255]; //B, G, R var GREEN = [0, 255, 0]; //B, G, R var WHITE = [255, 255, 255]; //B, G, R -cv.readImage('./examples/files/quads.jpg', function(err, im) { +cv.readImage('./files/quads.jpg', function(err, im) { if (err) throw err; if (im.width() < 1 || im.height() < 1) throw new Error('Image has no size'); @@ -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.save('./examples/tmp/quad-crosses.png'); - console.log('Image saved to ./examples/tmp/quad-crosses.png'); + out.save('./tmp/quad-crosses.png'); + console.log('Image saved to ./tmp/quad-crosses.png'); }); diff --git a/examples/salt.js b/examples/salt.js index d3212b2..737e834 100755 --- a/examples/salt.js +++ b/examples/salt.js @@ -1,7 +1,7 @@ var cv = require('../lib/opencv'); cv.readImage("./files/mona.png", function(err, im) { - salt(im, 1000); + salt(im, 100); im.save("./tmp/salt.png"); console.log('Image saved to ./tmp/salt.png'); }); diff --git a/examples/warp-image.js b/examples/warp-image.js index bcf13b8..8549bf9 100644 --- a/examples/warp-image.js +++ b/examples/warp-image.js @@ -1,6 +1,6 @@ var cv = require('../lib/opencv'); -cv.readImage("./examples/files/mona.png", function(err, im) { +cv.readImage("./files/mona.png", function(err, im) { if (err) throw err; var width = im.width(); @@ -11,6 +11,6 @@ cv.readImage("./examples/files/mona.png", function(err, im) { var dstArray = [0, 0, width * 0.9, height * 0.1, width, height, width * 0.2, height * 0.8]; var xfrmMat = im.getPerspectiveTransform(srcArray, dstArray); im.warpPerspective(xfrmMat, width, height, [255, 255, 255]); - im.save("./examples/tmp/warp-image.png"); + im.save("./tmp/warp-image.png"); console.log('Image saved to ./tmp/warp-image.png'); }); diff --git a/test/examples.js b/test/examples.js index b48a743..23f0f14 100644 --- a/test/examples.js +++ b/test/examples.js @@ -1,12 +1,17 @@ var test = require('tape') , glob = require('glob') , exec = require('child_process').exec + , path = require('path') module.exports = function(){ glob.sync('./examples/*.js').forEach(function(example){ test("Example: " + example, function(assert){ - exec('node ' + example, function(error, stdout, stderr){ + + var fullName = path.resolve(example) + , examples = path.resolve('./examples') + + exec('node ' + fullName, {cwd: examples}, function(error, stdout, stderr){ assert.error(error) assert.end() }) From 7af5707be13798e12e7768556a1bebb074820a9b Mon Sep 17 00:00:00 2001 From: Peter Braden Date: Wed, 11 Feb 2015 20:24:17 +0100 Subject: [PATCH 30/37] Update Car Detection cascade for example re http://code.opencv.org/issues/2387 --- data/hogcascade_cars_sideview.xml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/data/hogcascade_cars_sideview.xml b/data/hogcascade_cars_sideview.xml index 167705b..8860c16 100644 --- a/data/hogcascade_cars_sideview.xml +++ b/data/hogcascade_cars_sideview.xml @@ -1,6 +1,6 @@ - + BOOST HOG 24 @@ -835,5 +835,7 @@ 16 8 16 8 24 <_> - 16 8 16 8 28 + 16 8 16 8 28 + + From 2eaf099b35ad8f2cac68ef6e5274d52b89e1eb15 Mon Sep 17 00:00:00 2001 From: Peter Braden Date: Wed, 11 Feb 2015 20:38:39 +0100 Subject: [PATCH 31/37] New Travis keys --- .travis.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index e516cf6..5c752dd 100755 --- a/.travis.yml +++ b/.travis.yml @@ -9,8 +9,10 @@ compiler: clang env: global: - - secure: v7yz4KwR5+Iv7+oPs54wAK6/fYp7xnEDmbbr2z5F2i8NaG5Qvi4AGwfRuPTLNAeFhpapzL8wk8LI4NfxChUe2S1Rj9ytpW350wtHNcIEBiJXsbfKBeHCZQcZnlx+KofmuP//BRjO3kiVgilOxuLvVbdA9Ob/6ixAdKTHl0yk+NA= - - secure: ehjkxVYyBwL9dZAD1w/D3oEN2lWQebN44CnrftTYw0xVPiYsNeCKV0SpTs/RIlhhiVlQjZRmZbt+My213q32vYdKGEv4TGyyiSfy3BQz+hkXb5vCtxS0WZjfQpxcApYlh9bLh4LzvCcEXe6RrdLSApTXVh9PPiKVGBPtZjLXfZU= + - secure: "kCAwXdfcMv4l4ok5lO89ANbKXXwWQpn5/3qupSbhmX2NDIGUxyXze/cs90u9gF5hcT7ebq27ZJPEtu7pRov8MadfQM9BAd4ZZrHcMHWSkA0Iz+nM+m0Urwach6jkp2Iuwx15L2NHSis7f5PUKJcEv4Gnqs8jrCJzHHS7m7dO0Xo=" + - secure: "lBIk4BhdIkSmJtFUNp93UjDm445i9eF7nKA+oSiLRu+b9i/WeRLiKFI89tehexWeXBlyNhziBN16LrHmx3I86yZfEok9dBMA1JuzYBjrvpjRAflGcqaCFLV3axyyyNQRIh7Q+ziAlg0xg8HL752BpnfXO91g3jfDPjGxcvBb5xQ=" + + before_install: # Fix a problem with apt-get failing later, see http://docs.travis-ci.com/user/installing-dependencies/#Installing-Ubuntu-packages From bd6629de47cf4ca4f4e661f60379dbd8e9ace166 Mon Sep 17 00:00:00 2001 From: Peter Braden Date: Wed, 11 Feb 2015 20:46:15 +0100 Subject: [PATCH 32/37] Appveyor keys --- appveyor.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 6559ec1..aacd7c5 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,9 +1,9 @@ # environment variables environment: node_pre_gyp_accessKeyId: - secure: hTQMi31kndQOPU0AZVkVXgH7Vc3EjJmvThFwMYhkno4= + secure: 3GHZvq0y83PQ8Qi7FOc5rKoULRQvd2OohhtGqRQLZB4 node_pre_gyp_secretAccessKey: - secure: ZOsWmB5rxfiPgPW5bCuvkK1UUEupssSoHfK5jWcJBJsPuPWQHEWOr1lUteVbx2NV + secure: AiX8Bx+U8LKu5JZHb5CMth5xOHuWawkQW3il0OFWfV4kodPZnC8dLYIqb4XZeF7f # try on unstable version of the server to build node-opencv os: unstable From f485906bc08d966d99bd530460b5aa6ed4e79318 Mon Sep 17 00:00:00 2001 From: Peter Braden Date: Wed, 11 Feb 2015 20:52:56 +0100 Subject: [PATCH 33/37] [publish binary] Lets test this From efc2f6a8818b8ccb05a58e5c7f4edeafa81a2ad0 Mon Sep 17 00:00:00 2001 From: Peter Braden Date: Wed, 11 Feb 2015 21:17:30 +0100 Subject: [PATCH 34/37] Missed a character... [publish binary] --- appveyor.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/appveyor.yml b/appveyor.yml index aacd7c5..d508c3d 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,7 +1,7 @@ # environment variables environment: node_pre_gyp_accessKeyId: - secure: 3GHZvq0y83PQ8Qi7FOc5rKoULRQvd2OohhtGqRQLZB4 + secure: 3GHZvq0y83PQ8Qi7FOc5rKoULRQvd2OohhtGqRQLZB4= node_pre_gyp_secretAccessKey: secure: AiX8Bx+U8LKu5JZHb5CMth5xOHuWawkQW3il0OFWfV4kodPZnC8dLYIqb4XZeF7f From 2c6ec42ffd19b3bda9dab2b9a7ca7470185d3249 Mon Sep 17 00:00:00 2001 From: Peter Braden Date: Wed, 11 Feb 2015 21:24:59 +0100 Subject: [PATCH 35/37] Don't fail the build if package upload fails --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 5c752dd..5101789 100755 --- a/.travis.yml +++ b/.travis.yml @@ -50,7 +50,7 @@ install: before_script: - echo "Publishing native platform Binary Package? ->" $PUBLISH_BINARY # if publishing, do it - - if [[ $PUBLISH_BINARY == true ]]; then node-pre-gyp package publish; fi; + - if [[ $PUBLISH_BINARY == true ]]; then node-pre-gyp package publish || true ; fi; # cleanup - node-pre-gyp clean - node-gyp clean From efb9bf5356a39d76df556da1fb7d7e613e5371e6 Mon Sep 17 00:00:00 2001 From: Peter Braden Date: Wed, 11 Feb 2015 21:38:49 +0100 Subject: [PATCH 36/37] disable broken example --- examples/car-detection.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/examples/car-detection.js b/examples/car-detection.js index 58c2d61..df296d6 100644 --- a/examples/car-detection.js +++ b/examples/car-detection.js @@ -1,3 +1,6 @@ +/* For some reason the cascade file is broken on linux :( + + var cv = require('../lib/opencv'); cv.readImage("./files/car1.jpg", function(err, im){ @@ -16,3 +19,4 @@ cv.readImage("./files/car1.jpg", function(err, im){ console.log('Image saved to ./tmp/car-detection.jpg'); }); }); +*/ From 94dcfda3c254747fd6b45ad82eacb9517d690f85 Mon Sep 17 00:00:00 2001 From: Peter Braden Date: Wed, 11 Feb 2015 21:47:31 +0100 Subject: [PATCH 37/37] Bump the version. 3.0.0 --- CHANGELOG.md | 11 +++++++++++ package.json | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d5a7a62..3b6dc89 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,17 @@ # Changelog +### 3.0.0 + +You wait ages for a release, and 2 come along at once... + +This one is awesome. It adds prebuilt binaries, so you don't need +to build opencv for the common platforms. + +Many many thanks to @edgarsilva for awesome work here, and +http://hybridgroup.com/ for hosting the binaries + + ### 2.0.0 - Support for node 0.12 diff --git a/package.json b/package.json index 5f835b8..27ea033 100755 --- a/package.json +++ b/package.json @@ -7,7 +7,7 @@ "buffers": "0.1.1", "nan": "1.4.3" }, - "version": "2.0.0", + "version": "3.0.0", "devDependencies": { "tape": "^3.0.0", "aws-sdk": "~2.0.21"