From 64bde45c7454b28d98bcd4fab99b7c77e09856b7 Mon Sep 17 00:00:00 2001 From: Liu Liu Date: Sat, 6 Nov 2010 17:16:36 -0400 Subject: [PATCH] nasty bug, good observation made by Christian Schneider --- js/ccv.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/js/ccv.js b/js/ccv.js index 2ebc2a8fb..27ba28379 100644 --- a/js/ccv.js +++ b/js/ccv.js @@ -39,7 +39,7 @@ var ccv = { __worker_scripts : {}, spawn : function (pre, script, params, post, complete, worker_num) { - var params = ccv.__get_named_arguments(arguments, ["pre", "script", "params", "post", "complete"]); + var params = ccv.__get_named_arguments(arguments, ["pre", "script", "params", "post", "complete", "worker_num"]); var worker = new Worker("ccv.js"); worker.onmessage = function (event) { params.complete(params.post((typeof event.data == "string") ? JSON.parse(event.data) : event.data)); @@ -134,10 +134,12 @@ var ccv = { detect_objects : function (canvas, cascade, interval, min_neighbors, complete, worker_num, setup) { var params = ccv.__get_named_arguments(arguments, ["canvas", "cascade", "interval", "min_neighbors", "complete", "worker_num", "setup"]); - var cascade = params.cascade; - var scale = Math.pow(2, 1 / (params.interval + 1)); - var next = params.interval + 1; - var scale_upto = (cascade !== undefined) ? Math.floor(Math.log(Math.min(cascade.width, cascade.height)) / Math.log(scale)) : 0; + if (!params.setup) { + var cascade = params.cascade; + var scale = Math.pow(2, 1 / (params.interval + 1)); + var next = params.interval + 1; + var scale_upto = Math.floor(Math.log(Math.min(params.canvas.width / cascade.width, params.canvas.height / cascade.height)) / Math.log(scale)); + } var pre = function () { var pyr = new Array((scale_upto + next * 2) * 4); var ret = new Array((scale_upto + next * 2) * 4); @@ -196,7 +198,7 @@ var ccv = { var cascade = params.cascade; var scale = Math.pow(2, 1 / (params.interval + 1)); var next = params.interval + 1; - var scale_upto = Math.floor(Math.log(Math.min(cascade.width, cascade.height)) / Math.log(scale)); + var scale_upto = Math.floor(Math.log(Math.min(pyr[0].width / cascade.width, pyr[0].height / cascade.height)) / Math.log(scale)); var i, j, k, x, y, q; var scale_x = 1, scale_y = 1; var dx = [0, 1, 0, 1];