Permalink
Browse files

demo tweaks

  • Loading branch information...
1 parent 4875abe commit efdcdd0bac21365b3ac49f8fc9a328bfd3adc5bf @harthur committed Jun 6, 2012
Showing with 19 additions and 11 deletions.
  1. +13 −7 demo/demo.js
  2. +1 −1 demo/index.css
  3. +1 −1 demo/index.html
  4. +3 −1 demo/kittydar-browser.js
  5. +1 −1 kittydar.js
View
@@ -41,10 +41,12 @@ function handleFiles(files) {
var reader = new FileReader();
reader.onload = function(e) {
+ img.onload = function() {
+ drawToCanvas(img);
+ detector.abortCurrent();
+ detector.detectCats();
+ }
img.src = e.target.result;
- drawToCanvas(img);
-
- detector.detectCats();
};
reader.readAsDataURL(file);
@@ -77,7 +79,11 @@ function drawToCanvas(img) {
}
var detector = {
- minWindow: 48,
+ abortCurrent: function() {
+ if (this.worker) {
+ this.worker.terminate();
+ }
+ },
detectCats: function() {
var canvas = $("#preview").get(0);
@@ -87,8 +93,10 @@ var detector = {
worker.onmessage = this.onMessage;
worker.onerror = this.onError;
- var resizes = kittydar.getAllSizes(canvas, this.minWindow);
+ var resizes = kittydar.getAllSizes(canvas);
worker.postMessage(resizes);
+
+ this.worker = worker;
}
else {
var rects = kittydar.detectCats(canvas, network);
@@ -97,8 +105,6 @@ var detector = {
},
paintRects : function(rects) {
- console.log(rects.length);
-
var canvas = $("#annotations").get(0);
var ctx = canvas.getContext("2d");
View
@@ -19,7 +19,7 @@ body {
#container {
width: 900px;
- margin: 100px auto;
+ margin: 100px auto 0px auto;
text-align: center;
}
View
@@ -27,6 +27,6 @@
</div>
</div>
- <div id="drawing">1</div>
+ <div id="drawing" hidden=true>1</div>
</body>
</html>
View
@@ -1,4 +1,6 @@
var kittydar = {
+ minWindow: 48,
+
detectCats: function(canvas, options) {
this.setOptions(options || {});
@@ -14,7 +16,7 @@ var kittydar = {
setOptions: function(options) {
this.minWindow = options.minWindow || 48;
- this.threshold = options.threshold || 0.98;
+ this.threshold = options.threshold || 0.999;
this.network = options.network || network;
this.HOGparams = options.HOGparams || {
"cellSize": 4,
View
@@ -40,7 +40,7 @@ var kittydar = {
var imagedata = this.resizeToFixed(canvas, winScale);
resizes.push({
- imagedata: imagedata,
+ imagedata: imagedata
scale: winScale
})
}

0 comments on commit efdcdd0

Please sign in to comment.