Skip to content

Commit 2843697

Browse files
committed
v.1.0.2 contd
* update included examples
1 parent e981138 commit 2843697

File tree

6 files changed

+28
-24
lines changed

6 files changed

+28
-24
lines changed

examples/eye.html

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,15 +54,16 @@ <h1>Eye Detection with eye haar cascade by Mar Canet in JavaScript</h1>
5454
image.onload=function(){
5555
// profile
5656
//console.timeEnd('ImageLoad');
57-
wait.style.display='block';
58-
canvas.width=image.width; canvas.height=image.height;
59-
canvas.getContext('2d').drawImage(image,0,0);
57+
wait.style.display = 'block';
58+
canvas.width = image.width;
59+
canvas.height = image.height;
60+
canvas.getContext('2d').drawImage(image, 0, 0);
6061

6162
// profile
6263
//console.time('FeatureDetect');
6364
// detect the feature
6465
new HAAR.Detector(haarcascade_eye, useParallel) // much faster when using parallel computation
65-
.image(image, 0.8) // use the image
66+
.image(image, /*0.8*/150 / image.width) // use the image with standardised dimensions
6667
.interval(50) // set detection interval for asynchronous detection (if not parallel)
6768
.complete(function(){ // onComplete callback
6869
// profile
@@ -85,8 +86,8 @@ <h1>Eye Detection with eye haar cascade by Mar Canet in JavaScript</h1>
8586
log(this.objects.toString());
8687
alert(l+" Objects found");
8788
})
88-
.cannyThreshold({low:5, high:100}) // custom thresholds for canny pruning (for best results)
89-
.detect(1, 1.25, 0.5, 1, true); // go
89+
.cannyThreshold({low:5, high:200}) // custom thresholds for canny pruning (for best results)
90+
.detect(1, 1.1, 0.12, 1, 0.2, true); // go
9091
};
9192
// profile
9293
//console.time('ImageLoad');

examples/face.html

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,14 @@ <h1>Face Detection with OpenCV haar cascades in JavaScript</h1>
5252
}
5353

5454
image.onload=function(){
55-
wait.style.display='block';
56-
canvas.width=image.width; canvas.height=image.height;
57-
ctx.drawImage(image,0,0);
55+
wait.style.display = 'block';
56+
canvas.width = image.width;
57+
canvas.height = image.height;
58+
ctx.drawImage(image, 0, 0);
5859

5960
// detect the feature
6061
new HAAR.Detector(haarcascade_frontalface_alt, useParallel)
61-
.image(image) // use the image
62+
.image(image, 150 / image.width) // use the image with standardised dimensions
6263
.interval(40) // set detection interval for asynchronous detection (if not parallel)
6364
.complete(function(){ // onComplete callback
6465
var i, rect, l=this.objects.length;
@@ -78,7 +79,7 @@ <h1>Face Detection with OpenCV haar cascades in JavaScript</h1>
7879
log(this.objects.toString());
7980
alert(l+" Objects found");
8081
})
81-
.detect(1, 1.25, 0.5, 1, true); // go
82+
.detect(1, 1.1, 0.12, 1, 0.2, true); // go
8283
};
8384
image.src='model1.jpg'; // load it
8485
//]]>

examples/faces.html

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,14 @@ <h1>Many Faces Detection with OpenCV haar cascades in JavaScript</h1>
5252
}
5353

5454
image.onload=function(){
55-
wait.style.display='block';
56-
canvas.width=image.width; canvas.height=image.height;
57-
ctx.drawImage(image,0,0);
55+
wait.style.display = 'block';
56+
canvas.width = image.width;
57+
canvas.height = image.height;
58+
ctx.drawImage(image, 0, 0);
5859

5960
// detect the feature
6061
new HAAR.Detector(haarcascade_frontalface_alt, useParallel)
61-
.image(image, 0.5) // use the image
62+
.image(image, 150 / image.width) // use the image with standardised dimensions
6263
.interval(40) // set detection interval for asynchronous detection (if not parallel)
6364
.selection('auto') // set custom detection region
6465
//.selection({x:100, y:0, width:'auto', height:'auto'}) // set custom detection region
@@ -81,8 +82,8 @@ <h1>Many Faces Detection with OpenCV haar cascades in JavaScript</h1>
8182
log(this.objects.toString());
8283
alert(l+" Objects found");
8384
})
84-
.cannyThreshold({low:90, high:200}) // custom thresholds for canny pruning (for best results)
85-
.detect(1, 1.1, 0.12, 1, true); // go
85+
.cannyThreshold({low:20, high:400}) // custom thresholds for canny pruning (for best results)
86+
.detect(1, 1.1, 0.12, 1, 0.2, true); // go
8687
};
8788
image.src='Group_Faces2.jpg'; // load it
8889
//]]>

examples/mouth.html

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,14 @@ <h1>Mouth Detection with OpenCV haar cascades in JavaScript</h1>
5252
}
5353

5454
image.onload=function(){
55-
wait.style.display='block';
56-
canvas.width=image.width; canvas.height=image.height;
57-
ctx.drawImage(image,0,0);
55+
wait.style.display = 'block';
56+
canvas.width = image.width;
57+
canvas.height = image.height;
58+
ctx.drawImage(image, 0, 0);
5859

5960
// detect the feature
6061
new HAAR.Detector(haarcascade_mcs_mouth, useParallel)
61-
.image(image, 0.9) // use the image
62+
.image(image, 300 / image.width) // use the image with standardised dimensions
6263
.interval(40) // set detection interval for asynchronous detection (if not parallel)
6364
.complete(function(){ // onComplete callback
6465
var i, rect, l=this.objects.length;
@@ -79,7 +80,7 @@ <h1>Mouth Detection with OpenCV haar cascades in JavaScript</h1>
7980
alert(l+" Objects found");
8081
})
8182
.cannyThreshold({low:50, high:110}) // custom thresholds for canny pruning (for best results)
82-
.detect(1, 1.25, 0.1, 1, true); // go
83+
.detect(1, 1.25, 0.1, 1, 0.2, true); // go
8384
};
8485
image.src='model1.jpg'; // load it
8586
//]]>

examples/node.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ fs.readFile(__dirname + '/model1.jpg', function(err, squid) {
1818
new HAAR.Detector(detector).image(img, 1, new Canvas()).complete(function() {
1919
//processing done
2020
console.log(JSON.stringify(this.objects))
21-
}).detect(1, 1.25, 0.1, 1, true);
21+
}).detect(1, 1.25, 0.1, 1, 0.2, true);
2222
};
2323

2424
img.src = squid;

examples/require.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ requirejs(['haar-detector', 'haarcascade_frontalface_alt'], function(HAAR, detec
3636
new HAAR.Detector(detector).image(img, 1, new Canvas()).complete(function() {
3737
//processing done
3838
console.log(JSON.stringify(this.objects))
39-
}).detect(1, 1.25, 0.1, 1, true);
39+
}).detect(1, 1.25, 0.1, 1, 0.2, true);
4040
};
4141

4242
img.src = squid;

0 commit comments

Comments
 (0)