dd
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="CheckConfirm.aspx.cs" Inherits="FineUIPro.Web.RLSB.CheckConfirm" %>
|
||||
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head runat="server">
|
||||
<title>确认人脸比对</title>
|
||||
</head>
|
||||
<body>
|
||||
<form id="form1" runat="server">
|
||||
<div>
|
||||
|
||||
</div>
|
||||
</form>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,148 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using System.Web.UI;
|
||||
using System.Web.UI.WebControls;
|
||||
using System.Data.SqlClient;
|
||||
|
||||
namespace FineUIPro.Web.RLSB
|
||||
{
|
||||
public partial class CheckConfirm : System.Web.UI.Page
|
||||
{
|
||||
protected string flag = "";//标志(1-焊工,2-保管员)
|
||||
protected string keyId = "";//接收用户ID
|
||||
protected string grid = "";//1-领料,2-退料,3-退回焊条头
|
||||
protected string identityCard = "";//身份证号
|
||||
protected string stockMan = "";
|
||||
protected void Page_Load(object sender, EventArgs e)
|
||||
{
|
||||
keyId = Request.Params["keyId"];//用户ID
|
||||
flag = Request.Params["flag"];//1-焊工,2-保管员
|
||||
grid = Request.Params["grid"];//1-领料,2-退料,3-退焊条头,4-保管员结束确认
|
||||
identityCard = Request.Params["identityCard"];
|
||||
|
||||
checkFace();
|
||||
}
|
||||
|
||||
private void checkFace()
|
||||
{
|
||||
//查找是否符合对应人脸
|
||||
var result = "";
|
||||
var welder = BLL.HJGL_PersonManageService.GetWelderByIdentityCard(identityCard);
|
||||
if (welder != null)
|
||||
{
|
||||
if (welder.IsFaceTrain==true)
|
||||
{
|
||||
result = "1";
|
||||
}
|
||||
}
|
||||
var storeman = BLL.StoremanInfoService.GetStoremanByIdentityCard(identityCard);
|
||||
if (storeman != null)
|
||||
{
|
||||
if (storeman.IsFaceTrain == true)
|
||||
{
|
||||
result = "2";
|
||||
}
|
||||
}
|
||||
|
||||
if (grid == "1") // 领料
|
||||
{
|
||||
if (flag == "1" && result == "1")
|
||||
{
|
||||
BLL.UsingMatService.WelderConfirm(keyId, true);
|
||||
Response.Write("人脸对比成功,焊工已确认!");
|
||||
}
|
||||
else if (flag == "2" && result == "2")
|
||||
{
|
||||
BLL.UsingMatService.StoreManConfirm(keyId, true);
|
||||
Response.Write("人脸对比成功,保管员已确认!");
|
||||
}
|
||||
else
|
||||
{
|
||||
Response.Write("人脸不匹配!");
|
||||
}
|
||||
}
|
||||
if (grid == "2") // 退料
|
||||
{
|
||||
if (flag == "1" && result == "1")
|
||||
{
|
||||
BLL.RecycleMatService.WelderConfirm(keyId, true);
|
||||
Response.Write("人脸对比成功,焊工已确认!");
|
||||
}
|
||||
else
|
||||
{
|
||||
if (result == "2")
|
||||
{
|
||||
BLL.RecycleMatService.StoreManConfirm(keyId, true);
|
||||
|
||||
var recycle = BLL.RecycleMatService.GetRecycleMatById(keyId);
|
||||
var mat = BLL.UsingMatService.GetUsingMatById(recycle.UsingMatId);
|
||||
|
||||
//var stock = BLL.StockInService.GetStockInById(mat.StockInId);
|
||||
//var stockIn = BLL.StockInService.GetStockInByWeldIdAndNum(recycle.WeldId, recycle.Number);
|
||||
//var weld = BLL.WeldInfoService.GetWeldInfoById(recycle.WeldId);
|
||||
|
||||
if (!string.IsNullOrEmpty(mat.StockInId))
|
||||
{
|
||||
decimal recycleAmount = recycle.RecycleAmount.HasValue ? recycle.RecycleAmount.Value : 0;
|
||||
BLL.StockInService.UpdateStockInAmount(mat.StockInId, recycleAmount);
|
||||
}
|
||||
|
||||
#region 不用了
|
||||
//Model.Weld_StockIn newStockIn = new Model.Weld_StockIn();
|
||||
//newStockIn.WeldId = recycle.WeldId;
|
||||
//newStockIn.Amount = recycle.RecycleAmount;
|
||||
//newStockIn.Weight = recycle.RecycleAmount / weld.ConvertValue;
|
||||
//newStockIn.IsReview = false;
|
||||
//newStockIn.InStockDate = DateTime.Now;
|
||||
//newStockIn.Warrantybook = recycle.Warrantybook;
|
||||
//newStockIn.HeartNo = stock.HeartNo;
|
||||
//newStockIn.Materialman = stock.Materialman;
|
||||
//newStockIn.SupplierId = stock.SupplierId;
|
||||
//newStockIn.AttachUrl = stock.SupplierId;
|
||||
//newStockIn.Number = recycle.Number;
|
||||
//newStockIn.Flag = "2";
|
||||
|
||||
//if (stockIn == null)
|
||||
//{
|
||||
// newStockIn.Amount = recycle.RecycleAmount;
|
||||
// newStockIn.Weight = recycle.RecycleAmount / weld.ConvertValue;
|
||||
// newStockIn.StockInId = BLL.SQLHelper.GetNewID(typeof(Model.Weld_StockIn));
|
||||
// BLL.StockInService.AddStockIn(newStockIn);
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// newStockIn.Amount = stockIn.Amount + recycle.RecycleAmount;
|
||||
// newStockIn.Weight = (stockIn.Amount + recycle.RecycleAmount) / weld.ConvertValue;
|
||||
// newStockIn.StockInId = stockIn.StockInId;
|
||||
// BLL.StockInService.UpdateStockIn(newStockIn);
|
||||
//}
|
||||
#endregion
|
||||
|
||||
Response.Write("人脸对比成功,保管员已确认!");
|
||||
}
|
||||
}
|
||||
}
|
||||
if (grid == "3") // 退焊条头
|
||||
{
|
||||
if (flag == "1" && result == "1")
|
||||
{
|
||||
BLL.RecycleMatTopService.WelderConfirm(keyId, true);
|
||||
Response.Write("人脸对比成功,焊工已确认!");
|
||||
}
|
||||
else if (flag == "2" && result == "2")
|
||||
{
|
||||
BLL.RecycleMatTopService.StoreManConfirm(keyId, true);
|
||||
Response.Write("人脸对比成功,保管员已确认!");
|
||||
}
|
||||
}
|
||||
if (grid == "4")
|
||||
{
|
||||
BLL.UsingPlanService.UpdateIsFinish(keyId, stockMan);
|
||||
var s = BLL.StoremanInfoService.GetStoremanById(stockMan);
|
||||
Response.Write("保管员:" + s.StoreName + "确认此计划完成");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <自动生成>
|
||||
// 此代码由工具生成。
|
||||
//
|
||||
// 对此文件的更改可能会导致不正确的行为,并且如果
|
||||
// 重新生成代码,这些更改将会丢失。
|
||||
// </自动生成>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace FineUIPro.Web.RLSB {
|
||||
|
||||
|
||||
public partial class CheckConfirm {
|
||||
|
||||
/// <summary>
|
||||
/// form1 控件。
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// 自动生成的字段。
|
||||
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
|
||||
/// </remarks>
|
||||
protected global::System.Web.UI.HtmlControls.HtmlForm form1;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,399 @@
|
||||
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="FaceConfirm.aspx.cs" Inherits="FineUIPro.Web.RLSB.FaceConfirm" %>
|
||||
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head runat="server">
|
||||
<title></title>
|
||||
<script src="../../Scripts/jquery-1.8.3.js" type="text/javascript"></script>
|
||||
<script src="../../Scripts/jquery-ui-1.9.2.custom.min.js" type="text/javascript"></script>
|
||||
<link type="text/css" rel="Stylesheet" href="../../Styles/Site.css" />
|
||||
<link href="../../Styles/sunny/jquery-ui-1.9.2.custom.min.css" rel="stylesheet" type="text/css" />
|
||||
<script language="JavaScript" for="videoctrl" event="OnServerResult(param,type)">
|
||||
if(type==0){
|
||||
//人脸识别结果,param的格式为 "OK:LABEL,IMAGE;LABEL,IMAGE" 或 "ERR:2错误号";
|
||||
if ( param.indexOf('OK:') == 0 )
|
||||
{
|
||||
var ret = param.substr(3).split(';');
|
||||
if(ret.length>0){
|
||||
if( ret[0] == ""){
|
||||
$('#idet .tips').html('未能识别出,请检查人脸库!');
|
||||
return;
|
||||
}
|
||||
//目前只使用第一个;
|
||||
var subret = ret[0].split(',');
|
||||
var label = subret[0];//身份证号
|
||||
var jidu = parseFloat(subret[1]);//照片精确度
|
||||
var image = subret[2];//照片名称
|
||||
if(jidu>0.65)
|
||||
{
|
||||
var keyId =$("#keyId").val();
|
||||
var flag = $("#flag").val();
|
||||
var grid = $("#grid").val();
|
||||
|
||||
var url = "CheckConfirm.aspx?identityCard=" +label+"&keyId="+keyId+"&flag="+flag+"&grid="+grid;
|
||||
window.location.href= url;
|
||||
|
||||
videoctrl.CloseCamera();//关闭摄像头
|
||||
window.close();
|
||||
}
|
||||
else
|
||||
{
|
||||
// alert("未准确找到当前焊工信息,请重新识别!");
|
||||
$('#idet .tips').html('未能准确识别,请重新识别!');
|
||||
return;
|
||||
}
|
||||
// ShowShiBieResult(label,jidu,image);
|
||||
}else{
|
||||
$('#idet .tips').html('未能识别出,请检查人脸库!');
|
||||
}
|
||||
}else{
|
||||
$('#idet .tips').html('识别出错:'+param);
|
||||
}
|
||||
}else if(type ==1){
|
||||
//操作方式的返回结果!
|
||||
$('#idet .tips').html(param);
|
||||
}
|
||||
</script>
|
||||
<script type="text/javascript">
|
||||
$("#upload").attr("src", "uploadimg.aspx?identityCard=" + $('input[name=xunlianlabel]').val())
|
||||
|
||||
if (!String.prototype.trim) {
|
||||
String.prototype.trim = function () {
|
||||
return this.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, '');
|
||||
};
|
||||
}
|
||||
function GetServerUrl() {
|
||||
var pos = window.location.href.lastIndexOf('/');
|
||||
var url = window.location.href.substr(0, pos) + "/RLSBProccess.ashx";
|
||||
return url;
|
||||
}
|
||||
/*
|
||||
jidu = 0.0 ~ 1.0
|
||||
*/
|
||||
function SetFilterJidu(jidu) {
|
||||
/*
|
||||
* SetSameDetectJidu 设置相同人脸过滤的精确度(0到1之间, 1是完全同一张脸100%,0==%0
|
||||
* 当自动识别模式开启时,会自动检测人脸,如果上一张人脸与当前人脸相似度大于某个值时就不会上传服务器验证,认为是同一个,如果低于某个值就
|
||||
* 认为是不相同的人,则要上传验证,此选项可以降低频繁向服务器发送作用不大的请求。
|
||||
* 手工验证不受此值影响。
|
||||
*/
|
||||
//默认此项
|
||||
|
||||
if (!jidu || jidu == '') { jidu = '0.85'; }
|
||||
videoctrl.SetSameDetectJidu(parseFloat(jidu));
|
||||
}
|
||||
function OpenCamera() {
|
||||
|
||||
videoctrl.OpenCamera(parseInt($('select[name=cameraIdx]').val()));
|
||||
}
|
||||
function SetServerUrl() {
|
||||
|
||||
videoctrl.SetRequestUrl(GetServerUrl());
|
||||
}
|
||||
function CloseCamera() {
|
||||
videoctrl.CloseCamera();
|
||||
}
|
||||
function ShowUploading(uploading) {
|
||||
$('.mask').css('display', uploading ? '' : 'none');
|
||||
$('.uploadifrm').css('display', !uploading ? '' : 'none');
|
||||
}
|
||||
function OnBeginUpload() {
|
||||
ShowUploading(true);
|
||||
}
|
||||
function OnUploadOver() {
|
||||
ShowUploading(false);
|
||||
}
|
||||
function ReLoadUploadImg() {
|
||||
ShowUploading(false);
|
||||
$('#importface iframe').attr('src', 'uploadimg.aspx');
|
||||
}
|
||||
//通过标签删除
|
||||
function DeleteLabel() {
|
||||
var label = $('input[name=dellabel]').val();
|
||||
label = label.trim();
|
||||
if ('' == label) {
|
||||
$('<p>请输入要删除的标签!</p>').dialog({ autoOpen: true, width: 300, title: '操作提示' });
|
||||
return;
|
||||
}
|
||||
if (!confirm("确定要删除吗?删除不可恢复!"))
|
||||
return;
|
||||
$('#facelib .tips').html('正删除中……');
|
||||
$.post('RLSBProccess.ashx', { action: 'delliblabel', label: label }, function (data) {
|
||||
$('#facelib .tips').html(data.desc);
|
||||
LoadFaceLibLabel();
|
||||
});
|
||||
}
|
||||
//通过文件名删除人脸库
|
||||
function DelLibByFile(file, idx) {
|
||||
if (!confirm("确定要删除吗?删除不可恢复!"))
|
||||
return;
|
||||
$('#facelib .tips').html('正删除中……');
|
||||
$.post('RLSBProccess.ashx', { action: 'dellibfile', filename: file }, function (data) {
|
||||
$('#facelib .tips').html(data.desc);
|
||||
});
|
||||
$('.labellist tr[data=img_tr_' + idx + ']').remove();
|
||||
}
|
||||
function ShowRetInfo(a) {
|
||||
function Alert(s) { $('#idet .tips').html(s); }
|
||||
if (a != 0) {
|
||||
switch (a) {
|
||||
case 1:
|
||||
Alert("未打开摄像头!");
|
||||
break;
|
||||
case 2:
|
||||
Alert("当前帧未检测到人脸,请重试!");
|
||||
break;
|
||||
case 3:
|
||||
Alert("存储临时文件失败!");
|
||||
break;
|
||||
case 4:
|
||||
Alert('处理正忙……');
|
||||
break;
|
||||
}
|
||||
//alert("failed UploadImageAndCheck " + a);
|
||||
} else {
|
||||
//Alert("正上传服务验证中……");
|
||||
}
|
||||
}
|
||||
function XunLianRenLian() {
|
||||
ShowTips('...');
|
||||
var label = $('input[name=xunlianlabel]').val();
|
||||
label = label.trim();
|
||||
if ('' == label) {
|
||||
$('#idet .tips').html('请输入标签后再训练!'); return;
|
||||
}
|
||||
//接口是异步,需要回调消息里面得结果
|
||||
var ret = videoctrl.UploadImageAndTrain(GetServerUrl(), label);
|
||||
//ShowRetInfo(ret);
|
||||
}
|
||||
function ShiBie() {
|
||||
ShowTips('...');
|
||||
//接口是异步,需要回调消息里面得结果
|
||||
var ret = videoctrl.UploadImageAndCheck(GetServerUrl());
|
||||
//ShowRetInfo(ret);
|
||||
}
|
||||
//是否启动自动检测人脸并上传验证
|
||||
function OnAutoDecete() {
|
||||
if ($('input[name=auto_decete]').prop('checked')) {
|
||||
videoctrl.EnableAutoDetect(1);
|
||||
} else {
|
||||
videoctrl.EnableAutoDetect(0);
|
||||
}
|
||||
}
|
||||
function OnQuickMode() {
|
||||
if ($('input[name=quick_mode]').prop('checked')) {
|
||||
if (!confirm('启动快速模式将有可能降低精确度,确定要启动吗?')) {
|
||||
$('input[name=quick_mode]').prop('checked', false);
|
||||
return;
|
||||
}
|
||||
videoctrl.EnableQuickMode(1);
|
||||
} else {
|
||||
videoctrl.EnableQuickMode(0);
|
||||
}
|
||||
}
|
||||
function ShowTips(txt) { $('#idet .tips').html(txt); }
|
||||
function ShowShiBieResult(label, jidu, image) {
|
||||
var filter = parseFloat($('input[name=jidu]:checked').val());
|
||||
if (filter <= jidu) {
|
||||
ShowTips('识别出【<strong>' + label + '</strong>】,精准度:' + Math.floor(jidu * 100) + '%');
|
||||
} else {
|
||||
ShowTips('无法识别,但系统猜测结果是【<strong>' + label + '</strong>】,精准度:' + Math.floor(jidu * 100) + '%');
|
||||
}
|
||||
|
||||
}
|
||||
var g_bFirstLoadFace = true;
|
||||
function LoadFaceLibLabel() {
|
||||
$('#facelib .tips').html('');
|
||||
$('#facelibpane').html('加载中……');
|
||||
|
||||
function PrompEmpty() {
|
||||
// $('#facelibpane').html('<font color=red>人脸库为空,需要先增加!</font>');
|
||||
if (g_bFirstLoadFace) {
|
||||
g_bFirstLoadFace = false;
|
||||
// $('<font color=red>人脸库为空,需要先增加!</font>').dialog({ autoOpen: true, width: 400, title: '提示' });
|
||||
ShowTips('人脸库为空,需要先增加!');
|
||||
}
|
||||
}
|
||||
function parseLabel(data) {
|
||||
var html = '<div class="labellist"><table>';
|
||||
$(data.list).each(function (i, o) {
|
||||
html += '<tr data="img_tr_' + i + '" onmouseover="javascript:this.style.backgroundColor=\'#FFD54A\'" onmouseout="javascript:this.style.backgroundColor=\'\'">';
|
||||
html += '<td>' + o.Label + '</td>';
|
||||
html += '<td><img src="' + GetServerUrl() + '?action=getimage&name=' + o.Image + '"/></td>';
|
||||
html += '<td><a href="javascript:DelLibByFile(\'' + o.Image + '\',' + i + ');">删除</a></td>';
|
||||
html += '</tr>';
|
||||
});
|
||||
html += '</table></div>';
|
||||
$('#facelibpane').html(html);
|
||||
}
|
||||
//get method
|
||||
|
||||
$.ajax(GetServerUrl() + '?action=alllabelimage&t=' + (new Date()).getTime(), {
|
||||
success: function (data) {
|
||||
$("#upload").attr("src", "uploadimg.aspx?identityCard=" + $('input[name=xunlianlabel]').val());
|
||||
if ('' == data) {
|
||||
PrompEmpty();
|
||||
} else {
|
||||
var o = eval('(' + data + ')');
|
||||
if (o.err == 0) {
|
||||
if (o.list == null || o.list.length == 0) {
|
||||
PrompEmpty();
|
||||
} else {
|
||||
parseLabel(o);
|
||||
}
|
||||
} else {
|
||||
$('#facelibpane').html("加载失败:" + e.desc);
|
||||
}
|
||||
}
|
||||
},
|
||||
error: function (data) {
|
||||
$('#facelibpane').html("加载失败请<a href='javascript:LoadFaceLibLabel();'>重试</a>!");
|
||||
}
|
||||
});
|
||||
}
|
||||
//初始化
|
||||
function OnInitLoad() {
|
||||
LoadFaceLibLabel(); //加载人脸图库
|
||||
SetServerUrl(); //一定要设置之后,自动识别才有效果
|
||||
setTimeout(OpenCamera, 3000); //自动打开摄像头
|
||||
|
||||
SetFilterJidu(0.85); //设置默认过滤相同人脸
|
||||
OnAutoDecete(); //自动识别检测
|
||||
//由于快速会影响识别的精确度,所以先取消掉
|
||||
///OnQuickMode(); //启动快速模式
|
||||
}
|
||||
$(function () {
|
||||
$('#tabsmain').tabs({
|
||||
beforeActivate: function (event, ui) {
|
||||
if (ui.newTab) {
|
||||
|
||||
if (ui.newTab.find('a[href=#facelib]').length == 1) {
|
||||
LoadFaceLibLabel();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
$("#vdo_options,#faceliboption").accordion({ collapsible: true, heightStyle: "content" });
|
||||
$('#radiosetjidu').buttonset();
|
||||
$('input[type=button]').button();
|
||||
$('#sliderjidu').slider({
|
||||
min: 1, max: 100, value: 85,
|
||||
slide: function (event, ui) {
|
||||
$("#sliderjidutips").val(ui.value + '%');
|
||||
var fjidu = parseFloat(ui.value);
|
||||
fjidu /= 100;
|
||||
SetFilterJidu(fjidu);
|
||||
}
|
||||
});
|
||||
OnInitLoad();
|
||||
});
|
||||
</script>
|
||||
<style type="text/css">
|
||||
.mybgpanel
|
||||
{
|
||||
background-color: #B1EEEF;
|
||||
background-image: url(../Images/login_02.jpg);
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body class="mybgpanel">
|
||||
<div id="idet" runat="server">
|
||||
<%--<div>
|
||||
<table width="100%">
|
||||
<tr>
|
||||
<td align="center" style="font-size: 35px; font-weight: bold; color: Black;" colspan="3">
|
||||
镇海石化焊材领料人脸识别系统
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>--%>
|
||||
<div>
|
||||
<input name="keyId" type="hidden" id="keyId" value="<%=keyId %>" />
|
||||
<input name="flag" type="hidden" id="flag" value="<%=flag %>" />
|
||||
<input name="grid" type="hidden" id="grid" value="<%=grid %>" />
|
||||
</div>
|
||||
<div class="tips" style="font-size: 30px; font-weight: bold;">
|
||||
</div>
|
||||
<div class="video">
|
||||
|
||||
|
||||
|
||||
<object id="videoctrl" width="600" height="480" classid="CLSID:423B9F4C-A606-450D-9151-B44B511B4DC3">
|
||||
此控件需在IE下面才能正常运行!
|
||||
</object>
|
||||
</div>
|
||||
<div class="vdotool">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<%-- <select name="cameraIdx">
|
||||
<option value="0">摄像头1</option>
|
||||
<option value="1">摄像头2</option>
|
||||
</select>
|
||||
<input type="button" value="识别人脸" onclick="ShiBie()" /> --%>
|
||||
</div>
|
||||
<div style="height: 100px;">
|
||||
</div>
|
||||
<div id="vdo_options">
|
||||
<h3>
|
||||
识别选项
|
||||
</h3>
|
||||
<div class="vdotool">
|
||||
<select name="cameraIdx">
|
||||
<option value="0">摄像头1</option>
|
||||
<option value="1">摄像头2</option>
|
||||
</select>
|
||||
<input value="打开摄像头" onclick="OpenCamera()" type="button" />
|
||||
<input type="button" value="关闭摄像头" onclick="CloseCamera()" />
|
||||
</div>
|
||||
<div>
|
||||
<input type="checkbox" name="auto_decete" value="auto" onclick="OnAutoDecete()" checked="checked" />自动识别 <a
|
||||
title="识别到人脸时将让服务器识别,同时一张脸时将在本地过滤,不重复请求识别">?</a>
|
||||
<input type="checkbox" name="quick_mode" value="quick" onclick="OnQuickMode()" />快速模式 <a
|
||||
title="快速模式将在本地取人脸特证值,让服务器快速识别!">?</a>
|
||||
<br />
|
||||
<table>
|
||||
<tr>
|
||||
<td>
|
||||
识别精度过滤:
|
||||
</td>
|
||||
<td>
|
||||
<div id="radiosetjidu">
|
||||
<input type="radio" id="radio1" name="jidu" value="0.85"></input><label for="radio1">精确</label>
|
||||
<input type="radio" id="radio2" name="jidu" checked="checked" value="0.70"></input><label
|
||||
for="radio2">一般</label>
|
||||
<input type="radio" id="radio3" name="jidu" value="0.55"></input><label for="radio3">模糊</label>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
相同脸过滤<br />
|
||||
(同一张脸不重复验证):
|
||||
</td>
|
||||
<td>
|
||||
<div id="sameface">
|
||||
<p>
|
||||
<label for="sliderjidutips">
|
||||
过滤掉大于:</label>
|
||||
<input type="text" id="sliderjidutips" value="85%" readonly style="border: 0; color: #f6931f;
|
||||
font-weight: bold; background: transparent; width: 40px;">相似度的脸
|
||||
</p>
|
||||
<div id="sliderjidu">
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,24 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using System.Web.UI;
|
||||
using System.Web.UI.WebControls;
|
||||
using System.Text;
|
||||
using RLSB;
|
||||
|
||||
namespace FineUIPro.Web.RLSB
|
||||
{
|
||||
public partial class FaceConfirm : System.Web.UI.Page
|
||||
{
|
||||
protected string flag = "";//标志(1-焊工,2-保管员)
|
||||
protected string keyId = "";//接收用户ID
|
||||
protected string grid = "";//1-领料,2-退料,3-退回焊条头
|
||||
protected void Page_Load(object sender, EventArgs e)
|
||||
{
|
||||
keyId = Request.Params["keyId"];
|
||||
flag = Request.Params["flag"];//1-焊工,2-保管员
|
||||
grid = Request.Params["grid"];//1-领料,2-退料,3-退焊条头,4-保管员结束确认
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <自动生成>
|
||||
// 此代码由工具生成。
|
||||
//
|
||||
// 对此文件的更改可能导致不正确的行为,如果
|
||||
// 重新生成代码,则所做更改将丢失。
|
||||
// </自动生成>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace FineUIPro.Web.RLSB {
|
||||
|
||||
|
||||
public partial class FaceConfirm {
|
||||
|
||||
/// <summary>
|
||||
/// idet 控件。
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// 自动生成的字段。
|
||||
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
|
||||
/// </remarks>
|
||||
protected global::System.Web.UI.HtmlControls.HtmlGenericControl idet;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
<%@ WebHandler Language="C#" CodeBehind="RLSBProccess.ashx.cs" Class="RLSB.RLSBProccess" %>
|
||||
@@ -0,0 +1,448 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Threading;
|
||||
using System.Text;
|
||||
using BLL;
|
||||
|
||||
namespace RLSB
|
||||
{
|
||||
public class LabelImage
|
||||
{
|
||||
public string Label { get; set; }
|
||||
public string Image { get; set; }
|
||||
}
|
||||
public class LabelImageResult
|
||||
{
|
||||
public List<LabelImage> list { get; set; }
|
||||
public int err { get; set; }
|
||||
}
|
||||
public class LabelResult
|
||||
{
|
||||
public string[] list { get; set; }
|
||||
public int err { get; set; }
|
||||
public string desc { get; set; }
|
||||
}
|
||||
/// <summary>
|
||||
/// RLSBProccess 的摘要说明
|
||||
/// </summary>
|
||||
public class RLSBProccess : IHttpHandler, System.Web.SessionState.IRequiresSessionState
|
||||
{
|
||||
|
||||
public void ProcessRequest(HttpContext context)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (context.Request.HttpMethod == "POST")
|
||||
{
|
||||
DoProccess(context);
|
||||
}
|
||||
else
|
||||
{
|
||||
DoGetProccess(context);
|
||||
}
|
||||
}
|
||||
catch (ThreadAbortException ex)
|
||||
{
|
||||
//忽略此异常!
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
context.Response.Write(ex.ToString());
|
||||
try { context.Response.End(); }
|
||||
catch { }
|
||||
}
|
||||
//context.Response.ContentType = "text/plain";
|
||||
//context.Response.Write("Hello World");
|
||||
}
|
||||
Object m_GetObj = null;
|
||||
HttpContext m_tmpContext = null;
|
||||
void GetCallBackLabel(int err, string content)
|
||||
{
|
||||
if (m_GetObj != null)
|
||||
{
|
||||
LabelResult lr = m_GetObj as LabelResult;
|
||||
if (lr != null)
|
||||
{
|
||||
lr.list = content.Split(';');
|
||||
lr.err = 0;
|
||||
lr.desc = "";
|
||||
if (m_tmpContext != null)
|
||||
m_tmpContext.Response.Write(JsonHelper.JsonSerializer(lr));
|
||||
}
|
||||
}
|
||||
}
|
||||
void GetCallBackLabelImage(int err, string content)
|
||||
{
|
||||
if (m_GetObj != null)
|
||||
{
|
||||
LabelImageResult lr = m_GetObj as LabelImageResult;
|
||||
if (lr != null)
|
||||
{
|
||||
|
||||
string[] aliAry = content.Split(';');
|
||||
lr.list = new List<LabelImage>();
|
||||
foreach (var s in aliAry)
|
||||
{
|
||||
LabelImage li = new LabelImage();
|
||||
string[] tmp = s.Split(',');
|
||||
if (tmp.Count() == 2)
|
||||
{
|
||||
li.Image = tmp[1];
|
||||
li.Label = tmp[0];
|
||||
lr.list.Add(li);
|
||||
}
|
||||
}
|
||||
if (m_tmpContext != null)
|
||||
m_tmpContext.Response.Write(JsonHelper.JsonSerializer(lr));
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 新加方法
|
||||
/// </summary>
|
||||
/// <param name="context"></param>
|
||||
void GetCallBackLabelImageByLabel(int err, string content)
|
||||
{
|
||||
|
||||
string[] aliAry = content.Split(';'); // format: label,image;label,image
|
||||
foreach (var s in aliAry)
|
||||
{
|
||||
LabelImage li = new LabelImage();
|
||||
string[] tmp = s.Split(',');
|
||||
if (tmp.Count() == 2)
|
||||
{
|
||||
if (tmp[0].Equals(searchLabel))
|
||||
{
|
||||
searchImage = tmp[1];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 新加方法
|
||||
/// </summary>
|
||||
/// <param name="context"></param>
|
||||
void GetAllCallBackLabelImageByLabel(int err, string content)
|
||||
{
|
||||
|
||||
string[] aliAry = content.Split(';'); // format: label,image;label,image
|
||||
foreach (var s in aliAry)
|
||||
{
|
||||
LabelImage li = new LabelImage();
|
||||
string[] tmp = s.Split(',');
|
||||
if (tmp.Count() == 2)
|
||||
{
|
||||
if (tmp[0].Equals(searchLabel))
|
||||
{
|
||||
allSearchImage += tmp[1] + ",";
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!string.IsNullOrEmpty(allSearchImage))
|
||||
{
|
||||
allSearchImage = allSearchImage.Substring(0,allSearchImage.LastIndexOf(","));
|
||||
}
|
||||
}
|
||||
string searchLabel;
|
||||
string searchImage;
|
||||
string allSearchImage;
|
||||
/// <summary>
|
||||
/// 新加方法根据标签获取图片封装
|
||||
/// </summary>
|
||||
/// <param name="context"></param>
|
||||
public string GetImageByLabel(string label)
|
||||
{
|
||||
searchLabel = label;
|
||||
searchImage = "未找到匹配的图片";
|
||||
libFace.GetAllLabelAndImage(GetCallBackLabelImageByLabel);
|
||||
//searchImage;//此时searchImage就是对应标签的图片文件名
|
||||
return searchImage;
|
||||
}
|
||||
/// <summary>
|
||||
/// 新加方法根据标签获取所有图片封装
|
||||
/// </summary>
|
||||
/// <param name="context"></param>
|
||||
public string GetAllImageByLabel(string label)
|
||||
{
|
||||
searchLabel = label;
|
||||
libFace.GetAllLabelAndImage(GetAllCallBackLabelImageByLabel);
|
||||
if (string.IsNullOrEmpty(allSearchImage))
|
||||
{
|
||||
allSearchImage = "未找到匹配的图片";
|
||||
}
|
||||
//allSearchImage;//此时allSearchImage就是对应标签的所有图片文件名
|
||||
return allSearchImage;
|
||||
}
|
||||
|
||||
void DoGetProccess(HttpContext context)
|
||||
{
|
||||
string action = context.Request.Params["action"];
|
||||
switch (action)
|
||||
{
|
||||
case "alllabel":
|
||||
LabelResult lr = new LabelResult();
|
||||
m_GetObj = lr;
|
||||
m_tmpContext = context;
|
||||
libFace.GetAllLabel(GetCallBackLabel);//.Split(';');
|
||||
//lr.list
|
||||
|
||||
break;
|
||||
case "alllabelimage":
|
||||
m_GetObj = new LabelImageResult();
|
||||
m_tmpContext = context;
|
||||
libFace.GetAllLabelAndImage(GetCallBackLabelImage);
|
||||
|
||||
break;
|
||||
case "getimage":
|
||||
string filename = context.Request.Params["name"].Trim();
|
||||
if (filename == "")
|
||||
{
|
||||
context.Response.End();
|
||||
break;
|
||||
}
|
||||
string filepath = context.Server.MapPath("~/SeetaFaceDir/modelimages/" + filename);
|
||||
context.Response.ContentType = "image/jpg";
|
||||
try
|
||||
{
|
||||
context.Response.WriteFile(filepath);
|
||||
}
|
||||
catch { }
|
||||
break;
|
||||
default:
|
||||
//LabelResult
|
||||
lr = new LabelResult();
|
||||
lr.err = 3;
|
||||
lr.desc = "无效的action请求!";
|
||||
context.Response.Write(JsonHelper.JsonSerializer(lr));
|
||||
break;
|
||||
}
|
||||
context.Response.End();
|
||||
}
|
||||
|
||||
void GetCallBackLabelQuickShiBie(int err, string content)
|
||||
{
|
||||
if (null != m_GetObj)
|
||||
{
|
||||
StringBuilder sb = m_GetObj as StringBuilder;
|
||||
if (sb != null)
|
||||
{
|
||||
sb.Append(content);
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 文件内容是十六进制的字符串,需要读出来传递给库
|
||||
/// </summary>
|
||||
/// <param name="filename"></param>
|
||||
/// <returns></returns>
|
||||
string QuickShiBie(string filename)
|
||||
{
|
||||
try
|
||||
{
|
||||
FileStream stream = File.OpenRead(filename);
|
||||
StreamReader sr = new StreamReader(stream);
|
||||
string strFeature = sr.ReadToEnd();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
m_GetObj = sb;
|
||||
libFace.GetNameByFeature(strFeature, 3, GetCallBackLabelQuickShiBie);
|
||||
sr.Close();
|
||||
return sb.ToString();
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
return "ERR:识别异常!";
|
||||
}
|
||||
}
|
||||
string TrainFile(HttpServerUtility server, string filename, string label)
|
||||
{
|
||||
try
|
||||
{
|
||||
//bool b = libFace.AddFileLabel(filename, label);
|
||||
//由于训练图片需要时间,这里加个线程处理,即时返回客户端,但并不表示马上训练成功,防止上传图时被柱塞
|
||||
new Thread(() =>
|
||||
{
|
||||
try
|
||||
{
|
||||
bool b = libFace.TrainFileLabel(filename, label);
|
||||
System.IO.File.Delete(filename);
|
||||
//修改焊工是否已训练
|
||||
Model.HJGL_BS_Welder welder = BLL.HJGL_PersonManageService.GetWelderByIdentityCard(label);
|
||||
if (welder != null)
|
||||
{
|
||||
welder.IsFaceTrain = true;
|
||||
BLL.HJGL_PersonManageService.UpdateBSWelderIsFaceTrain(welder);
|
||||
}
|
||||
//修改保管员是否已训练
|
||||
Model.Weld_Storeman storeman = BLL.StoremanInfoService.GetStoremanByIdentityCard(label);
|
||||
if (storeman != null)
|
||||
{
|
||||
storeman.IsFaceTrain = true;
|
||||
BLL.StoremanInfoService.UpdateStoreManIsFaceTrain(storeman);
|
||||
}
|
||||
Logger.WriteLog(server, "TrainFile " + filename + " " + (b ? "成功" : "失败"));
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
string log = string.Format("TrainFile {0}Exception:" + ex.ToString(), filename);
|
||||
Logger.WriteLog(server, log);
|
||||
System.IO.File.Delete(filename);
|
||||
}
|
||||
}).Start();
|
||||
|
||||
return "上传图已加入训练队列!服务器正处理中,稍后将生效!";
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
return "训练异常!";
|
||||
}
|
||||
}
|
||||
void GetCallBackLabelShibie(int err, string content)
|
||||
{
|
||||
if (null != m_GetObj)
|
||||
{
|
||||
StringBuilder sb = m_GetObj as StringBuilder;
|
||||
if (sb != null)
|
||||
{
|
||||
sb.Append(content);
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 识别人脸,filename上传的图片所存的位置
|
||||
/// </summary>
|
||||
/// <param name="filename"></param>
|
||||
/// <returns></returns>
|
||||
string Shibie(string filename)
|
||||
{
|
||||
try
|
||||
{
|
||||
var sb = new StringBuilder();
|
||||
m_GetObj = sb;
|
||||
libFace.GetNameByFile(filename, 3, GetCallBackLabelShibie);
|
||||
return sb.ToString();
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
return "ERR:识别异常!";
|
||||
}
|
||||
}
|
||||
void DoProccess(HttpContext context)
|
||||
{
|
||||
string action = context.Request.Form["action"];
|
||||
string filename;
|
||||
switch (action)
|
||||
{
|
||||
//训练人脸库,上传的是图片
|
||||
case "train":
|
||||
string label = context.Request.Form["label"].Trim();
|
||||
if (string.IsNullOrEmpty(label))
|
||||
{
|
||||
context.Response.Write("失败,没有设置标签!");
|
||||
break;
|
||||
}
|
||||
if (context.Request.Files.Count != 1)
|
||||
{
|
||||
context.Response.Write("失败,没有上传一个文件(一次支持一张)!");
|
||||
break;
|
||||
}
|
||||
filename = context.Server.MapPath("~/tmpupload/" + (DateTime.Now).ToString("yyyyMMddHHmmss") + ".jpg");
|
||||
context.Request.Files[0].SaveAs(filename);
|
||||
context.Response.Write(TrainFile(context.Server, filename, label));
|
||||
|
||||
//由于控件内部处理也是使用此接口,所以过滤掉控件的请求,控件不执行以下代码
|
||||
if (-1 == context.Request.UserAgent.IndexOf("ActiveXSeetaFace"))
|
||||
{
|
||||
context.Response.Write("<script type='text/javascript'>parent.OnUploadOver();</script>");
|
||||
}
|
||||
//由于使用线程处理,下面不能删文件,否则将出错!
|
||||
//////System.IO.File.Delete(filename);
|
||||
break;
|
||||
//识别人脸
|
||||
case "shibie":
|
||||
if (context.Request.Files.Count != 1)
|
||||
{
|
||||
context.Response.Write("失败,没有上传一个文件(一次支持一张)!");
|
||||
break;
|
||||
}
|
||||
{
|
||||
filename = context.Server.MapPath("~/tmpupload/" + (DateTime.Now).ToString("yyyyMMddHHmmss") + ".jpg");
|
||||
context.Request.Files[0].SaveAs(filename);
|
||||
context.Response.Write(Shibie(filename));
|
||||
System.IO.File.Delete(filename);
|
||||
}
|
||||
break;
|
||||
//快速识别,上传的是特证码(十六进制字符串)
|
||||
case "quickshibie":
|
||||
if (context.Request.Files.Count != 1)
|
||||
{
|
||||
context.Response.Write("失败,没有上传一个文件(一次支持一张)!");
|
||||
break;
|
||||
}
|
||||
{
|
||||
filename = context.Server.MapPath("~/tmpupload/" + (DateTime.Now).ToString("yyyyMMddHHmmss") + ".jpg");
|
||||
context.Request.Files[0].SaveAs(filename);
|
||||
context.Response.Write(QuickShiBie(filename));
|
||||
System.IO.File.Delete(filename);
|
||||
}
|
||||
break;
|
||||
//以标签方式删除库
|
||||
//返回JSON格式
|
||||
case "delliblabel":
|
||||
context.Response.ContentType = "application/json";
|
||||
label = context.Request.Form["label"].Trim();
|
||||
if (string.IsNullOrEmpty(label))
|
||||
{
|
||||
context.Response.Write("{\"err\":1,\"desc\":\"失败,没有设置标签!\"}");
|
||||
break;
|
||||
}
|
||||
bool bOK = libFace.DelLibByLabel(label);
|
||||
if (bOK)
|
||||
{
|
||||
context.Response.Write("{\"err\":0,\"desc\":\"删除成功!\"}");
|
||||
}
|
||||
else
|
||||
{
|
||||
context.Response.Write("{\"err\":1,\"desc\":\"删除失败或者此标签已不存在!\"}");
|
||||
}
|
||||
break;
|
||||
//以图片名方式删除库
|
||||
case "dellibfile":
|
||||
context.Response.ContentType = "application/json";
|
||||
filename = context.Request.Form["filename"];
|
||||
if (string.IsNullOrEmpty(filename))
|
||||
{
|
||||
context.Response.Write("{\"err\":1,\"desc\":\"失败,没有设置文件名!\"}");
|
||||
break;
|
||||
}
|
||||
bOK = libFace.DelLibByFileName(filename);
|
||||
if (bOK)
|
||||
{
|
||||
context.Response.Write("{\"err\":0,\"desc\":\"删除成功!\"}");
|
||||
}
|
||||
else
|
||||
{
|
||||
context.Response.Write("{\"err\":2,\"desc\":\"删除失败或者此文件已不存在!\"}");
|
||||
}
|
||||
break;
|
||||
default:
|
||||
context.Response.Write("失败,请求有误!未知的action");
|
||||
break;
|
||||
}
|
||||
context.Response.End();
|
||||
|
||||
}
|
||||
public bool IsReusable
|
||||
{
|
||||
get
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="UploadImageCheck.aspx.cs" Inherits="FineUIPro.Web.RNSB.UploadImageCheck" %>
|
||||
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head runat="server">
|
||||
<title></title>
|
||||
</head>
|
||||
<body>
|
||||
<form id="form1" runat="server">
|
||||
<div>
|
||||
|
||||
</div>
|
||||
</form>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,69 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using System.Web.UI;
|
||||
using System.Web.UI.WebControls;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Diagnostics;
|
||||
using BLL;
|
||||
|
||||
namespace FineUIPro.Web.RNSB
|
||||
{
|
||||
public partial class UploadImageCheck : System.Web.UI.Page
|
||||
{
|
||||
private string fileUrl = string.Empty;
|
||||
|
||||
protected void Page_Load(object sender, EventArgs e)
|
||||
{
|
||||
if (Request.ServerVariables["Request_Method"] == "POST")
|
||||
{
|
||||
DoUpload();
|
||||
}
|
||||
else
|
||||
{
|
||||
Response.Write("请使用POST方法,上传图像!");
|
||||
}
|
||||
}
|
||||
//次回调,是识别回调,是照片与标签对应关系,标签可以和数据库中匹配并返回相关数据,标签是惟一的。可以由DEMO中程序定义并添加》
|
||||
|
||||
unsafe void CheckCallBack(
|
||||
string szLabel,
|
||||
double d)
|
||||
{
|
||||
//string strLabel = str.ToString();
|
||||
string label = szLabel;
|
||||
//identityCard = szLabel;
|
||||
Debug.WriteLine(string.Format("{0},{1}", label, d));
|
||||
Response.Write(label + "#" + d + "|" + fileUrl);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
void DoUpload()
|
||||
{
|
||||
if (Request.Files.Count != 1)
|
||||
{
|
||||
Response.Write("没有上传一个文件!");
|
||||
return;
|
||||
}
|
||||
if (Request.Files[0].FileName == "")
|
||||
{
|
||||
Response.Write("上传文件为空!");
|
||||
return;
|
||||
}
|
||||
string filename = "FileUpload//" + (DateTime.Now).ToString("yyyyMMddHHmmss") + ".jpg";
|
||||
fileUrl = filename;
|
||||
Request.Files[0].SaveAs(Funs.RootPath + filename);
|
||||
unsafe
|
||||
{
|
||||
CheckCallBack ccb = new BLL.CheckCallBack( CheckCallBack );
|
||||
libOpenCV.DoCheckImage(Funs.RootPath + filename, ccb);
|
||||
}
|
||||
//System.IO.File.Delete(Funs.RootPath + filename);
|
||||
//BLL.UploadFileService.DeleteFile(Funs.RootPath, filename);//删除文件内容,该删除操作调整到焊材发放页面进行操作,因领料单需要打印照片,故暂不删除
|
||||
Response.End();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <自动生成>
|
||||
// 此代码由工具生成。
|
||||
//
|
||||
// 对此文件的更改可能会导致不正确的行为,并且如果
|
||||
// 重新生成代码,这些更改将会丢失。
|
||||
// </自动生成>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace FineUIPro.Web.RNSB {
|
||||
|
||||
|
||||
public partial class UploadImageCheck {
|
||||
|
||||
/// <summary>
|
||||
/// form1 控件。
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// 自动生成的字段。
|
||||
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
|
||||
/// </remarks>
|
||||
protected global::System.Web.UI.HtmlControls.HtmlForm form1;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="UploadImageTrain.aspx.cs" Inherits="FineUIPro.Web.RNSB.UploadImageTrain" %>
|
||||
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head runat="server">
|
||||
<title></title>
|
||||
</head>
|
||||
<body>
|
||||
<form id="form1" runat="server">
|
||||
<div>
|
||||
|
||||
</div>
|
||||
</form>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,96 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using System.Web.UI;
|
||||
using System.Web.UI.WebControls;
|
||||
using BLL;
|
||||
using Web;
|
||||
|
||||
namespace FineUIPro.Web.RNSB
|
||||
{
|
||||
public partial class UploadImageTrain :PageBase
|
||||
{
|
||||
protected void Page_Load(object sender, EventArgs e)
|
||||
{
|
||||
if (Request.ServerVariables["Request_Method"] == "POST")
|
||||
{
|
||||
DoUpload();
|
||||
}
|
||||
else
|
||||
{
|
||||
Response.Write("请使用POST方法,上传图像!");
|
||||
}
|
||||
}
|
||||
void DoUpload()
|
||||
{
|
||||
if (Request.Files.Count != 1)
|
||||
{
|
||||
Response.Write("没有上传一个文件!");
|
||||
return;
|
||||
}
|
||||
if (Request.Files[0].FileName == "")
|
||||
{
|
||||
Response.Write("上传文件为空!");
|
||||
return;
|
||||
}
|
||||
try
|
||||
{
|
||||
string label = Request.Form["label"].Trim();
|
||||
if (String.IsNullOrEmpty(label))
|
||||
{
|
||||
Response.Write("村签不能为空!");
|
||||
return;
|
||||
}
|
||||
|
||||
string filename = Server.MapPath("~/FileUpload/" + (DateTime.Now).ToString("yyyyMMddHHmmss") + ".jpg");
|
||||
Request.Files[0].SaveAs(filename);
|
||||
|
||||
int nRet = libOpenCV.DoTrainImage(filename, label);
|
||||
switch (nRet)
|
||||
{
|
||||
/* TI_PARAM_NULL = 1,
|
||||
TI_FILEOPEN,
|
||||
TI_NO_FACE,
|
||||
TI_CASCADE,*/
|
||||
case 0:
|
||||
var welder = BLL.HJGL_PersonManageService.GetWelderByIdentityCard(label);//焊工采集
|
||||
if (welder != null)
|
||||
{
|
||||
welder.IsFaceTrain = true;
|
||||
welder.WED_ID = welder.WED_ID;
|
||||
BLL.HJGL_PersonManageService.UpdateBSWelderIsFaceTrain(welder);
|
||||
}
|
||||
var storeman = BLL.StoremanInfoService.GetStoremanByIdentityCard(label);//保管员采集
|
||||
if (storeman!=null)
|
||||
{
|
||||
storeman.IsFaceTrain = true;
|
||||
storeman.StoremanId = storeman.StoremanId;
|
||||
BLL.StoremanInfoService.UpdateStoreManIsFaceTrain(storeman);
|
||||
}
|
||||
Response.Write("人脸采集成功!");
|
||||
break;
|
||||
case 1:
|
||||
Response.Write("文件打开失败!");
|
||||
break;
|
||||
case 2:
|
||||
Response.Write("未检测到人脸!");
|
||||
break;
|
||||
case 3:
|
||||
Response.Write("人脸检测加载失败!");
|
||||
break;
|
||||
default:
|
||||
Response.Write("未知错误!");
|
||||
break;
|
||||
}
|
||||
|
||||
System.IO.File.Delete(filename);
|
||||
}
|
||||
catch
|
||||
{
|
||||
Response.Write("exception!");
|
||||
}
|
||||
Response.End();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <自动生成>
|
||||
// 此代码由工具生成。
|
||||
//
|
||||
// 对此文件的更改可能会导致不正确的行为,并且如果
|
||||
// 重新生成代码,这些更改将会丢失。
|
||||
// </自动生成>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace FineUIPro.Web.RNSB {
|
||||
|
||||
|
||||
public partial class UploadImageTrain {
|
||||
|
||||
/// <summary>
|
||||
/// form1 控件。
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// 自动生成的字段。
|
||||
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
|
||||
/// </remarks>
|
||||
protected global::System.Web.UI.HtmlControls.HtmlForm form1;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,388 @@
|
||||
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WelderRead.aspx.cs" Inherits="FineUIPro.Web.RLSB.WelderRead" %>
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head runat="server">
|
||||
<title></title>
|
||||
<script src="../../Scripts/jquery-1.8.3.js" type="text/javascript"></script>
|
||||
<script src="../../Scripts/jquery-ui-1.9.2.custom.min.js" type="text/javascript"></script>
|
||||
<link type="text/css" rel="Stylesheet" href="../../Styles/Site.css" />
|
||||
<link href="../../Styles/sunny/jquery-ui-1.9.2.custom.min.css" rel="stylesheet" type="text/css" />
|
||||
<script language="JavaScript" for="videoctrl" event="OnServerResult(param,type)">
|
||||
if(type==0){
|
||||
//人脸识别结果,param的格式为 "OK:LABEL,IMAGE;LABEL,IMAGE" 或 "ERR:2错误号";
|
||||
if ( param.indexOf('OK:') == 0 )
|
||||
{
|
||||
var ret = param.substr(3).split(';');
|
||||
if(ret.length>0){
|
||||
if( ret[0] == ""){
|
||||
$('#idet .tips').html('未能识别出,请检查人脸库!');
|
||||
return;
|
||||
}
|
||||
//目前只使用第一个;
|
||||
var subret = ret[0].split(',');
|
||||
var label = subret[0];
|
||||
var jidu = parseFloat(subret[1]);
|
||||
var image = subret[2];
|
||||
if(jidu>0.65)
|
||||
{
|
||||
var url = "../WeldMat/UsingSentMat/UsingMat.aspx?identityCard=" + label + "&fileName=" + image;
|
||||
window.location.href= url;
|
||||
videoctrl.CloseCamera();
|
||||
}
|
||||
else
|
||||
{
|
||||
// alert("未准确找到当前焊工信息,请重新识别!");
|
||||
$('#idet .tips').html('未准确找到当前焊工信息,请重新识别!');
|
||||
return;
|
||||
}
|
||||
// ShowShiBieResult(label,jidu,image);
|
||||
}else{
|
||||
$('#idet .tips').html('未能识别出,请检查人脸库!');
|
||||
}
|
||||
}else{
|
||||
$('#idet .tips').html('识别出错:'+param);
|
||||
}
|
||||
}else if(type ==1){
|
||||
//操作方式的返回结果!
|
||||
$('#idet .tips').html(param);
|
||||
}
|
||||
</script>
|
||||
<script type="text/javascript">
|
||||
$("#upload").attr("src", "uploadimg.aspx?identityCard=" + $('input[name=xunlianlabel]').val())
|
||||
|
||||
if (!String.prototype.trim) {
|
||||
String.prototype.trim = function () {
|
||||
return this.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, '');
|
||||
};
|
||||
}
|
||||
function GetServerUrl() {
|
||||
var pos = window.location.href.lastIndexOf('/');
|
||||
var url = window.location.href.substr(0, pos) + "/RLSBProccess.ashx";
|
||||
return url;
|
||||
}
|
||||
/*
|
||||
jidu = 0.0 ~ 1.0
|
||||
*/
|
||||
function SetFilterJidu(jidu) {
|
||||
/*
|
||||
* SetSameDetectJidu 设置相同人脸过滤的精确度(0到1之间, 1是完全同一张脸100%,0==%0
|
||||
* 当自动识别模式开启时,会自动检测人脸,如果上一张人脸与当前人脸相似度大于某个值时就不会上传服务器验证,认为是同一个,如果低于某个值就
|
||||
* 认为是不相同的人,则要上传验证,此选项可以降低频繁向服务器发送作用不大的请求。
|
||||
* 手工验证不受此值影响。
|
||||
*/
|
||||
//默认此项
|
||||
|
||||
if (!jidu || jidu == '') { jidu = '0.85'; }
|
||||
videoctrl.SetSameDetectJidu(parseFloat(jidu));
|
||||
}
|
||||
function OpenCamera() {
|
||||
|
||||
videoctrl.OpenCamera(parseInt($('select[name=cameraIdx]').val()));
|
||||
}
|
||||
function SetServerUrl() {
|
||||
|
||||
videoctrl.SetRequestUrl(GetServerUrl());
|
||||
}
|
||||
function CloseCamera() {
|
||||
videoctrl.CloseCamera();
|
||||
}
|
||||
function ShowUploading(uploading) {
|
||||
$('.mask').css('display', uploading ? '' : 'none');
|
||||
$('.uploadifrm').css('display', !uploading ? '' : 'none');
|
||||
}
|
||||
function OnBeginUpload() {
|
||||
ShowUploading(true);
|
||||
}
|
||||
function OnUploadOver() {
|
||||
ShowUploading(false);
|
||||
}
|
||||
function ReLoadUploadImg() {
|
||||
ShowUploading(false);
|
||||
$('#importface iframe').attr('src', 'uploadimg.aspx');
|
||||
}
|
||||
//通过标签删除
|
||||
function DeleteLabel() {
|
||||
var label = $('input[name=dellabel]').val();
|
||||
label = label.trim();
|
||||
if ('' == label) {
|
||||
$('<p>请输入要删除的标签!</p>').dialog({ autoOpen: true, width: 300, title: '操作提示' });
|
||||
return;
|
||||
}
|
||||
if (!confirm("确定要删除吗?删除不可恢复!"))
|
||||
return;
|
||||
$('#facelib .tips').html('正删除中……');
|
||||
$.post('RLSBProccess.ashx', { action: 'delliblabel', label: label }, function (data) {
|
||||
$('#facelib .tips').html(data.desc);
|
||||
LoadFaceLibLabel();
|
||||
});
|
||||
}
|
||||
//通过文件名删除人脸库
|
||||
function DelLibByFile(file, idx) {
|
||||
if (!confirm("确定要删除吗?删除不可恢复!"))
|
||||
return;
|
||||
$('#facelib .tips').html('正删除中……');
|
||||
$.post('RLSBProccess.ashx', { action: 'dellibfile', filename: file }, function (data) {
|
||||
$('#facelib .tips').html(data.desc);
|
||||
});
|
||||
$('.labellist tr[data=img_tr_' + idx + ']').remove();
|
||||
}
|
||||
function ShowRetInfo(a) {
|
||||
function Alert(s) { $('#idet .tips').html(s); }
|
||||
if (a != 0) {
|
||||
switch (a) {
|
||||
case 1:
|
||||
Alert("未打开摄像头!");
|
||||
break;
|
||||
case 2:
|
||||
Alert("当前帧未检测到人脸,请重试!");
|
||||
break;
|
||||
case 3:
|
||||
Alert("存储临时文件失败!");
|
||||
break;
|
||||
case 4:
|
||||
Alert('处理正忙……');
|
||||
break;
|
||||
}
|
||||
//alert("failed UploadImageAndCheck " + a);
|
||||
} else {
|
||||
//Alert("正上传服务验证中……");
|
||||
}
|
||||
}
|
||||
function XunLianRenLian() {
|
||||
ShowTips('...');
|
||||
var label = $('input[name=xunlianlabel]').val();
|
||||
label = label.trim();
|
||||
if ('' == label) {
|
||||
$('#idet .tips').html('请输入标签后再训练!'); return;
|
||||
}
|
||||
//接口是异步,需要回调消息里面得结果
|
||||
var ret = videoctrl.UploadImageAndTrain(GetServerUrl(), label);
|
||||
//ShowRetInfo(ret);
|
||||
}
|
||||
function ShiBie() {
|
||||
ShowTips('...');
|
||||
//接口是异步,需要回调消息里面得结果
|
||||
var ret = videoctrl.UploadImageAndCheck(GetServerUrl());
|
||||
//ShowRetInfo(ret);
|
||||
}
|
||||
//是否启动自动检测人脸并上传验证
|
||||
function OnAutoDecete() {
|
||||
if ($('input[name=auto_decete]').prop('checked')) {
|
||||
videoctrl.EnableAutoDetect(1);
|
||||
} else {
|
||||
videoctrl.EnableAutoDetect(0);
|
||||
}
|
||||
}
|
||||
function OnQuickMode() {
|
||||
if ($('input[name=quick_mode]').prop('checked')) {
|
||||
if (!confirm('启动快速模式将有可能降低精确度,确定要启动吗?')) {
|
||||
$('input[name=quick_mode]').prop('checked', false);
|
||||
return;
|
||||
}
|
||||
videoctrl.EnableQuickMode(1);
|
||||
} else {
|
||||
videoctrl.EnableQuickMode(0);
|
||||
}
|
||||
}
|
||||
function ShowTips(txt) { $('#idet .tips').html(txt); }
|
||||
function ShowShiBieResult(label, jidu, image) {
|
||||
var filter = parseFloat($('input[name=jidu]:checked').val());
|
||||
if (filter <= jidu) {
|
||||
ShowTips('识别出【<strong>' + label + '</strong>】,精准度:' + Math.floor(jidu * 100) + '%');
|
||||
} else {
|
||||
ShowTips('无法识别,但系统猜测结果是【<strong>' + label + '</strong>】,精准度:' + Math.floor(jidu * 100) + '%');
|
||||
}
|
||||
|
||||
}
|
||||
var g_bFirstLoadFace = true;
|
||||
function LoadFaceLibLabel() {
|
||||
$('#facelib .tips').html('');
|
||||
$('#facelibpane').html('加载中……');
|
||||
|
||||
function PrompEmpty() {
|
||||
// $('#facelibpane').html('<font color=red>人脸库为空,需要先增加!</font>');
|
||||
if (g_bFirstLoadFace) {
|
||||
g_bFirstLoadFace = false;
|
||||
// $('<font color=red>人脸库为空,需要先增加!</font>').dialog({ autoOpen: true, width: 400, title: '提示' });
|
||||
ShowTips('人脸库为空,需要先增加!');
|
||||
}
|
||||
}
|
||||
function parseLabel(data) {
|
||||
var html = '<div class="labellist"><table>';
|
||||
$(data.list).each(function (i, o) {
|
||||
html += '<tr data="img_tr_' + i + '" onmouseover="javascript:this.style.backgroundColor=\'#FFD54A\'" onmouseout="javascript:this.style.backgroundColor=\'\'">';
|
||||
html += '<td>' + o.Label + '</td>';
|
||||
html += '<td><img src="' + GetServerUrl() + '?action=getimage&name=' + o.Image + '"/></td>';
|
||||
html += '<td><a href="javascript:DelLibByFile(\'' + o.Image + '\',' + i + ');">删除</a></td>';
|
||||
html += '</tr>';
|
||||
});
|
||||
html += '</table></div>';
|
||||
$('#facelibpane').html(html);
|
||||
}
|
||||
//get method
|
||||
|
||||
$.ajax(GetServerUrl() + '?action=alllabelimage&t=' + (new Date()).getTime(), {
|
||||
success: function (data) {
|
||||
$("#upload").attr("src", "uploadimg.aspx?identityCard=" + $('input[name=xunlianlabel]').val());
|
||||
if ('' == data) {
|
||||
PrompEmpty();
|
||||
} else {
|
||||
var o = eval('(' + data + ')');
|
||||
if (o.err == 0) {
|
||||
if (o.list == null || o.list.length == 0) {
|
||||
PrompEmpty();
|
||||
} else {
|
||||
parseLabel(o);
|
||||
}
|
||||
} else {
|
||||
$('#facelibpane').html("加载失败:" + e.desc);
|
||||
}
|
||||
}
|
||||
},
|
||||
error: function (data) {
|
||||
$('#facelibpane').html("加载失败请<a href='javascript:LoadFaceLibLabel();'>重试</a>!");
|
||||
}
|
||||
});
|
||||
}
|
||||
//初始化
|
||||
function OnInitLoad() {
|
||||
LoadFaceLibLabel(); //加载人脸图库
|
||||
SetServerUrl(); //一定要设置之后,自动识别才有效果
|
||||
setTimeout(OpenCamera, 3000); //自动打开摄像头
|
||||
|
||||
SetFilterJidu(0.85); //设置默认过滤相同人脸
|
||||
OnAutoDecete(); //自动识别检测
|
||||
//由于快速会影响识别的精确度,所以先取消掉
|
||||
///OnQuickMode(); //启动快速模式
|
||||
}
|
||||
$(function () {
|
||||
$('#tabsmain').tabs({
|
||||
beforeActivate: function (event, ui) {
|
||||
if (ui.newTab) {
|
||||
|
||||
if (ui.newTab.find('a[href=#facelib]').length == 1) {
|
||||
LoadFaceLibLabel();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
$("#vdo_options,#faceliboption").accordion({ collapsible: true, heightStyle: "content" });
|
||||
$('#radiosetjidu').buttonset();
|
||||
$('input[type=button]').button();
|
||||
$('#sliderjidu').slider({
|
||||
min: 1, max: 100, value: 85,
|
||||
slide: function (event, ui) {
|
||||
$("#sliderjidutips").val(ui.value + '%');
|
||||
var fjidu = parseFloat(ui.value);
|
||||
fjidu /= 100;
|
||||
SetFilterJidu(fjidu);
|
||||
}
|
||||
});
|
||||
OnInitLoad();
|
||||
});
|
||||
</script>
|
||||
<style type="text/css">
|
||||
.mybgpanel
|
||||
{
|
||||
background-color: #B1EEEF;
|
||||
background-image: url(../Images/login_02.jpg);
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body class="mybgpanel">
|
||||
<div id="idet" runat="server">
|
||||
<%--<div>
|
||||
<table width="100%">
|
||||
<tr>
|
||||
<td align="center" style="font-size: 35px; font-weight: bold; color: Black;" colspan="3">
|
||||
镇海石化焊材领料人脸识别系统
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>--%>
|
||||
<div class="tips" style="font-size:30px; font-weight:bold;">
|
||||
</div>
|
||||
<div class="video">
|
||||
|
||||
|
||||
|
||||
<object id="videoctrl" width="600" height="480" classid="CLSID:423B9F4C-A606-450D-9151-B44B511B4DC3">
|
||||
此控件需在IE下面才能正常运行!
|
||||
</object>
|
||||
</div>
|
||||
<div class="vdotool">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<%--<select name="cameraIdx">
|
||||
<option value="0">摄像头1</option>
|
||||
<option value="1">摄像头2</option>
|
||||
</select>
|
||||
<input type="button" value="识别人脸" onclick="ShiBie()" /> --%>
|
||||
</div>
|
||||
<div style="height: 100px;">
|
||||
</div>
|
||||
<div id="vdo_options">
|
||||
<h3>
|
||||
识别选项
|
||||
</h3>
|
||||
<div class="vdotool">
|
||||
<select name="cameraIdx">
|
||||
<option value="0">摄像头1</option>
|
||||
<option value="1">摄像头2</option>
|
||||
</select>
|
||||
<input value="打开摄像头" onclick="OpenCamera()" type="button" />
|
||||
<input type="button" value="关闭摄像头" onclick="CloseCamera()" />
|
||||
</div>
|
||||
<div>
|
||||
<input type="checkbox" name="auto_decete" value="auto" onclick="OnAutoDecete()" checked="checked" />自动识别 <a
|
||||
title="识别到人脸时将让服务器识别,同时一张脸时将在本地过滤,不重复请求识别">?</a>
|
||||
<input type="checkbox" name="quick_mode" value="quick" onclick="OnQuickMode()" />快速模式 <a
|
||||
title="快速模式将在本地取人脸特证值,让服务器快速识别!">?</a>
|
||||
<br />
|
||||
<table>
|
||||
<tr>
|
||||
<td>
|
||||
识别精度过滤:
|
||||
</td>
|
||||
<td>
|
||||
<div id="radiosetjidu">
|
||||
<input type="radio" id="radio1" name="jidu" value="0.85"></input><label for="radio1">精确</label>
|
||||
<input type="radio" id="radio2" name="jidu" checked="checked" value="0.70"></input><label
|
||||
for="radio2">一般</label>
|
||||
<input type="radio" id="radio3" name="jidu" value="0.55"></input><label for="radio3">模糊</label>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
相同脸过滤<br />
|
||||
(同一张脸不重复验证):
|
||||
</td>
|
||||
<td>
|
||||
<div id="sameface">
|
||||
<p>
|
||||
<label for="sliderjidutips">
|
||||
过滤掉大于:</label>
|
||||
<input type="text" id="sliderjidutips" value="85%" readonly style="border: 0; color: #f6931f;
|
||||
font-weight: bold; background: transparent; width: 40px;">相似度的脸
|
||||
</p>
|
||||
<div id="sliderjidu">
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,23 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using System.Web.UI;
|
||||
using System.Web.UI.WebControls;
|
||||
using BLL;
|
||||
using System.Text.RegularExpressions;
|
||||
using Web;
|
||||
|
||||
namespace FineUIPro.Web.RLSB
|
||||
{
|
||||
public partial class WelderRead :PageBase
|
||||
{
|
||||
protected void Page_Load(object sender, EventArgs e)
|
||||
{
|
||||
if (!IsPostBack)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <自动生成>
|
||||
// 此代码由工具生成。
|
||||
//
|
||||
// 对此文件的更改可能导致不正确的行为,如果
|
||||
// 重新生成代码,则所做更改将丢失。
|
||||
// </自动生成>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace FineUIPro.Web.RLSB {
|
||||
|
||||
|
||||
public partial class WelderRead {
|
||||
|
||||
/// <summary>
|
||||
/// idet 控件。
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// 自动生成的字段。
|
||||
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
|
||||
/// </remarks>
|
||||
protected global::System.Web.UI.HtmlControls.HtmlGenericControl idet;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,341 @@
|
||||
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WelderTrain.aspx.cs" Inherits="FineUIPro.Web.RLSB.WelderTrain" %>
|
||||
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head runat="server">
|
||||
<title>人脸识别训练</title>
|
||||
<script src="../Scripts/jquery-1.8.3.js" type="text/javascript"></script>
|
||||
<script src="../Scripts/jquery-ui-1.9.2.custom.min.js" type="text/javascript"></script>
|
||||
<link href="../Styles/Site.css" rel="stylesheet" type="text/css" />
|
||||
<link href="../Styles/sunny/jquery-ui-1.9.2.custom.min.css" rel="stylesheet" type="text/css" />
|
||||
<script language="JavaScript" for="videoctrl" event="OnServerResult(param,type)">
|
||||
if(type==0){
|
||||
//人脸识别结果,param的格式为 "OK:LABEL,IMAGE;LABEL,IMAGE" 或 "ERR:2错误号";
|
||||
if ( param.indexOf('OK:') == 0 )
|
||||
{
|
||||
var ret = param.substr(3).split(';');
|
||||
if(ret.length>0){
|
||||
if( ret[0] == ""){
|
||||
$('#idet .tips').html('未能识别出,请检查人脸库!');
|
||||
return;
|
||||
}
|
||||
//目前只使用第一个;
|
||||
var subret = ret[0].split(',');
|
||||
var label = subret[0];
|
||||
var jidu = parseFloat(subret[1]);
|
||||
var image = subret[2];
|
||||
ShowShiBieResult(label,jidu,image);
|
||||
}else{
|
||||
$('#idet .tips').html('未能识别出,请检查人脸库!');
|
||||
}
|
||||
}else{
|
||||
$('#idet .tips').html('识别出错:'+param);
|
||||
}
|
||||
}else if(type ==1){
|
||||
//操作方式的返回结果!
|
||||
$('#idet .tips').html(param);
|
||||
}
|
||||
</script>
|
||||
<script type="text/javascript">
|
||||
$("#upload").attr("src", "uploadimg.aspx?identityCard=" + $('input[name=xunlianlabel]').val())
|
||||
|
||||
if (!String.prototype.trim) {
|
||||
String.prototype.trim = function () {
|
||||
return this.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, '');
|
||||
};
|
||||
}
|
||||
function GetServerUrl() {
|
||||
var pos = window.location.href.lastIndexOf('/');
|
||||
var url = window.location.href.substr(0, pos) + "/RLSBProccess.ashx";
|
||||
return url;
|
||||
}
|
||||
/*
|
||||
jidu = 0.0 ~ 1.0
|
||||
*/
|
||||
function SetFilterJidu(jidu) {
|
||||
/*
|
||||
* SetSameDetectJidu 设置相同人脸过滤的精确度(0到1之间, 1是完全同一张脸100%,0==%0
|
||||
* 当自动识别模式开启时,会自动检测人脸,如果上一张人脸与当前人脸相似度大于某个值时就不会上传服务器验证,认为是同一个,如果低于某个值就
|
||||
* 认为是不相同的人,则要上传验证,此选项可以降低频繁向服务器发送作用不大的请求。
|
||||
* 手工验证不受此值影响。
|
||||
*/
|
||||
//默认此项
|
||||
|
||||
if (!jidu || jidu == '') { jidu = '0.85'; }
|
||||
videoctrl.SetSameDetectJidu(parseFloat(jidu));
|
||||
}
|
||||
function OpenCamera() {
|
||||
|
||||
videoctrl.OpenCamera(parseInt($('select[name=cameraIdx]').val()));
|
||||
}
|
||||
function SetServerUrl() {
|
||||
|
||||
videoctrl.SetRequestUrl(GetServerUrl());
|
||||
}
|
||||
function CloseCamera() {
|
||||
videoctrl.CloseCamera();
|
||||
}
|
||||
function ShowUploading(uploading) {
|
||||
$('.mask').css('display', uploading ? '' : 'none');
|
||||
$('.uploadifrm').css('display', !uploading ? '' : 'none');
|
||||
}
|
||||
function OnBeginUpload() {
|
||||
ShowUploading(true);
|
||||
}
|
||||
function OnUploadOver() {
|
||||
ShowUploading(false);
|
||||
}
|
||||
function ReLoadUploadImg() {
|
||||
ShowUploading(false);
|
||||
$('#importface iframe').attr('src', 'uploadimg.aspx');
|
||||
}
|
||||
//通过标签删除
|
||||
function DeleteLabel() {
|
||||
var label = $('input[name=dellabel]').val();
|
||||
label = label.trim();
|
||||
if ('' == label) {
|
||||
$('<p>请输入要删除的标签!</p>').dialog({ autoOpen: true, width: 300, title: '操作提示' });
|
||||
return;
|
||||
}
|
||||
if (!confirm("确定要删除吗?删除不可恢复!"))
|
||||
return;
|
||||
$('#facelib .tips').html('正删除中……');
|
||||
$.post('RLSBProccess.ashx', { action: 'delliblabel', label: label }, function (data) {
|
||||
$('#facelib .tips').html(data.desc);
|
||||
LoadFaceLibLabel();
|
||||
});
|
||||
}
|
||||
//通过文件名删除人脸库
|
||||
function DelLibByFile(file, idx) {
|
||||
if (!confirm("确定要删除吗?删除不可恢复!"))
|
||||
return;
|
||||
$('#facelib .tips').html('正删除中……');
|
||||
$.post('RLSBProccess.ashx', { action: 'dellibfile', filename: file }, function (data) {
|
||||
$('#facelib .tips').html(data.desc);
|
||||
});
|
||||
$('.labellist tr[data=img_tr_' + idx + ']').remove();
|
||||
}
|
||||
function ShowRetInfo(a) {
|
||||
function Alert(s) { $('#idet .tips').html(s); }
|
||||
if (a != 0) {
|
||||
switch (a) {
|
||||
case 1:
|
||||
Alert("未打开摄像头!");
|
||||
break;
|
||||
case 2:
|
||||
Alert("当前帧未检测到人脸,请重试!");
|
||||
break;
|
||||
case 3:
|
||||
Alert("存储临时文件失败!");
|
||||
break;
|
||||
case 4:
|
||||
Alert('处理正忙……');
|
||||
break;
|
||||
}
|
||||
//alert("failed UploadImageAndCheck " + a);
|
||||
} else {
|
||||
//Alert("正上传服务验证中……");
|
||||
}
|
||||
}
|
||||
function XunLianRenLian() {
|
||||
ShowTips('...');
|
||||
|
||||
var label = $('input[name=xunlianlabel]').val();
|
||||
label = label.trim();
|
||||
if ('' == label) {
|
||||
$('#idet .tips').html('请输入标签后再训练!'); return;
|
||||
}
|
||||
|
||||
//接口是异步,需要回调消息里面得结果
|
||||
var ret = videoctrl.UploadImageAndTrain(GetServerUrl(), label);
|
||||
|
||||
// ShowRetInfo(ret);
|
||||
}
|
||||
function ShiBie() {
|
||||
ShowTips('...');
|
||||
//接口是异步,需要回调消息里面得结果
|
||||
var ret = videoctrl.UploadImageAndCheck(GetServerUrl());
|
||||
// ShowRetInfo(ret);
|
||||
}
|
||||
//是否启动自动检测人脸并上传验证
|
||||
function OnAutoDecete() {
|
||||
if ($('input[name=auto_decete]').prop('checked')) {
|
||||
videoctrl.EnableAutoDetect(1);
|
||||
} else {
|
||||
videoctrl.EnableAutoDetect(0);
|
||||
}
|
||||
}
|
||||
function OnQuickMode() {
|
||||
if ($('input[name=quick_mode]').prop('checked')) {
|
||||
if (!confirm('启动快速模式将有可能降低精确度,确定要启动吗?')) {
|
||||
$('input[name=quick_mode]').prop('checked', false);
|
||||
return;
|
||||
}
|
||||
videoctrl.EnableQuickMode(1);
|
||||
} else {
|
||||
videoctrl.EnableQuickMode(0);
|
||||
}
|
||||
}
|
||||
function ShowTips(txt) { $('#idet .tips').html(txt); }
|
||||
function ShowShiBieResult(label, jidu, image) {
|
||||
var filter = parseFloat($('input[name=jidu]:checked').val());
|
||||
if (filter <= jidu) {
|
||||
ShowTips('识别出【<strong>' + label + '</strong>】,精准度:' + Math.floor(jidu * 100) + '%');
|
||||
} else {
|
||||
ShowTips('无法识别,但系统猜测结果是【<strong>' + label + '</strong>】,精准度:' + Math.floor(jidu * 100) + '%');
|
||||
}
|
||||
|
||||
}
|
||||
var g_bFirstLoadFace = true;
|
||||
function LoadFaceLibLabel() {
|
||||
$('#facelib .tips').html('');
|
||||
$('#facelibpane').html('加载中……');
|
||||
|
||||
function PrompEmpty() {
|
||||
// $('#facelibpane').html('<font color=red>人脸库为空,需要先增加!</font>');
|
||||
if (g_bFirstLoadFace) {
|
||||
g_bFirstLoadFace = false;
|
||||
// $('<font color=red>人脸库为空,需要先增加!</font>').dialog({ autoOpen: true, width: 400, title: '提示' });
|
||||
ShowTips('人脸库为空,需要先增加!');
|
||||
}
|
||||
}
|
||||
function parseLabel(data) {
|
||||
var html = '<div class="labellist"><table>';
|
||||
$(data.list).each(function (i, o) {
|
||||
html += '<tr data="img_tr_' + i + '" onmouseover="javascript:this.style.backgroundColor=\'#FFD54A\'" onmouseout="javascript:this.style.backgroundColor=\'\'">';
|
||||
html += '<td>' + o.Label + '</td>';
|
||||
html += '<td><img src="' + GetServerUrl() + '?action=getimage&name=' + o.Image + '"/></td>';
|
||||
html += '<td><a href="javascript:DelLibByFile(\'' + o.Image + '\',' + i + ');">删除</a></td>';
|
||||
html += '</tr>';
|
||||
});
|
||||
html += '</table></div>';
|
||||
$('#facelibpane').html(html);
|
||||
}
|
||||
//get method
|
||||
|
||||
$.ajax(GetServerUrl() + '?action=alllabelimage&t=' + (new Date()).getTime(), {
|
||||
success: function (data) {
|
||||
$("#upload").attr("src", "uploadimg.aspx?identityCard=" + $('input[name=xunlianlabel]').val());
|
||||
if ('' == data) {
|
||||
PrompEmpty();
|
||||
} else {
|
||||
var o = eval('(' + data + ')');
|
||||
if (o.err == 0) {
|
||||
if (o.list == null || o.list.length == 0) {
|
||||
PrompEmpty();
|
||||
} else {
|
||||
parseLabel(o);
|
||||
}
|
||||
} else {
|
||||
$('#facelibpane').html("加载失败:" + e.desc);
|
||||
}
|
||||
}
|
||||
},
|
||||
error: function (data) {
|
||||
$('#facelibpane').html("加载失败请<a href='javascript:LoadFaceLibLabel();'>重试</a>!");
|
||||
}
|
||||
});
|
||||
}
|
||||
//初始化
|
||||
function OnInitLoad() {
|
||||
LoadFaceLibLabel(); //加载人脸图库
|
||||
SetServerUrl(); //一定要设置之后,自动识别才有效果
|
||||
setTimeout(OpenCamera, 3000); //自动打开摄像头
|
||||
|
||||
SetFilterJidu(0.85); //设置默认过滤相同人脸
|
||||
OnAutoDecete(); //自动识别检测
|
||||
//由于快速会影响识别的精确度,所以先取消掉
|
||||
///OnQuickMode(); //启动快速模式
|
||||
}
|
||||
$(function () {
|
||||
$('#tabsmain').tabs({
|
||||
beforeActivate: function (event, ui) {
|
||||
if (ui.newTab) {
|
||||
|
||||
if (ui.newTab.find('a[href=#facelib]').length == 1) {
|
||||
LoadFaceLibLabel();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
$("#vdo_options,#faceliboption").accordion({ collapsible: true, heightStyle: "content" });
|
||||
$('#radiosetjidu').buttonset();
|
||||
$('input[type=button]').button();
|
||||
$('#sliderjidu').slider({
|
||||
min: 1, max: 100, value: 85,
|
||||
slide: function (event, ui) {
|
||||
$("#sliderjidutips").val(ui.value + '%');
|
||||
var fjidu = parseFloat(ui.value);
|
||||
fjidu /= 100;
|
||||
SetFilterJidu(fjidu);
|
||||
}
|
||||
});
|
||||
//var vdoCtrl = document.getElementById('videoctrl');
|
||||
OnInitLoad();
|
||||
});
|
||||
</script>
|
||||
</head>
|
||||
<body style="margin-left: 50px">
|
||||
<div id="wapper">
|
||||
<div class="main">
|
||||
<div id="tabsmain">
|
||||
<ul>
|
||||
<li><a href="#idet">人脸识别</a></li>
|
||||
<li><a href="#facelib">人脸库</a></li>
|
||||
<li><a href="#importface">导入人脸库</a></li>
|
||||
</ul>
|
||||
<div id="idet">
|
||||
<div class="tips">
|
||||
</div>
|
||||
<div class="video">
|
||||
<object id="videoctrl" width="500" height="380" classid="CLSID:423B9F4C-A606-450D-9151-B44B511B4DC3">
|
||||
此控件需在IE下面才能正常运行!
|
||||
</object>
|
||||
</div>
|
||||
<div class="vdotool">
|
||||
<select name="cameraIdx">
|
||||
<option value="0">摄像头1</option>
|
||||
<option value="1">摄像头2</option>
|
||||
</select>
|
||||
<input value="打开摄像头" onclick="OpenCamera()" type="button" />
|
||||
<input type="button" value="关闭摄像头" onclick="CloseCamera()" />
|
||||
</div>
|
||||
<div id="vdo_options">
|
||||
<h3>
|
||||
训练人脸</h3>
|
||||
<div>
|
||||
标签:<input type="text" runat="server" id="xunlianlabel" name="xunlianlabel" readonly="readonly" /> <input
|
||||
type="button" value="训练当前帧" onclick="XunLianRenLian()" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="facelib">
|
||||
<div class="tips">
|
||||
</div>
|
||||
<div id="facelibpane">
|
||||
</div>
|
||||
<div id="faceliboption">
|
||||
<h3>
|
||||
按标签删除</h3>
|
||||
<div>
|
||||
输入要删除的标签:<input type="text" name="dellabel" /> <input type="button" value="删除标签"
|
||||
onclick="DeleteLabel()" /></div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="importface">
|
||||
<div class="desc">
|
||||
你可以针对某人上传一张图片并设置一标签对应,可以一个标签对应多张图片!<br />
|
||||
请尽量使用正脸照片!</div>
|
||||
<div class="mask" style="display: none;">
|
||||
上传处理中……</div>
|
||||
<iframe class="uploadifrm" id="upload" frameborder="0" scrolling="no" width="80%"
|
||||
height="400"></iframe>
|
||||
<div class="tool">
|
||||
<input type="button" value="终止或重新上传" onclick="ReLoadUploadImg()" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,15 @@
|
||||
using System;
|
||||
|
||||
namespace FineUIPro.Web.RLSB
|
||||
{
|
||||
public partial class WelderTrain : PageBase
|
||||
{
|
||||
protected void Page_Load(object sender, EventArgs e)
|
||||
{
|
||||
if (!IsPostBack)
|
||||
{
|
||||
this.xunlianlabel.Value = Request.Params["identityCard"];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <自动生成>
|
||||
// 此代码由工具生成。
|
||||
//
|
||||
// 对此文件的更改可能导致不正确的行为,如果
|
||||
// 重新生成代码,则所做更改将丢失。
|
||||
// </自动生成>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace FineUIPro.Web.RLSB {
|
||||
|
||||
|
||||
public partial class WelderTrain {
|
||||
|
||||
/// <summary>
|
||||
/// xunlianlabel 控件。
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// 自动生成的字段。
|
||||
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
|
||||
/// </remarks>
|
||||
protected global::System.Web.UI.HtmlControls.HtmlInputText xunlianlabel;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="uploadimg.aspx.cs" Inherits="RLSB.uploadimg" %>
|
||||
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head runat="server">
|
||||
<title></title>
|
||||
<script src="../Scripts/jquery-1.8.3.js" type="text/javascript"></script>
|
||||
<script src="../Scripts/jquery-ui-1.9.2.custom.min.js" type="text/javascript"></script>
|
||||
<link href="../Styles/sunny/jquery-ui-1.9.2.custom.min.css" rel="stylesheet" type="text/css" />
|
||||
<script type="text/javascript">
|
||||
if (!String.prototype.trim) {
|
||||
String.prototype.trim = function () {
|
||||
return this.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, '');
|
||||
};
|
||||
}
|
||||
|
||||
function Check() {
|
||||
if ($('input[name=file1]').val() == '') {
|
||||
$(".tips").html("<font color=red>没有选择一个文件!</font>");
|
||||
return false;
|
||||
}
|
||||
// var label = $('input[name=label]').val().trim();
|
||||
// if (label == '') {
|
||||
// $(".tips").html("<font color=red>请输入标签!</font>");
|
||||
// return false;
|
||||
// }
|
||||
parent.OnBeginUpload();
|
||||
$(".tips").html("<font color=blue>上传中...</font>");
|
||||
return true;
|
||||
}
|
||||
$(function () {
|
||||
$('input[type=submit]').button();
|
||||
});
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<form runat="server" id="form1">
|
||||
</form>
|
||||
<form action="RLSBProccess.ashx" method="post" enctype="multipart/form-data" onsubmit="return Check()">
|
||||
<input type="hidden" name="action" value="train" />
|
||||
<table style="margin: 0 auto;">
|
||||
<tr>
|
||||
<td>
|
||||
图片路径:
|
||||
</td>
|
||||
<td>
|
||||
<input type="file" name="file1" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
标签名:
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" runat="server" id="xunlianlabel" readonly="readonly" name="label" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2">
|
||||
<input type="submit" value="上传" />
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<br />
|
||||
</form>
|
||||
<div class="tips">
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,20 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using System.Web.UI;
|
||||
using System.Web.UI.WebControls;
|
||||
|
||||
namespace RLSB
|
||||
{
|
||||
public partial class uploadimg : System.Web.UI.Page
|
||||
{
|
||||
protected void Page_Load(object sender, EventArgs e)
|
||||
{
|
||||
if (!IsPostBack)
|
||||
{
|
||||
this.xunlianlabel.Value = Request.Params["identityCard"];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <自动生成>
|
||||
// 此代码由工具生成。
|
||||
//
|
||||
// 对此文件的更改可能会导致不正确的行为,并且如果
|
||||
// 重新生成代码,这些更改将会丢失。
|
||||
// </自动生成>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace RLSB {
|
||||
|
||||
|
||||
public partial class uploadimg {
|
||||
|
||||
/// <summary>
|
||||
/// form1 控件。
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// 自动生成的字段。
|
||||
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
|
||||
/// </remarks>
|
||||
protected global::System.Web.UI.HtmlControls.HtmlForm form1;
|
||||
|
||||
/// <summary>
|
||||
/// xunlianlabel 控件。
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// 自动生成的字段。
|
||||
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
|
||||
/// </remarks>
|
||||
protected global::System.Web.UI.HtmlControls.HtmlInputText xunlianlabel;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user