Ai
3 Star 1 Fork 0

Gitee 极速下载/face-detection

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
此仓库是为了提升国内下载速度的镜像仓库,每日同步一次。 原始仓库: https://github.com/jaysalvat/jquery.facedetection
克隆/下载
tests.js 1.89 KB
一键复制 编辑 原始数据 按行查看 历史
Jay Salvat 提交于 2016-11-06 00:37 +08:00 . Update dependencies
/*
FaceDetection jQuery Plugin
Copyright (c) 2014 Jay Salvat
*/
/* global jQuery:true, QUnit:true */
(function ($) {
"use strict";
QUnit.test('Plugin', function (assert) {
assert.ok($("#img").faceDetection().addClass("testing"), "can be chained");
});
QUnit.test('Detection in image', function (assert) {
$("#img").faceDetection(function (faces) {
assert.equal(faces.length, 2, "2 faces found (callback)");
});
$("#img").faceDetection({
complete: function (faces) {
assert.equal(faces.length, 2, "2 faces found (options)");
}
});
});
QUnit.test('Detection in canvas', function (assert) {
var img = document.getElementById('img'),
canvas = document.getElementById('canvas'),
ctx = canvas.getContext('2d');
canvas.setAttribute('width', img.width);
canvas.setAttribute('height',img.height);
ctx.drawImage(img, 0, 0);
// TODO Async test on image load
$("#canvas").faceDetection(function (faces) {
assert.equal(faces.length, 2, "2 faces found");
});
});
QUnit.test('Errors', function (assert) {
$("#div").faceDetection({
complete: function (faces) {
assert.equal(faces.length, 0, "no faces found");
},
error: function (code, message) {
assert.equal(code, 1, "returns error code 1");
assert.ok(/images, videos and canvas only/.test(message), "contains message");
}
});
});
QUnit.asyncTest('Async Mode', function (assert) {
assert.expect(1);
$("#img").faceDetection({
worker: true,
complete: function(faces) {
assert.equal(faces.length, 2, "2 faces found");
QUnit.start();
}
});
});
})(jQuery);
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
JavaScript
1
https://gitee.com/mirrors/face-detection.git
git@gitee.com:mirrors/face-detection.git
mirrors
face-detection
face-detection
master

搜索帮助