Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding nose support #251

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions build/data/eye-min.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions build/data/eye.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions build/data/face-min.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions build/data/face.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions build/data/mouth-min.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions build/data/mouth.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions build/data/nose-min.js

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions build/data/nose.js

Large diffs are not rendered by default.

11 changes: 9 additions & 2 deletions build/tracking.js
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,8 @@
var width;
var height;


// FIXME here the video display size of the analysed size
var resizeCanvas_ = function() {
width = element.offsetWidth;
height = element.offsetHeight;
Expand All @@ -245,6 +247,11 @@
resizeCanvas_();
element.addEventListener('resize', resizeCanvas_);


// FIXME: do a process function - it is up to the caller to handle the frequency of detection
// it seems all handled in the tracking.TrackerTask..
// so in short, remove the tracking.TrackerTask from here
// if the user want to use it, it can create it himself
var requestId;
var requestAnimationFrame_ = function() {
requestId = window.requestAnimationFrame(function() {
Expand Down Expand Up @@ -2939,7 +2946,7 @@
tracking.LBF.maxNumStages
);
}

// NOTE: is this thesholding suitable ? if it is on image, why no skin-color filter ? and a adaptative threshold
pixels = tracking.Image.grayscale(pixels, width, height, false);

pixels = tracking.Image.equalizeHist(pixels, width, height);
Expand Down Expand Up @@ -3108,4 +3115,4 @@
this.leafnodes = data.id_leafnodes;
}

}());
}());
67 changes: 67 additions & 0 deletions examples/nose_camera.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>tracking.js - nose with camera</title>
<link rel="stylesheet" href="assets/demo.css">

<script src="../build/tracking-min.js"></script>
<script src="../build/data/nose-min.js"></script>
<script src="../node_modules/dat.gui/build/dat.gui.min.js"></script>
<script src="assets/stats.min.js"></script>

<style>
video, canvas {
margin-left: 230px;
margin-top: 120px;
position: absolute;
}
</style>
</head>
<body>
<div class="demo-title">
<p><a href="http://trackingjs.com" target="_parent">tracking.js</a> - get user's webcam and detect noses</p>
</div>

<div class="demo-frame">
<div class="demo-container">
<video id="video" width="320" height="240" preload autoplay loop muted></video>
<canvas id="canvas" width="320" height="240"></canvas>
</div>
</div>

<script>
window.onload = function() {
var video = document.getElementById('video');
var canvas = document.getElementById('canvas');
var context = canvas.getContext('2d');

var tracker = new tracking.ObjectTracker('nose');
tracker.setInitialScale(4);
tracker.setStepSize(2);
tracker.setEdgesDensity(0.1);

tracking.track('#video', tracker, { camera: true });

tracker.on('track', function(event) {
context.clearRect(0, 0, canvas.width, canvas.height);

event.data.forEach(function(rect) {
context.strokeStyle = '#a64ceb';
context.strokeRect(rect.x, rect.y, rect.width, rect.height);
context.font = '11px Helvetica';
context.fillStyle = "#fff";
context.fillText('x: ' + rect.x + 'px', rect.x + rect.width + 5, rect.y + 11);
context.fillText('y: ' + rect.y + 'px', rect.x + rect.width + 5, rect.y + 22);
});
});

var gui = new dat.GUI();
gui.add(tracker, 'edgesDensity', 0.1, 0.5).step(0.01);
gui.add(tracker, 'initialScale', 1.0, 10.0).step(0.1);
gui.add(tracker, 'stepSize', 1, 5).step(0.1);
};
</script>

</body>
</html>
Loading