function CatchCode() {
//实际运用可不写,测试代 , 为单击拍照按钮就获取了当前图像,有其他用途
var canvans = document.getElementById("canvas");
var video = document.getElementById("video");
var context = canvas.getContext("2d");
canvas.width = video.videoWidth;
canvas.height = video.videoHeight;
context.drawImage(video,0,0);
var imgData = canvans.toDataURL();
//获取图像在前端截取22位以后的字符串作为图像数据
var imgData1 = imgData.substring(22);
var username = $("#username").val();
$.ajax({
type: "post",
url: "FaceServlet?tag=reg",
data: {"img":imgData1,"username":username},
success: function(data){
alert(data);
},error:function(msg){
alert("错误");
}
});
}

注册

用户名:

录入头像:


style="border:1px solid red;border-radius: 800px;" autoplay>
id="canvas">