Skip to content
Browse files

fix unit test

  • Loading branch information...
1 parent 20fa7a1 commit 7d43360b722a44b159b64d2b7cfb7aa2b753a687 @peterbraden committed
Showing with 25 additions and 11 deletions.
  1. BIN examples/coin1.jpg
  2. BIN examples/coin2.jpg
  3. +1 −1 examples/motion-track.js
  4. +4 −2 smoke/smoke.sh
  5. +20 −8 test/unit.js
View
BIN examples/coin1.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN examples/coin2.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
2 examples/motion-track.js
@@ -13,7 +13,7 @@ vid.read(function(mat){
console.log(">>", x, ":" , rec)
if (x % 10 == 0){
m2.rectangle([rec[0], rec[1]], [rec[2], rec[3]])
- m2.save('./out' + x + '.jpg')
+ m2.save('./out-motiontrack-' + x + '.jpg')
}
if (x<100)
iter();
View
6 smoke/smoke.sh
@@ -1,6 +1,8 @@
#!/bin/bash
node-gyp build && echo '-- Compiled OK --
-' && node examples/motion-track.js && 0 && node smoke/smoketest.js && echo '-- Smoke Done, running tests --
+' && node smoke/smoketest.js && echo '-- Smoke Done, running tests --
-' && npm test
+' && npm test && echo '-- Tests Run, runnning examples --
+(building example data)
+' && ./examples/make-example-files.sh && node examples/motion-track.js
View
28 test/unit.js
@@ -9,6 +9,16 @@ assertDeepSimilar = function(res, exp){
assert.deepEqual(res, exp)
}
+assertWithinRange = function(res, exp, range){
+ assert.ok((res - exp) < range || (res - exp) > -range, "Not within range:" + res + " (" + exp + "+- " + range + ")")
+}
+
+assertWithinRanges = function(res, exp, range){
+ for (var i =0; i<res.length; i++){
+ assertWithinRange(res[i], exp[i], range);
+ }
+}
+
vows.describe('Smoke Tests OpenCV').addBatch({
"Importing": {
@@ -263,20 +273,22 @@ vows.describe('Smoke Tests OpenCV').addBatch({
topic : function(){
var cv = require('../lib/opencv')
, self = this
-
- var im = cv.readImage('./examples/mona.png', function(e, im){
- self.callback(im, cv)
+
+ cv.readImage('./examples/coin1.jpg', function(e, im){
+ cv.readImage('./examples/coin2.jpg', function(e, im2){
+ self.callback(im, im2, cv)
+ })
})
}
- , "create TrackedObject" : function(im, cv){
- var tracked = new cv.TrackedObject(im, [0, 0, 50, 50]);
+ , "create TrackedObject" : function(im, im2, cv){
+ var tracked = new cv.TrackedObject(im, [420, 110, 490, 170]);
assert.ok(tracked);
}
- , "use TrackedObject.track" : function(im,cv){
- var tracked = new cv.TrackedObject(im, [0, 0, 50, 50]);
- assert.equal(tracked.track(im), [10, 10, 50, 50]);
+ , "use TrackedObject.track" : function(im, im2, cv){
+ var tracked = new cv.TrackedObject(im, [420, 110, 490, 170], {channel: 'v'});
+ assertWithinRanges(tracked.track(im2), [386, 112, 459, 166], 10);
}
}

0 comments on commit 7d43360

Please sign in to comment.
Something went wrong with that request. Please try again.