基于HTML5 的人脸识别活体认证的实现方法

2020-04-24 19:24:07易采站长站整理

cc.lineWidth=3;  
  
function drawLoop() {  
//requestAnimationFrame(drawLoop);  
  
  
cc.clearRect(0, 0, canvasInput.width, canvasInput.height);  
//ctracker.draw(canvasInput );  
var positions = ctracker.getCurrentPosition();  
if (showpos && positions) {  
  
for (var p = 0;p < positions.length;p++) {  
positionString += "featurepoint "+p+" : ["+positions[p][0].toFixed(2)+","+positions[p][1].toFixed(2) +"]<br/>";  
}  
document.getElementById(‘positions’).innerHTML = positionString;  
  
  
}  
if(positions){  
  
for (var p =0;p < 71;p++) {      
cc.beginPath();  
cc.arc(positions[p][0].toFixed(2), positions[p][1].toFixed(2),2, 0, Math.PI * 2, true);  
cc.closePath();  
cc.fillStyle = ‘#00FF00’;  
cc.fill();  
}  
  
  
//cc.strokeStyle = ‘red’;  
  
//0-14 轮廓  
//7 下吧,最下  
  
//2 最左边  
//12 最右边  
  
  
//15-22 眉毛  
  
  
//23-27 左眼睛五个点  
//27 左眼中间  
//63-66 左眼四个点  
  
//28-32 右眼睛五个点  
//67-70 右眼四个点  
  
  
//33-43 鼻子  
//62 鼻中间  
  
  
//44-61 嘴巴  
//47 嘴巴上  
//53 嘴巴下  
  
///////////////////////////////////////////////////////////////////////////////////////////////  
  
//左眼中间  
for (var p =27;p <=27;p++) {      
cc.beginPath();  
cc.arc(positions[p][0].toFixed(2), positions[p][1].toFixed(2), 2, 0, Math.PI * 2, true);  
cc.closePath();  
cc.fillStyle = ‘red’;  
cc.fill();  
}  
  
//鼻子中间  
for (var p =62;p <=62;p++) {