Skip to content

Commit

Permalink
Update deps, reduce face detection examples (#133)
Browse files Browse the repository at this point in the history
  • Loading branch information
jwagner authored Jan 23, 2024
1 parent de2d143 commit a6d41a3
Show file tree
Hide file tree
Showing 7 changed files with 6,053 additions and 5,910 deletions.
1 change: 1 addition & 0 deletions examples/face-api.js
1 change: 0 additions & 1 deletion examples/face-api.min.js

This file was deleted.

15 changes: 2 additions & 13 deletions examples/testbed.html
Original file line number Diff line number Diff line change
Expand Up @@ -45,18 +45,10 @@ <h2>Drop images on this page to analyze them.</h2>
</div>
<div>
<label><input name="faceDetection" type="radio" value="face-api" />Use
<a href="https://github.com/justadudewhohacks/face-api.js">face-api.js</a>
<a href="https://github.com/vladmandic/face-api/">face-api</a>
(tiny_face_detector model)
</label>
</div>
<div>
<label><input name="faceDetection" type="radio" value="jquery" />Use
<a href="http://facedetection.jaysalvat.com/">jquery.facedetection</a></label>
</div>
<div>
<label><input name="faceDetection" type="radio" value="tracking" />Use
<a href="https://trackingjs.com/">tracking.js</a></label>
</div>
<div>
<label class="opencv-loading"><input name="faceDetection" type="radio" value="opencv" disabled />Use <a
href="https://opencv.org/">opencv.js</a></label>
Expand All @@ -75,10 +67,7 @@ <h4>All Crops</h4>
<script src="underscore.js"></script>
<script src="../smartcrop.js"></script>
<script src="smartcrop-debug.js"></script>
<script src="tracking-min.js"></script>
<script src="tracking-face-min.js"></script>
<script src="jquery.facedetection.min.js"></script>
<script src="face-api.min.js"></script>
<script src="face-api.js"></script>
<script src="testbed.js"></script>
<script async src="https://unpkg.com/opencv.js@1.2.1/opencv.js"
integrity="sha384-ucXOxPgA5tSKdaZgFD+5C0lAJeavjW31veENhNvOwsTjgx8waDD0s1QcMdUxhlxk" crossorigin="anonymous"
Expand Down
64 changes: 6 additions & 58 deletions examples/testbed.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,15 +76,14 @@
var faceDetection = $('input[name=faceDetection]:checked', form).val();
var analyzeOptions = analyze.bind(this, options);

if (faceDetection === 'tracking') {
faceDetectionTracking(options, analyzeOptions);
} else if (faceDetection === 'jquery') {
faceDetectionJquery(options, analyzeOptions);
} else if (faceDetection === 'opencv') {
switch (faceDetection) {
case 'opencv':
faceDetectionOpenCV(options, analyzeOptions);
} else if (faceDetection === 'face-api') {
break;
case 'face-api':
faceDetectionFaceAPI(options, analyzeOptions);
} else {
break;
default:
analyzeOptions();
}
}
Expand Down Expand Up @@ -175,57 +174,6 @@
});
}

function faceDetectionTracking(options, callback) {
prescaleImage(img, 768, function(img, scale) {
var tracker = new tracking.ObjectTracker('face');
tracking.track(img, tracker);
tracker.on('track', function(event) {
console.log(
'tracking.js detected ' + event.data.length + ' faces',
event.data
);
options.boost = event.data.map(function(face) {
return {
x: face.x / scale,
y: face.y / scale,
width: face.width / scale,
height: face.height / scale,
weight: 1.0
};
});

callback(options);
});
});
}

function faceDetectionJquery(options, callback) {
$(img).faceDetection({
complete: function(faces) {
if (faces === false) {
return console.log('jquery.facedetection returned false');
}
console.log(
'jquery.facedetection detected ' + faces.length + ' faces',
faces
);
options.boost = Array.prototype.slice
.call(faces, 0)
.map(function(face) {
return {
x: face.x,
y: face.y,
width: face.width,
height: face.height,
weight: 1.0
};
});

callback(options);
}
});
}

function analyze(options) {
console.log('analyze', options);
smartcrop.crop(img, options, draw);
Expand Down
14 changes: 4 additions & 10 deletions karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,31 +6,25 @@ module.exports = function(config) {
sauceChromeLatest: {
base: 'SauceLabs',
browserName: 'chrome',
platform: 'Windows 10',
platform: 'Windows 11',
version: 'latest'
},
sauceFirefoxLatest: {
base: 'SauceLabs',
browserName: 'firefox',
platform: 'Windows 10',
platform: 'Windows 11',
version: 'latest'
},
sauceIE: {
base: 'SauceLabs',
browserName: 'internet explorer',
platform: 'Windows 8.1',
version: '11'
},
sauceEdge: {
base: 'SauceLabs',
browserName: 'MicrosoftEdge',
platform: 'Windows 10',
platform: 'Windows 11',
version: 'latest'
},
sauceSafari: {
base: 'SauceLabs',
browserName: 'safari',
platform: 'OS X 10.11',
platform: 'macOS 13',
version: 'latest'
}
// sl_firefox: {
Expand Down
Loading

0 comments on commit a6d41a3

Please sign in to comment.