81 changed files with 17537 additions and 0 deletions
@ -0,0 +1,3 @@ |
|||||
|
.vs/ |
||||
|
packages/ |
||||
|
FaceDetect/obj/ |
||||
@ -0,0 +1,25 @@ |
|||||
|
|
||||
|
Microsoft Visual Studio Solution File, Format Version 12.00 |
||||
|
# Visual Studio Version 17 |
||||
|
VisualStudioVersion = 17.2.32616.157 |
||||
|
MinimumVisualStudioVersion = 10.0.40219.1 |
||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FaceDetect", "FaceDetect\FaceDetect.csproj", "{D1AC3DD6-CA8D-4141-A250-E17EF25D6091}" |
||||
|
EndProject |
||||
|
Global |
||||
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution |
||||
|
Debug|Any CPU = Debug|Any CPU |
||||
|
Release|Any CPU = Release|Any CPU |
||||
|
EndGlobalSection |
||||
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution |
||||
|
{D1AC3DD6-CA8D-4141-A250-E17EF25D6091}.Debug|Any CPU.ActiveCfg = Debug|Any CPU |
||||
|
{D1AC3DD6-CA8D-4141-A250-E17EF25D6091}.Debug|Any CPU.Build.0 = Debug|Any CPU |
||||
|
{D1AC3DD6-CA8D-4141-A250-E17EF25D6091}.Release|Any CPU.ActiveCfg = Release|Any CPU |
||||
|
{D1AC3DD6-CA8D-4141-A250-E17EF25D6091}.Release|Any CPU.Build.0 = Release|Any CPU |
||||
|
EndGlobalSection |
||||
|
GlobalSection(SolutionProperties) = preSolution |
||||
|
HideSolutionNode = FALSE |
||||
|
EndGlobalSection |
||||
|
GlobalSection(ExtensibilityGlobals) = postSolution |
||||
|
SolutionGuid = {B8632D8A-9E42-409F-93B9-1326F7D40EFC} |
||||
|
EndGlobalSection |
||||
|
EndGlobal |
||||
@ -0,0 +1,34 @@ |
|||||
|
<?xml version="1.0" encoding="utf-8" ?> |
||||
|
<configuration> |
||||
|
<appSettings> |
||||
|
<!--是否需要常开视频流--> |
||||
|
<add key="NeedAlive" value="0"/> |
||||
|
<!--视频流像素X位--> |
||||
|
<add key="LiveX" value="200"/> |
||||
|
<!--视频流像素Y位--> |
||||
|
<add key="LiveY" value="200"/> |
||||
|
<!--视频流宽度--> |
||||
|
<add key="LiveWidth" value="250"/> |
||||
|
<!--视频流高度--> |
||||
|
<add key="LiveHeight" value="250"/> |
||||
|
<!--比对阈值--> |
||||
|
<add key="Threshold" value="80"/> |
||||
|
<!--摄像头配置,有n个摄像头,可配置为0到n-1,分别调用不同的摄像头--> |
||||
|
<add key="CameraIndex" value="0"/> |
||||
|
<!--百度人脸Sdk最大检测数--> |
||||
|
<add key="MaxDectNum" value="10"/> |
||||
|
<!--大后台服务器地址--> |
||||
|
<add key="HttpUrl" value="http://192.168.1.141:8015"/> |
||||
|
<!--小后台服务器地址--> |
||||
|
<add key="KioskUrl" value="https://localhost:7143"/> |
||||
|
<!--AllWebSocket地址--> |
||||
|
<!--<add key="WebsocketForAll" value="ws://127.0.0.1:7180"/>--> |
||||
|
<!--人脸WebSocket地址--> |
||||
|
<add key="WebsocketForFace" value="ws://127.0.0.1:7179"/> |
||||
|
<!--直播WebSocket地址--> |
||||
|
<add key="WebsocketForLive" value="ws://127.0.0.1:7188"/> |
||||
|
</appSettings> |
||||
|
<startup> |
||||
|
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8" /> |
||||
|
</startup> |
||||
|
</configuration> |
||||
@ -0,0 +1,9 @@ |
|||||
|
<Application x:Class="FaceDetect.App" |
||||
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" |
||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" |
||||
|
xmlns:local="clr-namespace:FaceDetect" |
||||
|
StartupUri="MainWindow.xaml"> |
||||
|
<Application.Resources> |
||||
|
|
||||
|
</Application.Resources> |
||||
|
</Application> |
||||
@ -0,0 +1,70 @@ |
|||||
|
using Microsoft.VisualBasic.ApplicationServices; |
||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Configuration; |
||||
|
using System.Data; |
||||
|
using System.Linq; |
||||
|
using System.Threading.Tasks; |
||||
|
using System.Windows; |
||||
|
|
||||
|
namespace FaceDetect |
||||
|
{ |
||||
|
public class EntryPoint |
||||
|
{ |
||||
|
[STAThread] |
||||
|
public static void Main(string[] args) |
||||
|
{ |
||||
|
SingleInstanceManager manager = new SingleInstanceManager(); |
||||
|
manager.Run(args); |
||||
|
} |
||||
|
} |
||||
|
/// <summary>
|
||||
|
/// App.xaml 的交互逻辑
|
||||
|
/// </summary>
|
||||
|
public partial class App : Application |
||||
|
{ |
||||
|
public App() |
||||
|
{ |
||||
|
InitializeComponent(); |
||||
|
} |
||||
|
public void Activate() |
||||
|
{ |
||||
|
this.MainWindow.Show(); |
||||
|
this.MainWindow.Activate(); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
public class SingleInstanceManager : |
||||
|
Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase |
||||
|
{ |
||||
|
private App wpfapp; // 这才是真正的WPF Application
|
||||
|
/// <summary>
|
||||
|
/// 单例程序
|
||||
|
/// </summary>
|
||||
|
public SingleInstanceManager() |
||||
|
{ |
||||
|
this.IsSingleInstance = true; |
||||
|
} |
||||
|
|
||||
|
// 第一次打开调这个方法
|
||||
|
protected override bool OnStartup( |
||||
|
Microsoft.VisualBasic.ApplicationServices.StartupEventArgs e) |
||||
|
{ |
||||
|
wpfapp = new App(); |
||||
|
wpfapp.Run(); |
||||
|
|
||||
|
return false; |
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 当有其他应用程序实例化时,则触发此事件,弹出已存在的实例窗口
|
||||
|
/// </summary>
|
||||
|
/// <param name="eventArgs"></param>
|
||||
|
protected override void OnStartupNextInstance(StartupNextInstanceEventArgs eventArgs) |
||||
|
{ |
||||
|
// Subsequent launches
|
||||
|
base.OnStartupNextInstance(eventArgs); |
||||
|
//wpfapp.Activate();
|
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,877 @@ |
|||||
|
using FaceDetect.Model; |
||||
|
using Newtonsoft.Json; |
||||
|
using OpenCvSharp; |
||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.IO; |
||||
|
using System.Linq; |
||||
|
using System.Runtime.InteropServices; |
||||
|
using System.Text; |
||||
|
using System.Threading.Tasks; |
||||
|
|
||||
|
namespace FaceDetect.Common |
||||
|
{ |
||||
|
public class BaiduFaceSdk |
||||
|
{ |
||||
|
public static BaiduFaceSdk SDK |
||||
|
{ |
||||
|
get |
||||
|
{ |
||||
|
if (_sdk == null) |
||||
|
_sdk = new BaiduFaceSdk(); |
||||
|
return _sdk; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
private static BaiduFaceSdk _sdk; |
||||
|
|
||||
|
#region 百度DLL导入
|
||||
|
// sdk初始化
|
||||
|
[DllImport("BaiduFaceApi.dll", EntryPoint = "sdk_init", CharSet = CharSet.Ansi |
||||
|
, CallingConvention = CallingConvention.Cdecl)] |
||||
|
private static extern int sdk_init(string model_path); |
||||
|
|
||||
|
// 是否授权
|
||||
|
[DllImport("BaiduFaceApi.dll", EntryPoint = "is_auth", CharSet = CharSet.Ansi |
||||
|
, CallingConvention = CallingConvention.Cdecl)] |
||||
|
private static extern bool is_auth(); |
||||
|
|
||||
|
// sdk销毁
|
||||
|
[DllImport("BaiduFaceApi.dll", EntryPoint = "sdk_destroy", CharSet = CharSet.Ansi |
||||
|
, CallingConvention = CallingConvention.Cdecl)] |
||||
|
private static extern void sdk_destroy(); |
||||
|
|
||||
|
// type 为0时候执行RGB人脸跟踪,1时候执行NIR人脸跟踪
|
||||
|
[DllImport("BaiduFaceApi.dll", EntryPoint = "track", CharSet = CharSet.Ansi |
||||
|
, CallingConvention = CallingConvention.Cdecl)] |
||||
|
public static extern int track(IntPtr ptr, IntPtr mat, int type); |
||||
|
|
||||
|
// type 为0时候执行RGB人脸跟踪,1时候执行NIR人脸跟踪
|
||||
|
[DllImport("BaiduFaceApi.dll", EntryPoint = "clear_track_history", CharSet = CharSet.Ansi |
||||
|
, CallingConvention = CallingConvention.Cdecl)] |
||||
|
public static extern void clear_track_history(int type); |
||||
|
|
||||
|
// 获取人脸属性
|
||||
|
[DllImport("BaiduFaceApi.dll", EntryPoint = "face_attr", CharSet = CharSet.Ansi |
||||
|
, CallingConvention = CallingConvention.Cdecl)] |
||||
|
public static extern int face_attr(IntPtr ptr, IntPtr mat); |
||||
|
|
||||
|
//人脸检测 type 0: 表示rgb 人脸检测 1:表示nir人脸检测
|
||||
|
[DllImport("BaiduFaceApi.dll", EntryPoint = "detect", CharSet = CharSet.Ansi |
||||
|
, CallingConvention = CallingConvention.Cdecl)] |
||||
|
public static extern int detect(IntPtr ptr, IntPtr mat, int type); |
||||
|
#endregion
|
||||
|
#region 百度结构体
|
||||
|
[StructLayout(LayoutKind.Sequential, Pack = 1)] |
||||
|
public struct BDFaceBBox |
||||
|
{ |
||||
|
public int index; // 人脸索引值
|
||||
|
public float center_x; // 人脸中心点x坐标
|
||||
|
public float center_y; // 人脸中心点y坐标
|
||||
|
public float width; // 人脸宽度
|
||||
|
public float height; // 人脸高度
|
||||
|
public float angle; // 人脸角度
|
||||
|
public float score; // 人脸置信度
|
||||
|
} |
||||
|
|
||||
|
[StructLayout(LayoutKind.Sequential, Pack = 1)] |
||||
|
public struct BDFaceLandmark |
||||
|
{ |
||||
|
public int index; // 人脸关键点索引值
|
||||
|
public int size; // 人脸关键点数量
|
||||
|
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 144)] |
||||
|
public float[] data;// = new float[144];
|
||||
|
public float score; // 人脸关键点置信度
|
||||
|
} |
||||
|
[StructLayout(LayoutKind.Sequential, Pack = 1)] |
||||
|
public struct BDFaceTrackInfo |
||||
|
{ |
||||
|
public int face_id; |
||||
|
[MarshalAs(UnmanagedType.Struct)] |
||||
|
public BDFaceBBox box; |
||||
|
[MarshalAs(UnmanagedType.Struct)] |
||||
|
public BDFaceLandmark landmark; |
||||
|
} |
||||
|
/// <summary>
|
||||
|
/// 人脸表情属性枚举
|
||||
|
/// </summary>
|
||||
|
enum BDFaceAttributeEmotionType |
||||
|
{ |
||||
|
BDFACE_ATTRIBUTE_EMOTION_FROWN = 0, // 皱眉
|
||||
|
BDFACE_ATTRIBUTE_EMOTION_SMILE = 1, // 笑
|
||||
|
BDFACE_ATTRIBUTE_EMOTION_CALM = 2, // 平静
|
||||
|
}; |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 人脸种族属性枚举
|
||||
|
/// </summary>
|
||||
|
enum BDFaceRace |
||||
|
{ |
||||
|
BDFACE_RACE_YELLOW = 0, // 黄种人
|
||||
|
BDFACE_RACE_WHITE = 1, // 白种人
|
||||
|
BDFACE_RACE_BLACK = 2, // 黑种人
|
||||
|
BDFACE_RACE_INDIAN = 3, // 印第安人
|
||||
|
}; |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 眼镜状态属性枚举
|
||||
|
/// </summary>
|
||||
|
enum BDFaceGlasses |
||||
|
{ |
||||
|
BDFACE_NO_GLASSES = 0, // 无眼镜
|
||||
|
BDFACE_GLASSES = 1, // 有眼镜
|
||||
|
BDFACE_SUN_GLASSES = 2, // 墨镜
|
||||
|
}; |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 性别属性枚举
|
||||
|
/// </summary>
|
||||
|
public enum BDFaceGender |
||||
|
{ |
||||
|
BDFACE_GENDER_FEMAILE = 0, // 女性
|
||||
|
BDFACE_GENDER_MALE = 1, // 男性
|
||||
|
}; |
||||
|
|
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 人脸属性结构体
|
||||
|
/// </summary>
|
||||
|
[StructLayout(LayoutKind.Sequential, Pack = 1)] |
||||
|
struct BDFaceAttribute |
||||
|
{ |
||||
|
public int age; // 年龄
|
||||
|
public BDFaceRace race; // 种族
|
||||
|
public BDFaceAttributeEmotionType emotion; // 表情
|
||||
|
public BDFaceGlasses glasses; // 戴眼镜状态
|
||||
|
public BDFaceGender gender; // 性别
|
||||
|
}; |
||||
|
#endregion
|
||||
|
#region 业务逻辑类
|
||||
|
/// <summary>
|
||||
|
/// 综合识别类
|
||||
|
/// </summary>
|
||||
|
public struct FaceDectData |
||||
|
{ |
||||
|
public int index; // 人脸索引值
|
||||
|
public float center_x; // 人脸中心点x坐标
|
||||
|
public float center_y; // 人脸中心点y坐标
|
||||
|
public float width; // 人脸宽度
|
||||
|
public float height; // 人脸高度
|
||||
|
public float angle; // 人脸角度
|
||||
|
public float score; // 人脸置信度
|
||||
|
public int age;// 年龄
|
||||
|
public BDFaceGender gender;// 性别
|
||||
|
} |
||||
|
#endregion
|
||||
|
#region 业务逻辑变量
|
||||
|
/// <summary>
|
||||
|
/// type 为0时候执行RGB人脸跟踪,1时候执行NIR人脸跟踪
|
||||
|
/// </summary>
|
||||
|
private int _trackType = 0; |
||||
|
/// <summary>
|
||||
|
/// 人脸属性值空默认值
|
||||
|
/// </summary>
|
||||
|
private BDFaceAttribute[] _emptyAttr = new BDFaceAttribute[0]; |
||||
|
/// <summary>
|
||||
|
/// 人脸检测空默认值
|
||||
|
/// </summary>
|
||||
|
private BDFaceBBox[] _emptyBox = new BDFaceBBox[0]; |
||||
|
/// <summary>
|
||||
|
/// 人脸特征空默认值
|
||||
|
/// </summary>
|
||||
|
private BDFaceTrackInfo[] _emptyTrack = new BDFaceTrackInfo[0]; |
||||
|
/// <summary>
|
||||
|
/// 人脸综合空默认值
|
||||
|
/// </summary>
|
||||
|
private FaceDectData[] _emptyInfo = new FaceDectData[0]; |
||||
|
/// <summary>
|
||||
|
/// 停留两秒后被判定的当前检测到的主 人脸
|
||||
|
/// </summary>
|
||||
|
public FaceDectData? _masterFace = null; |
||||
|
/// <summary>
|
||||
|
/// 近期人脸特征字典(从未检测到人脸到检测到人脸期间的人脸,当未检测到人脸时会清空)
|
||||
|
/// </summary>
|
||||
|
private Dictionary<int, FaceDectData> _faceDic = new Dictionary<int, FaceDectData>(); |
||||
|
/// <summary>
|
||||
|
/// 首次进入时的人脸时间字典
|
||||
|
/// </summary>
|
||||
|
private Dictionary<int, DateTime> _faceEnterDic = new Dictionary<int, DateTime>(); |
||||
|
/// <summary>
|
||||
|
/// 首次未被识别到的人脸时间字典(检测到不同人脸时会记录上一个人脸id和(第一次未检测到这个人的)时间)
|
||||
|
/// </summary>
|
||||
|
private Dictionary<int, DateTime?> _faceLeaveDic = new Dictionary<int, DateTime?>(); |
||||
|
private bool _isSendLive; |
||||
|
#endregion
|
||||
|
#region 方法
|
||||
|
/// <summary>
|
||||
|
/// 初始化
|
||||
|
/// </summary>
|
||||
|
/// <returns>true-成功 false-失败</returns>
|
||||
|
public static bool Init() |
||||
|
{ |
||||
|
try |
||||
|
{ |
||||
|
//更新sdk配置文件
|
||||
|
UpdateConfig(); |
||||
|
//初始化
|
||||
|
int n = sdk_init(AppDomain.CurrentDomain.BaseDirectory); |
||||
|
if (n != 0) |
||||
|
{ |
||||
|
Log.MyLog.WriteLogFile("百度人脸Sdk初始化失败!", "BaiduSDKError"); |
||||
|
return false; |
||||
|
} |
||||
|
if (is_auth()) |
||||
|
{ |
||||
|
return true; |
||||
|
} |
||||
|
else |
||||
|
{ |
||||
|
Log.MyLog.WriteLogFile("设备未授权!", "BaiduSDKError"); |
||||
|
return false; |
||||
|
} |
||||
|
} |
||||
|
catch (Exception ex) |
||||
|
{ |
||||
|
Log.MyLog.WriteLogFile("百度人脸Sdk初始化异常:" + ex.Message); |
||||
|
return false; |
||||
|
} |
||||
|
} |
||||
|
/// <summary>
|
||||
|
/// 使用完毕,销毁sdk,释放内存
|
||||
|
/// </summary>
|
||||
|
public static void Destory() |
||||
|
{ |
||||
|
try |
||||
|
{ |
||||
|
sdk_destroy(); |
||||
|
} |
||||
|
catch (Exception ex) |
||||
|
{ |
||||
|
Log.MyLog.WriteLogFile("百度人脸Sdk销毁异常:" + ex.Message); |
||||
|
} |
||||
|
} |
||||
|
/// <summary>
|
||||
|
/// 更新Sdk配置文件
|
||||
|
/// </summary>
|
||||
|
public static void UpdateConfig() |
||||
|
{ |
||||
|
try |
||||
|
{ |
||||
|
var filePath = Path.Combine(ComParameters.Parameters._baseDir, "config", "detect.json"); |
||||
|
if (!File.Exists(filePath)) |
||||
|
{ |
||||
|
Log.MyLog.WriteLogFile("Sdk配置文件路径异常:" + filePath); |
||||
|
return; |
||||
|
} |
||||
|
var content = FileManage.ReadJsonFile(filePath); |
||||
|
if (!string.IsNullOrEmpty(content)) |
||||
|
{ |
||||
|
var model = JsonConvert.DeserializeObject<DetectModel>(content); |
||||
|
model.max_detect_num = ComParameters.Parameters._maxDectNum; |
||||
|
FileManage.WriteJsonFile(filePath, JsonConvert.SerializeObject(model)); |
||||
|
} |
||||
|
|
||||
|
} |
||||
|
catch (Exception ex) |
||||
|
{ |
||||
|
Log.MyLog.WriteLogFile("更新Sdk配置文件毁异常:" + ex.Message); |
||||
|
} |
||||
|
} |
||||
|
/// <summary>
|
||||
|
/// 人脸检测
|
||||
|
/// </summary>
|
||||
|
/// <param name="mat"></param>
|
||||
|
/// <param name="maxDectNum"></param>
|
||||
|
/// <returns></returns>
|
||||
|
private BDFaceBBox[] DetectFace(Mat mat, int maxDectNum) |
||||
|
{ |
||||
|
try |
||||
|
{ |
||||
|
int sizeTrack = Marshal.SizeOf(typeof(BDFaceBBox)); |
||||
|
IntPtr ptT = Marshal.AllocHGlobal(sizeTrack * maxDectNum); |
||||
|
int faceNum = detect(ptT, mat.CvPtr, _trackType); |
||||
|
if (faceNum > 0) |
||||
|
{ |
||||
|
// 因为需预分配内存,所以返回的人脸数若大于预先分配的内存数,则仅仅显示预分配的人脸数
|
||||
|
if (faceNum > maxDectNum) |
||||
|
{ |
||||
|
faceNum = maxDectNum; |
||||
|
} |
||||
|
BDFaceBBox[] info = new BDFaceBBox[faceNum]; |
||||
|
for (int index = 0; index < faceNum; index++) |
||||
|
{ |
||||
|
|
||||
|
IntPtr ptr = new IntPtr(); |
||||
|
if (8 == IntPtr.Size) |
||||
|
{ |
||||
|
ptr = (IntPtr)(ptT.ToInt64() + sizeTrack * index); |
||||
|
} |
||||
|
else if (4 == IntPtr.Size) |
||||
|
{ |
||||
|
ptr = (IntPtr)(ptT.ToInt32() + sizeTrack * index); |
||||
|
} |
||||
|
|
||||
|
info[index] = (BDFaceBBox)Marshal.PtrToStructure(ptr, typeof(BDFaceBBox)); |
||||
|
|
||||
|
//// 索引值
|
||||
|
//Console.WriteLine("detect index is:{0}", info[index].index);
|
||||
|
//// 置信度
|
||||
|
//Console.WriteLine("detect score is:{0}", info[index].score);
|
||||
|
//// 角度
|
||||
|
//Console.WriteLine("detect mAngle is:{0}", info[index].angle);
|
||||
|
//// 人脸宽度
|
||||
|
//Console.WriteLine("detect mWidth is:{0}", info[index].width);
|
||||
|
//// 中心点X,Y坐标
|
||||
|
//Console.WriteLine("detect mCenter_x is:{0}", info[index].center_x);
|
||||
|
//Console.WriteLine("detect mCenter_y is:{0}", info[index].center_y);
|
||||
|
} |
||||
|
Marshal.FreeHGlobal(ptT); |
||||
|
info = info.Where(p => p.score > ComParameters.Parameters._miniThreshold).ToArray(); |
||||
|
return info; |
||||
|
} |
||||
|
else |
||||
|
{ |
||||
|
return _emptyBox; |
||||
|
} |
||||
|
|
||||
|
} |
||||
|
catch (Exception ex) |
||||
|
{ |
||||
|
Log.MyLog.WriteLogFile("人脸检测失败" + ex.Message); |
||||
|
return _emptyBox; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 获取人脸属性值
|
||||
|
/// </summary>
|
||||
|
/// <param name="mat"></param>
|
||||
|
/// <param name="maxDectNum"></param>
|
||||
|
/// <returns></returns>
|
||||
|
private BDFaceAttribute[] GetFaceAttr(Mat mat, int maxDectNum) |
||||
|
{ |
||||
|
try |
||||
|
{ |
||||
|
int size = Marshal.SizeOf(typeof(BDFaceAttribute)); |
||||
|
IntPtr ptT = Marshal.AllocHGlobal(size * maxDectNum); |
||||
|
int faceNum = face_attr(ptT, mat.CvPtr); |
||||
|
if (faceNum > 0) |
||||
|
{ |
||||
|
if (faceNum > maxDectNum) |
||||
|
{ |
||||
|
faceNum = maxDectNum; |
||||
|
} |
||||
|
BDFaceAttribute[] attr_info = new BDFaceAttribute[faceNum]; |
||||
|
for (int index = 0; index < faceNum; index++) |
||||
|
{ |
||||
|
IntPtr ptr = new IntPtr(); |
||||
|
if (8 == IntPtr.Size) |
||||
|
{ |
||||
|
ptr = (IntPtr)(ptT.ToInt64() + size * index); |
||||
|
} |
||||
|
else if (4 == IntPtr.Size) |
||||
|
{ |
||||
|
ptr = (IntPtr)(ptT.ToInt32() + size * index); |
||||
|
} |
||||
|
|
||||
|
attr_info[index] = (BDFaceAttribute)Marshal.PtrToStructure(ptr, typeof(BDFaceAttribute)); |
||||
|
//// 年龄
|
||||
|
//Console.WriteLine("age is {0}:", attr_info[index].age);
|
||||
|
//// 种族
|
||||
|
//Console.WriteLine("race is:{0}", attr_info[index].race);
|
||||
|
//// 表情
|
||||
|
//Console.WriteLine("emotion is:{0}", attr_info[index].emotion);
|
||||
|
//// 戴眼镜状态
|
||||
|
//Console.WriteLine("glasses is:{0}", attr_info[index].glasses);
|
||||
|
//// 性别
|
||||
|
//Console.WriteLine("gender is:{0}", attr_info[index].gender);
|
||||
|
} |
||||
|
Marshal.FreeHGlobal(ptT); |
||||
|
return attr_info; |
||||
|
} |
||||
|
else |
||||
|
{ |
||||
|
return _emptyAttr; |
||||
|
} |
||||
|
} |
||||
|
catch (Exception ex) |
||||
|
{ |
||||
|
Log.MyLog.WriteLogFile("获取人脸属性值失败" + ex.Message); |
||||
|
return _emptyAttr; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 获取人脸特征值
|
||||
|
/// </summary>
|
||||
|
/// <param name="mat"></param>
|
||||
|
/// <param name="maxDectNum"></param>
|
||||
|
/// <returns></returns>
|
||||
|
private BDFaceTrackInfo[] GetFaceTrac(Mat mat, int maxDectNum) |
||||
|
{ |
||||
|
try |
||||
|
{ |
||||
|
int sizeTrack = Marshal.SizeOf(typeof(BDFaceTrackInfo)); |
||||
|
IntPtr ptT = Marshal.AllocHGlobal(sizeTrack * maxDectNum); |
||||
|
// faceNum为返回的检测到的人脸个数
|
||||
|
var faceNum = track(ptT, mat.CvPtr, _trackType); |
||||
|
if (faceNum > 0) |
||||
|
{ |
||||
|
// 因为需预分配内存,所以返回的人脸数若大于预先分配的内存数,则仅仅显示预分配的人脸数
|
||||
|
if (faceNum > maxDectNum) |
||||
|
{ |
||||
|
faceNum = maxDectNum; |
||||
|
} |
||||
|
BDFaceTrackInfo[] track_info = new BDFaceTrackInfo[faceNum]; |
||||
|
for (int i = 0; i < faceNum; i++) |
||||
|
{ |
||||
|
track_info[i] = new BDFaceTrackInfo(); |
||||
|
track_info[i].box = new BDFaceBBox(); |
||||
|
track_info[i].box.score = 0; |
||||
|
track_info[i].box.width = 0; |
||||
|
track_info[i].landmark.data = new float[144]; |
||||
|
track_info[i].face_id = 0; |
||||
|
} |
||||
|
|
||||
|
for (int index = 0; index < faceNum; index++) |
||||
|
{ |
||||
|
|
||||
|
IntPtr ptr = new IntPtr(); |
||||
|
if (8 == IntPtr.Size) |
||||
|
{ |
||||
|
ptr = (IntPtr)(ptT.ToInt64() + sizeTrack * index); |
||||
|
} |
||||
|
else if (4 == IntPtr.Size) |
||||
|
{ |
||||
|
ptr = (IntPtr)(ptT.ToInt32() + sizeTrack * index); |
||||
|
} |
||||
|
|
||||
|
track_info[index] = (BDFaceTrackInfo)Marshal.PtrToStructure(ptr, typeof(BDFaceTrackInfo)); |
||||
|
//Console.WriteLine("track face_id is {0}:", track_info[index].face_id);
|
||||
|
//Console.WriteLine("track landmarks is:");
|
||||
|
|
||||
|
//for(int i = 0; i < 144; i++)
|
||||
|
//{
|
||||
|
// Console.WriteLine("lanmark data is {0}:", track_info[index].landmark.data[i]);
|
||||
|
//}
|
||||
|
//Console.WriteLine("track landmarks score is:{0}", track_info[index].landmark.score);
|
||||
|
//Console.WriteLine("track landmarks index is:{0}", track_info[index].landmark.index);
|
||||
|
|
||||
|
//// 索引值
|
||||
|
//Console.WriteLine("track score is:{0}", track_info[index].box.index);
|
||||
|
//// 置信度
|
||||
|
//Console.WriteLine("track score is:{0}", track_info[index].box.score);
|
||||
|
//// 角度
|
||||
|
//Console.WriteLine("track mAngle is:{0}", track_info[index].box.angle);
|
||||
|
//// 人脸宽度
|
||||
|
//Console.WriteLine("track mWidth is:{0}", track_info[index].box.width);
|
||||
|
//// 中心点X,Y坐标
|
||||
|
//Console.WriteLine("track mCenter_x is:{0}", track_info[index].box.center_x);
|
||||
|
//Console.WriteLine("track mCenter_y is:{0}", track_info[index].box.center_y);
|
||||
|
} |
||||
|
track_info = track_info.Where(p => p.box.score > ComParameters.Parameters._miniThreshold).ToArray(); |
||||
|
//track_info = track_info.Where(p => p.landmark.score > ComParameters.Parameters._miniThreshold).ToArray();
|
||||
|
Marshal.FreeHGlobal(ptT); |
||||
|
return track_info; |
||||
|
} |
||||
|
else |
||||
|
{ |
||||
|
return _emptyTrack; |
||||
|
} |
||||
|
} |
||||
|
catch (Exception ex) |
||||
|
{ |
||||
|
Log.MyLog.WriteLogFile("获取人脸特征值失败" + ex.Message); |
||||
|
return _emptyTrack; |
||||
|
} |
||||
|
} |
||||
|
/// <summary>
|
||||
|
/// 清除人脸追踪历史
|
||||
|
/// </summary>
|
||||
|
public void ClearTrack() |
||||
|
{ |
||||
|
clear_track_history(_trackType); |
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 获取人脸检测属性值
|
||||
|
/// </summary>
|
||||
|
/// <param name="mat">图像帧</param>
|
||||
|
/// <param name="maxDectNum">最大检测人数</param>
|
||||
|
/// <param name="Info">传出的检测值</param>
|
||||
|
/// <returns></returns>
|
||||
|
private FaceDectData[] GetFaceInfoAttr(Mat mat, int maxDectNum) |
||||
|
{ |
||||
|
var Info = DetectFace(mat, maxDectNum); |
||||
|
if (Info.Any()) |
||||
|
{ |
||||
|
var attrInfo = GetFaceAttr(mat, maxDectNum); |
||||
|
var resu = Info.Select(p => new FaceDectData |
||||
|
{ |
||||
|
index=p.index, |
||||
|
center_x= p.center_x, |
||||
|
center_y= p.center_y, |
||||
|
width=p.width, |
||||
|
height = p.height, |
||||
|
angle = p.angle, |
||||
|
score = p.score, |
||||
|
}).ToArray(); |
||||
|
for (int i = 0; i < Info.Length; i++) |
||||
|
{ |
||||
|
resu[i].age = i < attrInfo.Length ? attrInfo[i].age : int.MaxValue; |
||||
|
resu[i].gender = i < attrInfo.Length ? attrInfo[i].gender : BDFaceGender.BDFACE_GENDER_MALE; |
||||
|
} |
||||
|
return resu; |
||||
|
} |
||||
|
return _emptyInfo; |
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// usb摄像头实时人脸检测示例
|
||||
|
/// </summary>
|
||||
|
public void USBVideoTract() |
||||
|
{ |
||||
|
using (var window = new Window("face")) |
||||
|
using (VideoCapture cap = VideoCapture.FromCamera(ComParameters.Parameters._cameraIndex)) |
||||
|
{ |
||||
|
if (!cap.IsOpened()) |
||||
|
{ |
||||
|
Log.MyLog.WriteLogFile("打开摄像头失败!"); |
||||
|
return; |
||||
|
} |
||||
|
// Frame image buffer
|
||||
|
Mat image = new Mat(); |
||||
|
// When the movie playback reaches end, Mat.data becomes NULL.
|
||||
|
while (true) |
||||
|
{ |
||||
|
try |
||||
|
{ |
||||
|
//读取相机帧
|
||||
|
cap.Read(image); // same as cvQueryFrame
|
||||
|
if (!image.Empty()) |
||||
|
{ |
||||
|
FaceDectData? currentFace = null; |
||||
|
#region 推送流文件
|
||||
|
if ((ComParameters.Parameters._isLive || ComParameters.Parameters._isOpenLive) && null != image) |
||||
|
{ |
||||
|
using (var newFrame = new Mat(image, new Rect(new Point(ComParameters.Parameters._liveX, ComParameters.Parameters._liveY), new Size(ComParameters.Parameters._liveWidth, ComParameters.Parameters._liveHeight)))) |
||||
|
{ |
||||
|
try |
||||
|
{ |
||||
|
var encodeBuff = newFrame.ImEncode(".jpg"); |
||||
|
var base64Str = Convert.ToBase64String(encodeBuff); |
||||
|
var faceData = new FaceSocketModel |
||||
|
{ |
||||
|
age = 0, |
||||
|
genderMale = "", |
||||
|
vipId = "", |
||||
|
faceID = "", |
||||
|
carNo = "", |
||||
|
faceImage = base64Str |
||||
|
}; |
||||
|
//获取特征属性值
|
||||
|
var speInfos = GetFaceInfoAttr(newFrame, 1); |
||||
|
//bool isSuccess = false;
|
||||
|
if (speInfos != null && speInfos.Any()) |
||||
|
{ |
||||
|
faceData.age = speInfos[0].age; |
||||
|
faceData.genderMale = speInfos[0].gender == BDFaceGender.BDFACE_GENDER_MALE ? "男" : "女"; |
||||
|
|
||||
|
#region 不需要的逻辑
|
||||
|
//foreach (var item in speInfos)
|
||||
|
//{
|
||||
|
// //isSuccess = true;
|
||||
|
// //var vipId = string.Empty;
|
||||
|
// //var faceID = string.Empty;
|
||||
|
// //var carNo = string.Empty;
|
||||
|
|
||||
|
// //if (!string.IsNullOrEmpty(ComParameters.Parameters._kioskUrl) && !_isSendLive)
|
||||
|
// //{
|
||||
|
// // _isSendLive = true;
|
||||
|
|
||||
|
// // var dic = HttpComm.Http.UploadImage("Face=" + base64Str);
|
||||
|
// // if (dic != null)
|
||||
|
// // {
|
||||
|
// // vipId = dic.ContainsKey("vipId") && dic["vipId"] == null ? "" : dic["vipId"].ToString();
|
||||
|
// // faceID = dic.ContainsKey("faceID") && dic["faceID"] == null ? "" : dic["faceID"].ToString();
|
||||
|
// // carNo = dic.ContainsKey("carNo") && dic["carNo"] == null ? "" : dic["carNo"].ToString();
|
||||
|
// // ComParameters.Parameters._isLive = false;
|
||||
|
// // }
|
||||
|
// // else
|
||||
|
// // {
|
||||
|
// // _isSendLive = false;
|
||||
|
// // }
|
||||
|
// //}
|
||||
|
// //var faceData = new FaceSocketModel
|
||||
|
// //{
|
||||
|
// // age = item.age,
|
||||
|
// // vipId = vipId,
|
||||
|
// // faceID = faceID,
|
||||
|
// // carNo = carNo,
|
||||
|
// // genderMale = item.gender == BDFaceGender.BDFACE_GENDER_MALE ? "男" : "女",
|
||||
|
// // faceImage = base64Str
|
||||
|
// //};
|
||||
|
// if (!ComParameters.Parameters._isLive)
|
||||
|
// {
|
||||
|
// //_isSendLive = false;
|
||||
|
// WebSocketManager.WebSocket.PushImage(JsonConvert.SerializeObject(faceData));
|
||||
|
// }
|
||||
|
//}
|
||||
|
#endregion
|
||||
|
} |
||||
|
#region 不需要的逻辑
|
||||
|
//if (!isSuccess)
|
||||
|
//{
|
||||
|
// var faceData = new FaceSocketModel
|
||||
|
// {
|
||||
|
// age = 0,
|
||||
|
// genderMale = "",
|
||||
|
// vipId = "",
|
||||
|
// faceID = "",
|
||||
|
// carNo = "",
|
||||
|
// faceImage = base64Str
|
||||
|
// };
|
||||
|
// WebSocketManager.WebSocket.PushImage(JsonConvert.SerializeObject(faceData));
|
||||
|
//}
|
||||
|
#endregion
|
||||
|
//推送视频流
|
||||
|
WebSocketManager.WebSocket.PushImage(JsonConvert.SerializeObject(faceData)); |
||||
|
} |
||||
|
catch (Exception e) |
||||
|
{ |
||||
|
Log.MyLog.WriteLogFile("推送流文件异常:" + e.Message); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
#endregion
|
||||
|
#region 人脸检测
|
||||
|
//获取特征属性值
|
||||
|
var attrInfo = GetFaceInfoAttr(image, ComParameters.Parameters._maxDectNum); |
||||
|
//近期已离开人脸KeyList
|
||||
|
var hasLeaveList = _faceDic.Keys.ToList(); |
||||
|
if (attrInfo.Any())//当前帧检测出人脸
|
||||
|
{ |
||||
|
//百度Sdk特征值和属性值已排过序越优越前
|
||||
|
currentFace = attrInfo.First(); |
||||
|
//所有人脸结果
|
||||
|
foreach (var item in attrInfo) |
||||
|
{ |
||||
|
//新增进近期人脸字典
|
||||
|
if (!_faceDic.ContainsKey(item.index)) |
||||
|
{ |
||||
|
//加入近期人脸字典
|
||||
|
_faceDic.Add(item.index, item); |
||||
|
//加入人脸进入字典
|
||||
|
_faceEnterDic.Add(item.index, DateTime.Now); |
||||
|
//通知导视 人员进入
|
||||
|
WebSocketManager.WebSocket.PeopleEnter(); |
||||
|
} |
||||
|
else |
||||
|
{ |
||||
|
hasLeaveList.Remove(item.index); |
||||
|
} |
||||
|
//如果人员离开表有这个人 但这一帧这个人又出现了 则这个人的离开时间应该是暂定的
|
||||
|
if (_faceLeaveDic.ContainsKey(item.index) && _faceLeaveDic[item.index].HasValue) |
||||
|
{ |
||||
|
_faceLeaveDic[item.index] = null; |
||||
|
} |
||||
|
} |
||||
|
//首次进入toBeRemoveList 应该是空的不走此逻辑
|
||||
|
//前后帧检测到的人不一样时 走此逻辑
|
||||
|
foreach (var item in hasLeaveList) |
||||
|
{ |
||||
|
if (!_faceLeaveDic.ContainsKey(item)) |
||||
|
{ |
||||
|
_faceLeaveDic.Add(item, DateTime.Now); |
||||
|
} |
||||
|
else if (!_faceLeaveDic[item].HasValue) |
||||
|
{ |
||||
|
_faceLeaveDic[item] = DateTime.Now; |
||||
|
} |
||||
|
//当这个人离开了超过两秒
|
||||
|
else if (_faceLeaveDic[item].Value.AddSeconds(2) <= DateTime.Now) |
||||
|
{ |
||||
|
//上传这个人前后一共停留的时间和人脸特征数据
|
||||
|
AddUploadFace(_faceDic[item].age.ToString(), _faceDic[item].gender == BDFaceGender.BDFACE_GENDER_MALE ? "男" : "女", _faceEnterDic[item]); |
||||
|
//从人脸特征表中删除此人脸
|
||||
|
_faceDic.Remove(item); |
||||
|
//从人员进入表中删除此人脸
|
||||
|
_faceEnterDic.Remove(item); |
||||
|
//从人员离开表中删除此人脸
|
||||
|
_faceLeaveDic.Remove(item); |
||||
|
if (_masterFace.HasValue && _masterFace.Value.index == item) |
||||
|
{ |
||||
|
_masterFace = null; |
||||
|
//通知导视人员离开
|
||||
|
WebSocketManager.WebSocket.PeopleLeave(); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
//如果主人脸有值且近期人脸List中不含此主人脸
|
||||
|
if (_masterFace.HasValue && !_faceDic.ContainsKey(_masterFace.Value.index)) |
||||
|
{ |
||||
|
_masterFace = null; |
||||
|
//通知导视人员离开
|
||||
|
//还没做 得做
|
||||
|
} |
||||
|
//如果主人脸为空且这个人停留超过两秒 则会进入此逻辑
|
||||
|
if (!_masterFace.HasValue && currentFace.HasValue && _faceEnterDic[currentFace.Value.index].AddSeconds(2) <= DateTime.Now) |
||||
|
{ |
||||
|
_masterFace = currentFace; |
||||
|
//源代码调了SendHttpForKiosk 空方法
|
||||
|
|
||||
|
#region 人脸识别
|
||||
|
FaceContact(image, currentFace.Value); |
||||
|
#endregion
|
||||
|
} |
||||
|
} |
||||
|
else//未检测出人脸(所有人都离开了)
|
||||
|
{ |
||||
|
foreach (var item in hasLeaveList) |
||||
|
{ |
||||
|
//记录人员离开表
|
||||
|
if (!_faceLeaveDic.ContainsKey(item)) |
||||
|
{ |
||||
|
_faceLeaveDic.Add(item, DateTime.Now); |
||||
|
} |
||||
|
else if (!_faceLeaveDic[item].HasValue) |
||||
|
{ |
||||
|
_faceLeaveDic[item] = DateTime.Now; |
||||
|
} |
||||
|
else if (_faceLeaveDic[item].Value.AddSeconds(2) <= DateTime.Now) |
||||
|
{ |
||||
|
//上传这个人前后一共停留的时间和人脸特征数据
|
||||
|
AddUploadFace(_faceDic[item].age.ToString(), _faceDic[item].gender == BDFaceGender.BDFACE_GENDER_MALE ? "男" : "女", _faceEnterDic[item]); |
||||
|
//从人脸特征表中删除此人脸
|
||||
|
_faceDic.Remove(item); |
||||
|
//从人员进入表中删除此人脸
|
||||
|
_faceEnterDic.Remove(item); |
||||
|
//从人员离开表中删除此人脸
|
||||
|
_faceLeaveDic.Remove(item); |
||||
|
} |
||||
|
} |
||||
|
if (_masterFace.HasValue && !_faceDic.ContainsKey(_masterFace.Value.index)) |
||||
|
{ |
||||
|
_masterFace = null; |
||||
|
//通知导视人员离开
|
||||
|
WebSocketManager.WebSocket.PeopleLeave(); |
||||
|
} |
||||
|
} |
||||
|
#endregion
|
||||
|
#region 画框
|
||||
|
try |
||||
|
{ |
||||
|
//画人像框
|
||||
|
FaceDraw.draw_rects(ref image, attrInfo.Length, attrInfo); |
||||
|
//展示
|
||||
|
window.ShowImage(image); |
||||
|
Cv2.WaitKey(1); |
||||
|
} |
||||
|
catch (Exception suex) |
||||
|
{ |
||||
|
Log.MyLog.WriteLogFile("图像展示异常:" + suex.ToString(), "ToBitmapError"); |
||||
|
} |
||||
|
#endregion
|
||||
|
} |
||||
|
else |
||||
|
{ |
||||
|
//Console.WriteLine("mat is empty");
|
||||
|
} |
||||
|
} |
||||
|
catch (Exception ex) |
||||
|
{ |
||||
|
Log.MyLog.WriteLogFile("usb摄像头实时人脸检测示例异常:" + ex.ToString(), "USBVideoTract"); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
public void FaceContact(Mat mat, FaceDectData faceBox) |
||||
|
{ |
||||
|
if (_faceDic.ContainsKey(faceBox.index)) |
||||
|
{ |
||||
|
int x = Convert.ToInt32(faceBox.center_x - faceBox.width / 2.0); |
||||
|
int y = Convert.ToInt32(faceBox.center_y - faceBox.height / 2.0); |
||||
|
int w = Convert.ToInt32(faceBox.width); |
||||
|
int h = Convert.ToInt32(faceBox.height); |
||||
|
try |
||||
|
{ |
||||
|
using (var image = new Mat(mat, new Rect(new Point(x, y), new Size(w, h)))) |
||||
|
{ |
||||
|
var encodeBuff = image.ImEncode(".jpg"); |
||||
|
var base64Str = Convert.ToBase64String(encodeBuff); |
||||
|
var gender = faceBox.gender == BDFaceGender.BDFACE_GENDER_MALE ? 1 : 0; |
||||
|
var param = $"Face={base64Str}&ip={SystemManager.GetLocalIp()}&Age={faceBox.age}&GenderMale={gender}"; |
||||
|
if (!string.IsNullOrEmpty(ComParameters.Parameters._method)) |
||||
|
{ |
||||
|
param += $"&method={ComParameters.Parameters._method}"; |
||||
|
ComParameters.Parameters._method = null; |
||||
|
} |
||||
|
HttpComm.Http.UploadFace(param); |
||||
|
} |
||||
|
} |
||||
|
catch (Exception ex) |
||||
|
{ |
||||
|
Log.MyLog.WriteLogFile("上传人脸数据失败:" + ex.Message); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
public void UploadTheRestFace() |
||||
|
{ |
||||
|
foreach (var item in _faceDic) |
||||
|
{ |
||||
|
var stopTime = Convert.ToInt32((DateTime.Now - _faceEnterDic[item.Key]).TotalSeconds); |
||||
|
if(stopTime > 0) |
||||
|
{ |
||||
|
ComParameters.Parameters._faceToUploadList.Add(new FaceDataModel |
||||
|
{ |
||||
|
Age = item.Value.age.ToString(), |
||||
|
BeginTime = _faceEnterDic[item.Key], |
||||
|
EndTime = DateTime.Now, |
||||
|
GenderMale = item.Value.gender == BDFaceGender.BDFACE_GENDER_MALE ? "男" : "女", |
||||
|
StopTime = stopTime, |
||||
|
IP = ComParameters.Parameters._ipAddress, |
||||
|
}); |
||||
|
} |
||||
|
} |
||||
|
if (ComParameters.Parameters._faceToUploadList.Any()) |
||||
|
{ |
||||
|
HttpComm.Http.UploadFaceList(); |
||||
|
} |
||||
|
} |
||||
|
/// <summary>
|
||||
|
/// 增加人脸统计数据
|
||||
|
/// </summary>
|
||||
|
/// <param name="age"></param>
|
||||
|
/// <param name="gender">男/女</param>
|
||||
|
/// <param name="enterTime"></param>
|
||||
|
private void AddUploadFace(string age, string gender, DateTime enterTime) |
||||
|
{ |
||||
|
try |
||||
|
{ |
||||
|
var stopTime = Convert.ToInt32((DateTime.Now - enterTime).TotalSeconds); |
||||
|
if (stopTime > 1) |
||||
|
{ |
||||
|
ComParameters.Parameters._faceToUploadList.Add(new FaceDataModel |
||||
|
{ |
||||
|
Age = age, |
||||
|
BeginTime = enterTime, |
||||
|
EndTime = DateTime.Now, |
||||
|
GenderMale = gender, |
||||
|
StopTime = stopTime, |
||||
|
IP = ComParameters.Parameters._ipAddress, |
||||
|
}); |
||||
|
} |
||||
|
if (ComParameters.Parameters._faceToUploadList.Count >= 5) |
||||
|
{ |
||||
|
HttpComm.Http.UploadFaceList(); |
||||
|
} |
||||
|
} |
||||
|
catch (Exception ex) |
||||
|
{ |
||||
|
Log.MyLog.WriteLogFile("增加人脸统计数据异常:" + ex.Message); |
||||
|
} |
||||
|
} |
||||
|
#endregion
|
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,135 @@ |
|||||
|
using FaceDetect.Model; |
||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Configuration; |
||||
|
using System.Linq; |
||||
|
using System.Text; |
||||
|
using System.Threading.Tasks; |
||||
|
|
||||
|
namespace FaceDetect.Common |
||||
|
{ |
||||
|
public class ComParameters |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// 公共参数
|
||||
|
/// </summary>
|
||||
|
public static ComParameters Parameters |
||||
|
{ |
||||
|
get |
||||
|
{ |
||||
|
if (_par == null) |
||||
|
_par = new ComParameters(); |
||||
|
return _par; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
private static ComParameters _par; |
||||
|
#region 公共参数
|
||||
|
/// <summary>
|
||||
|
/// 默认电脑自带摄像头,device可能为0,若外接usb摄像头,则device可能为1。
|
||||
|
/// </summary>
|
||||
|
public int _cameraIndex; |
||||
|
/// <summary>
|
||||
|
/// 对比阈值,超过当前值才合格(compare 使用0-100)
|
||||
|
/// </summary>
|
||||
|
public int _threshold; |
||||
|
/// <summary>
|
||||
|
/// 对比阈值,超过当前值才合格(track和attr使用0-1)
|
||||
|
/// </summary>
|
||||
|
public double _miniThreshold; |
||||
|
/// <summary>
|
||||
|
/// 百度人脸Sdk最大检测数
|
||||
|
/// </summary>
|
||||
|
public int _maxDectNum; |
||||
|
/// <summary>
|
||||
|
/// 程序基目录
|
||||
|
/// </summary>
|
||||
|
public string _baseDir; |
||||
|
/// <summary>
|
||||
|
/// Http地址(大后台)
|
||||
|
/// </summary>
|
||||
|
public string _httpUrl; |
||||
|
/// <summary>
|
||||
|
/// Http地址(小后台)
|
||||
|
/// </summary>
|
||||
|
public string _kioskUrl; |
||||
|
/// <summary>
|
||||
|
/// 待上传的人脸统计数据
|
||||
|
/// </summary>
|
||||
|
public List<FaceDataModel> _faceToUploadList; |
||||
|
/// <summary>
|
||||
|
/// 本机ip
|
||||
|
/// </summary>
|
||||
|
public string _ipAddress; |
||||
|
///// <summary>
|
||||
|
///// AllWebsocket地址
|
||||
|
///// </summary>
|
||||
|
//public string _allWSServer;
|
||||
|
/// <summary>
|
||||
|
/// 人脸识别Websocket地址
|
||||
|
/// </summary>
|
||||
|
public string _faceWSServer; |
||||
|
/// <summary>
|
||||
|
/// 直播Websocket地址
|
||||
|
/// </summary>
|
||||
|
public string _liveWSServer; |
||||
|
/// <summary>
|
||||
|
/// 视频流是否开启
|
||||
|
/// </summary>
|
||||
|
public bool _isLive = false; |
||||
|
/// <summary>
|
||||
|
/// 视频流是否需要常开
|
||||
|
/// </summary>
|
||||
|
public bool _needAlive = false; |
||||
|
/// <summary>
|
||||
|
/// 是否需要传递视频流
|
||||
|
/// </summary>
|
||||
|
public bool _isOpenLive = false; |
||||
|
/// <summary>
|
||||
|
/// 视频流像素X位
|
||||
|
/// </summary>
|
||||
|
public int _liveX; |
||||
|
/// <summary>
|
||||
|
/// 视频流像素Y位
|
||||
|
/// </summary>
|
||||
|
public int _liveY; |
||||
|
/// <summary>
|
||||
|
/// 视频流宽度
|
||||
|
/// </summary>
|
||||
|
public int _liveWidth; |
||||
|
/// <summary>
|
||||
|
/// 视频流高度
|
||||
|
/// </summary>
|
||||
|
public int _liveHeight; |
||||
|
/// <summary>
|
||||
|
/// 当前人脸识别后请求小后台传递的方法参数
|
||||
|
/// </summary>
|
||||
|
public string _method; |
||||
|
#endregion
|
||||
|
|
||||
|
public ComParameters() |
||||
|
{ |
||||
|
#region 参数初始化
|
||||
|
_cameraIndex = Convert.ToInt32(ConfigurationManager.AppSettings["CameraIndex"]); |
||||
|
_threshold = Convert.ToInt32(ConfigurationManager.AppSettings["Threshold"]); |
||||
|
_maxDectNum = Convert.ToInt32(ConfigurationManager.AppSettings["MaxDectNum"]); |
||||
|
_httpUrl = ConfigurationManager.AppSettings["HttpUrl"]; |
||||
|
_kioskUrl = ConfigurationManager.AppSettings["KioskUrl"]; |
||||
|
//_allWSServer = ConfigurationManager.AppSettings["WebsocketForAll"];
|
||||
|
_faceWSServer = ConfigurationManager.AppSettings["WebsocketForFace"]; |
||||
|
_liveWSServer = ConfigurationManager.AppSettings["WebsocketForLive"]; |
||||
|
_needAlive = ConfigurationManager.AppSettings["NeedAlive"] == "1" ? true : false; |
||||
|
int.TryParse(ConfigurationManager.AppSettings["LiveX"], out _liveX); |
||||
|
int.TryParse(ConfigurationManager.AppSettings["LiveY"], out _liveY); |
||||
|
int.TryParse(ConfigurationManager.AppSettings["LiveWidth"], out _liveWidth); |
||||
|
int.TryParse(ConfigurationManager.AppSettings["LiveHeight"], out _liveHeight); |
||||
|
|
||||
|
_method = ""; |
||||
|
_miniThreshold = (double)_threshold / (double)100; |
||||
|
_baseDir = AppDomain.CurrentDomain.BaseDirectory; |
||||
|
_faceToUploadList = new List<FaceDataModel>(); |
||||
|
_ipAddress = SystemManager.GetLocalIp(); |
||||
|
#endregion
|
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,170 @@ |
|||||
|
using OpenCvSharp; |
||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Linq; |
||||
|
using System.Text; |
||||
|
using System.Threading.Tasks; |
||||
|
using static FaceDetect.Common.BaiduFaceSdk; |
||||
|
|
||||
|
namespace FaceDetect.Common |
||||
|
{ |
||||
|
// 绘制类,画人脸框,画关键点等
|
||||
|
class FaceDraw |
||||
|
{ |
||||
|
// 画人脸框
|
||||
|
public static int draw_rects(ref Mat img, int face_num, BDFaceBBox[] info) |
||||
|
{ |
||||
|
if (face_num <= 0) |
||||
|
{ |
||||
|
return 0; |
||||
|
} |
||||
|
Scalar color = new Scalar(0, 255, 0); |
||||
|
for (int i = 0; i < face_num; i++) |
||||
|
{ |
||||
|
int x = Convert.ToInt32(info[i].center_x - info[i].width / 2.0); |
||||
|
int y = Convert.ToInt32(info[i].center_y - info[i].height / 2.0); |
||||
|
int w = Convert.ToInt32(info[i].width); |
||||
|
int h = Convert.ToInt32(info[i].height); |
||||
|
Rect rect = new Rect(x, y, w, h); |
||||
|
Cv2.Rectangle(img, rect, color); |
||||
|
} |
||||
|
return 0; |
||||
|
} |
||||
|
// 画人脸框
|
||||
|
public static int draw_rects(ref Mat img, int face_num, FaceDectData[] info) |
||||
|
{ |
||||
|
if (face_num <= 0) |
||||
|
{ |
||||
|
return 0; |
||||
|
} |
||||
|
Scalar color = new Scalar(0, 255, 0); |
||||
|
for (int i = 0; i < face_num; i++) |
||||
|
{ |
||||
|
int x = Convert.ToInt32(info[i].center_x - info[i].width / 2.0); |
||||
|
int y = Convert.ToInt32(info[i].center_y - info[i].height / 2.0); |
||||
|
int w = Convert.ToInt32(info[i].width); |
||||
|
int h = Convert.ToInt32(info[i].height); |
||||
|
Rect rect = new Rect(x, y, w, h); |
||||
|
Cv2.Rectangle(img, rect, color); |
||||
|
} |
||||
|
return 0; |
||||
|
} |
||||
|
// 画人脸框
|
||||
|
public static int draw_rects(ref Mat img, int face_num, BDFaceTrackInfo[] track_info) |
||||
|
{ |
||||
|
if (face_num <= 0) |
||||
|
{ |
||||
|
return 0; |
||||
|
} |
||||
|
Scalar color = new Scalar(0, 255, 0); |
||||
|
for (int i = 0; i < face_num; i++) |
||||
|
{ |
||||
|
int x = Convert.ToInt32(track_info[i].box.center_x - track_info[i].box.width / 2.0); |
||||
|
int y = Convert.ToInt32(track_info[i].box.center_y - track_info[i].box.height / 2.0); |
||||
|
int w = Convert.ToInt32(track_info[i].box.width); |
||||
|
int h = Convert.ToInt32(track_info[i].box.height); |
||||
|
Rect rect = new Rect(x, y, w, h); |
||||
|
Cv2.Rectangle(img, rect, color); |
||||
|
} |
||||
|
return 0; |
||||
|
} |
||||
|
// 画人脸关键点
|
||||
|
public static int draw_shape(ref Mat img, int face_num, BDFaceTrackInfo[] track_info) |
||||
|
{ |
||||
|
if (face_num <= 0) |
||||
|
{ |
||||
|
return 0; |
||||
|
} |
||||
|
int face_id = 0; |
||||
|
Scalar color = new Scalar(0, 255, 255); |
||||
|
Scalar color2 = new Scalar(0, 0, 255); |
||||
|
for (int i = 0; i < face_num; ++i) |
||||
|
{ |
||||
|
int point_size = track_info[i].landmark.size / 2; |
||||
|
int radius = 2; |
||||
|
face_id = track_info[i].face_id; |
||||
|
for (int j = 0; j < point_size; ++j) |
||||
|
{ |
||||
|
Cv2.Circle(img, (int)track_info[i].landmark.data[j * 2], (int)track_info[i].landmark.data[j * 2 + 1], radius, color); |
||||
|
} |
||||
|
if (point_size == 72) |
||||
|
{ |
||||
|
const int components = 9; |
||||
|
int[] comp1 = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 }; |
||||
|
int[] comp2 = { 13, 14, 15, 16, 17, 18, 19, 20, 13, 21 }; |
||||
|
int[] comp3 = { 22, 23, 24, 25, 26, 27, 28, 29, 22 }; |
||||
|
int[] comp4 = { 30, 31, 32, 33, 34, 35, 36, 37, 30, 38 }; |
||||
|
int[] comp5 = { 39, 40, 41, 42, 43, 44, 45, 46, 39 }; |
||||
|
int[] comp6 = { 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 47 }; |
||||
|
int[] comp7 = { 51, 57, 52 }; |
||||
|
int[] comp8 = { 58, 59, 60, 61, 62, 63, 64, 65, 58 }; |
||||
|
int[] comp9 = { 58, 66, 67, 68, 62, 69, 70, 71, 58 }; |
||||
|
int[][] idx = { comp1, comp2, comp3, comp4, comp5, comp6, comp7, comp8, comp9 }; |
||||
|
int[] npoints = { 13, 10, 9, 10, 9, 11, 3, 9, 9 }; |
||||
|
|
||||
|
for (int m = 0; m < components; ++m) |
||||
|
{ |
||||
|
for (int n = 0; n < npoints[m] - 1; ++n) |
||||
|
{ |
||||
|
Point p1 = new Point(track_info[i].landmark.data[idx[m][n] * 2], track_info[i].landmark.data[idx[m][n] * 2 + 1]); |
||||
|
Point p2 = new Point(track_info[i].landmark.data[idx[m][n + 1] * 2], track_info[i].landmark.data[idx[m][n + 1] * 2 + 1]); |
||||
|
Cv2.Line(img, p1, p2, color2); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
string s_face_id = face_id.ToString(); |
||||
|
double font_scale = 2; |
||||
|
Point pos = new Point(track_info[i].box.center_x, track_info[i].box.center_y); |
||||
|
Cv2.PutText(img, s_face_id, pos, HersheyFonts.HersheyComplex, font_scale, new Scalar(0, 255, 255)); |
||||
|
} |
||||
|
|
||||
|
return 0; |
||||
|
} |
||||
|
|
||||
|
// 画人脸关键点
|
||||
|
public static int draw_landmark(ref Mat img, int face_num, BDFaceLandmark[] landmark) |
||||
|
{ |
||||
|
if (face_num <= 0) |
||||
|
{ |
||||
|
return 0; |
||||
|
} |
||||
|
Scalar color = new Scalar(0, 255, 255); |
||||
|
Scalar color2 = new Scalar(0, 0, 255); |
||||
|
for (int i = 0; i < face_num; ++i) |
||||
|
{ |
||||
|
int point_size = landmark[i].size / 2; |
||||
|
int radius = 2; |
||||
|
for (int j = 0; j < point_size; ++j) |
||||
|
{ |
||||
|
Cv2.Circle(img, (int)landmark[i].data[j * 2], (int)landmark[i].data[j * 2 + 1], radius, color); |
||||
|
} |
||||
|
if (point_size == 72) |
||||
|
{ |
||||
|
const int components = 9; |
||||
|
int[] comp1 = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 }; |
||||
|
int[] comp2 = { 13, 14, 15, 16, 17, 18, 19, 20, 13, 21 }; |
||||
|
int[] comp3 = { 22, 23, 24, 25, 26, 27, 28, 29, 22 }; |
||||
|
int[] comp4 = { 30, 31, 32, 33, 34, 35, 36, 37, 30, 38 }; |
||||
|
int[] comp5 = { 39, 40, 41, 42, 43, 44, 45, 46, 39 }; |
||||
|
int[] comp6 = { 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 47 }; |
||||
|
int[] comp7 = { 51, 57, 52 }; |
||||
|
int[] comp8 = { 58, 59, 60, 61, 62, 63, 64, 65, 58 }; |
||||
|
int[] comp9 = { 58, 66, 67, 68, 62, 69, 70, 71, 58 }; |
||||
|
int[][] idx = { comp1, comp2, comp3, comp4, comp5, comp6, comp7, comp8, comp9 }; |
||||
|
int[] npoints = { 13, 10, 9, 10, 9, 11, 3, 9, 9 }; |
||||
|
|
||||
|
for (int m = 0; m < components; ++m) |
||||
|
{ |
||||
|
for (int n = 0; n < npoints[m] - 1; ++n) |
||||
|
{ |
||||
|
Point p1 = new Point(landmark[i].data[idx[m][n] * 2], landmark[i].data[idx[m][n] * 2 + 1]); |
||||
|
Point p2 = new Point(landmark[i].data[idx[m][n + 1] * 2], landmark[i].data[idx[m][n + 1] * 2 + 1]); |
||||
|
Cv2.Line(img, p1, p2, color2); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
return 0; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,42 @@ |
|||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.IO; |
||||
|
using System.Linq; |
||||
|
using System.Text; |
||||
|
using System.Threading.Tasks; |
||||
|
|
||||
|
namespace FaceDetect.Common |
||||
|
{ |
||||
|
public class FileManage |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// 写Json文件
|
||||
|
/// </summary>
|
||||
|
/// <param name="path"></param>
|
||||
|
/// <param name="jsonContents"></param>
|
||||
|
public static void WriteJsonFile(string path, string jsonContents) |
||||
|
{ |
||||
|
File.WriteAllText(path, jsonContents, System.Text.Encoding.UTF8); |
||||
|
} |
||||
|
/// <summary>
|
||||
|
/// 读Json文件
|
||||
|
/// </summary>
|
||||
|
/// <param name="path"></param>
|
||||
|
/// <returns></returns>
|
||||
|
public static string ReadJsonFile(string path) |
||||
|
{ |
||||
|
var json = string.Empty; |
||||
|
if (File.Exists(path)) |
||||
|
{ |
||||
|
using (FileStream fs = new FileStream(path, FileMode.OpenOrCreate, System.IO.FileAccess.Read, FileShare.ReadWrite)) |
||||
|
{ |
||||
|
using (StreamReader sr = new StreamReader(fs, Encoding.UTF8)) |
||||
|
{ |
||||
|
json = sr.ReadToEnd(); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
return json; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,382 @@ |
|||||
|
using FaceDetect.Model; |
||||
|
using Newtonsoft.Json; |
||||
|
using Newtonsoft.Json.Linq; |
||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.IO; |
||||
|
using System.Linq; |
||||
|
using System.Net; |
||||
|
using System.Text; |
||||
|
using System.Threading.Tasks; |
||||
|
|
||||
|
namespace FaceDetect.Common |
||||
|
{ |
||||
|
public class HttpComm |
||||
|
{ |
||||
|
public static HttpComm Http |
||||
|
{ |
||||
|
get |
||||
|
{ |
||||
|
if (_http == null) |
||||
|
_http = new HttpComm(); |
||||
|
return _http; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
private static HttpComm _http; |
||||
|
private string _httpUrl; |
||||
|
private HttpComm() |
||||
|
{ |
||||
|
_httpUrl = ComParameters.Parameters._httpUrl; |
||||
|
} |
||||
|
#region 基本代码
|
||||
|
public string Get(string Url, string cookies = null) |
||||
|
{ |
||||
|
try |
||||
|
{ |
||||
|
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(Url); |
||||
|
request.Method = "GET"; |
||||
|
if (cookies != null) |
||||
|
request.Headers.Add("Cookie", cookies); |
||||
|
request.ContentType = "application/x-www-form-urlencoded"; |
||||
|
HttpWebResponse response = (HttpWebResponse)request.GetResponse(); |
||||
|
string encoding = response.ContentEncoding; |
||||
|
if (encoding == null || encoding.Length < 1) |
||||
|
{ |
||||
|
encoding = "UTF-8"; //默认编码
|
||||
|
} |
||||
|
StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.GetEncoding(encoding)); |
||||
|
string retString = reader.ReadToEnd(); |
||||
|
return retString; |
||||
|
} |
||||
|
catch (Exception ex) |
||||
|
{ |
||||
|
Log.MyLog.WriteLogFile(ex.ToString()); |
||||
|
return "Error"; |
||||
|
} |
||||
|
} |
||||
|
private void init_Request(ref HttpWebRequest request) |
||||
|
{ |
||||
|
request.Accept = "text/json,*/*;q=0.5"; |
||||
|
request.Headers.Add("Accept-Charset", "utf-8;q=0.7,*;q=0.7"); |
||||
|
request.Headers.Add("Accept-Encoding", "gzip, deflate, x-gzip, identity; q=0.9"); |
||||
|
request.AutomaticDecompression = DecompressionMethods.GZip; |
||||
|
request.Timeout = 60000; |
||||
|
} |
||||
|
|
||||
|
public string Post(string url, string data, string contentType = "application/x-www-form-urlencoded; charset=utf-8", Dictionary<string, string> headers = null) |
||||
|
{ |
||||
|
try |
||||
|
{ |
||||
|
var request = (HttpWebRequest)WebRequest.Create(url); |
||||
|
{ |
||||
|
string retval; |
||||
|
init_Request(ref request); |
||||
|
request.Method = "POST"; |
||||
|
request.ContentType = contentType; |
||||
|
if (headers != null && headers.Count > 0) |
||||
|
{ |
||||
|
foreach (var h in headers) |
||||
|
{ |
||||
|
request.Headers.Add(h.Key, h.Value); |
||||
|
} |
||||
|
} |
||||
|
var bytes = System.Text.Encoding.UTF8.GetBytes(data); |
||||
|
request.ContentLength = bytes.Length; |
||||
|
using (var stream = request.GetRequestStream()) |
||||
|
{ |
||||
|
stream.Write(bytes, 0, bytes.Length); |
||||
|
} |
||||
|
using (var response = request.GetResponse()) |
||||
|
{ |
||||
|
using (var reader = new System.IO.StreamReader(response.GetResponseStream() ?? throw new InvalidOperationException())) |
||||
|
{ |
||||
|
retval = reader.ReadToEnd(); |
||||
|
} |
||||
|
} |
||||
|
return retval; |
||||
|
} |
||||
|
} |
||||
|
catch (Exception ex) |
||||
|
{ |
||||
|
Log.MyLog.WriteLogFile(ex.ToString()); |
||||
|
return "Error"; |
||||
|
} |
||||
|
} |
||||
|
/// <summary>
|
||||
|
/// 下载文件
|
||||
|
/// </summary>
|
||||
|
/// <param name="fileUrl">下载地址</param>
|
||||
|
/// <param name="localFileName">本地文件名</param>
|
||||
|
/// <param name="folderPath">文件夹完整路径</param>
|
||||
|
/// <param name="cover">是否覆盖同名文件</param>
|
||||
|
/// <returns></returns>
|
||||
|
private string DownLoadFile(string fileUrl, string localFileName, string folderPath, bool cover = false) |
||||
|
{ |
||||
|
var filePath = ""; |
||||
|
try |
||||
|
{ |
||||
|
if (!Directory.Exists(folderPath)) |
||||
|
{ |
||||
|
Directory.CreateDirectory(folderPath); |
||||
|
} |
||||
|
if (File.Exists(folderPath + "/" + localFileName)) |
||||
|
{ |
||||
|
if (!cover) |
||||
|
{ |
||||
|
return filePath; |
||||
|
} |
||||
|
else |
||||
|
{ |
||||
|
File.Delete(folderPath + "/" + localFileName); |
||||
|
} |
||||
|
} |
||||
|
if (File.Exists(folderPath + "/" + localFileName + ".temp")) |
||||
|
{ |
||||
|
File.Delete(folderPath + "/" + localFileName + ".temp"); |
||||
|
} |
||||
|
using (Stream fileStream = new FileStream(folderPath + "/" + localFileName + ".temp", FileMode.OpenOrCreate)) |
||||
|
{ |
||||
|
try |
||||
|
{ |
||||
|
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(fileUrl); |
||||
|
request.AddRange(fileStream.Length); |
||||
|
|
||||
|
HttpWebResponse respone = (HttpWebResponse)request.GetResponse(); |
||||
|
using (Stream netStream = respone.GetResponseStream()) |
||||
|
{ |
||||
|
long totalDownloadedByte = 0; |
||||
|
byte[] read = new byte[1024]; |
||||
|
int realReadLen = netStream.Read(read, 0, read.Length); |
||||
|
while (realReadLen > 0) |
||||
|
{ |
||||
|
totalDownloadedByte = realReadLen + totalDownloadedByte; |
||||
|
|
||||
|
fileStream.Write(read, 0, realReadLen); |
||||
|
realReadLen = netStream.Read(read, 0, read.Length); |
||||
|
|
||||
|
//System.Windows.Forms.Application.DoEvents();
|
||||
|
} |
||||
|
netStream.Close(); |
||||
|
} |
||||
|
if (fileStream.Length != respone.ContentLength) |
||||
|
{ |
||||
|
Log.MyLog.WriteLogFile("文件未下载完毕"); |
||||
|
} |
||||
|
fileStream.Close(); |
||||
|
Log.MyLog.WriteLogFile("下载完成" + folderPath + "/" + localFileName, "FileDownload"); |
||||
|
File.Move(folderPath + "/" + localFileName + ".temp", folderPath + "/" + localFileName); |
||||
|
filePath = folderPath + "/" + localFileName; |
||||
|
|
||||
|
|
||||
|
//var fileHash = GetMD5HashFromFile(folderPath + "/" + localFileName);
|
||||
|
//if (fileHash != hash)
|
||||
|
//{
|
||||
|
// log.WriteLogFile("localFile " + fileHash + " getHash:" + hash, "exelog");
|
||||
|
// File.Delete(folderPath + "/" + localFileName);
|
||||
|
// log.WriteLogFile("FileHash对比不一致,须删除重新下载" + folderPath + "/" + localFileName, "exelog");
|
||||
|
// return false;
|
||||
|
//}
|
||||
|
|
||||
|
} |
||||
|
catch (Exception ex) |
||||
|
{ |
||||
|
fileStream.Close(); |
||||
|
Log.MyLog.WriteLogFile("下载失败" + folderPath + "/" + localFileName + ex.ToString()); |
||||
|
File.Delete(folderPath + "/" + localFileName + ".temp"); |
||||
|
return filePath; |
||||
|
} |
||||
|
} |
||||
|
return filePath; |
||||
|
} |
||||
|
catch (Exception e) |
||||
|
{ |
||||
|
Log.MyLog.WriteLogFile(e.ToString()); |
||||
|
return filePath; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 表单上传
|
||||
|
/// </summary>
|
||||
|
/// <param name="url"></param>
|
||||
|
/// <param name="path"></param>
|
||||
|
/// <returns></returns>
|
||||
|
public string UploadFile(string url, string filePath, Dictionary<string, string> formDatas, string contentType = "multipart/form-data;") |
||||
|
{ |
||||
|
var returnValue = ""; |
||||
|
// 时间戳,用做boundary
|
||||
|
string timeStamp = DateTime.Now.Ticks.ToString("x"); |
||||
|
|
||||
|
//根据uri创建HttpWebRequest对象
|
||||
|
HttpWebRequest httpReq = (HttpWebRequest)WebRequest.Create(new Uri(url)); |
||||
|
httpReq.Method = "POST"; |
||||
|
httpReq.AllowWriteStreamBuffering = false; //对发送的数据不使用缓存
|
||||
|
httpReq.Timeout = 300000; //设置获得响应的超时时间(300秒)
|
||||
|
httpReq.ContentType = "multipart/form-data; boundary=" + timeStamp; |
||||
|
|
||||
|
//读取file文件
|
||||
|
FileStream fileStream = new FileStream(filePath, FileMode.Open, FileAccess.Read); |
||||
|
BinaryReader binaryReader = new BinaryReader(fileStream); |
||||
|
|
||||
|
//表单信息
|
||||
|
string boundary = "--" + timeStamp; |
||||
|
string form = ""; |
||||
|
string formFormat = boundary + "\r\nContent-Disposition: form-data; name=\"{0}\"\r\n\r\n{1}\r\n"; |
||||
|
string formEnd = boundary + "\r\nContent-Disposition: form-data; name=\"{0}\"; filename=\"{1}\";\r\nContent-Type:application/octet-stream\r\n\r\n"; |
||||
|
foreach (var pair in formDatas) |
||||
|
{ |
||||
|
form += string.Format(formFormat, pair.Key, pair.Value); |
||||
|
} |
||||
|
form += string.Format(formEnd, "file", Path.GetFileName(filePath)); |
||||
|
byte[] postHeaderBytes = Encoding.UTF8.GetBytes(form); |
||||
|
|
||||
|
//结束边界
|
||||
|
byte[] boundaryBytes = Encoding.ASCII.GetBytes("\r\n--" + timeStamp + "--\r\n"); |
||||
|
long length = fileStream.Length + postHeaderBytes.Length + boundaryBytes.Length; |
||||
|
httpReq.ContentLength = length; //请求内容长度
|
||||
|
|
||||
|
try |
||||
|
{ |
||||
|
//每次上传4k
|
||||
|
int bufferLength = 4096; |
||||
|
byte[] buffer = new byte[bufferLength]; |
||||
|
|
||||
|
//已上传的字节数
|
||||
|
long offset = 0; |
||||
|
int size = binaryReader.Read(buffer, 0, bufferLength); |
||||
|
Stream postStream = httpReq.GetRequestStream(); |
||||
|
|
||||
|
//发送请求头部消息
|
||||
|
postStream.Write(postHeaderBytes, 0, postHeaderBytes.Length); |
||||
|
|
||||
|
while (size > 0) |
||||
|
{ |
||||
|
postStream.Write(buffer, 0, size); |
||||
|
offset += size; |
||||
|
size = binaryReader.Read(buffer, 0, bufferLength); |
||||
|
} |
||||
|
|
||||
|
//添加尾部边界
|
||||
|
postStream.Write(boundaryBytes, 0, boundaryBytes.Length); |
||||
|
postStream.Close(); |
||||
|
|
||||
|
//获取服务器端的响应
|
||||
|
using (HttpWebResponse response = (HttpWebResponse)httpReq.GetResponse()) |
||||
|
{ |
||||
|
Stream receiveStream = response.GetResponseStream(); |
||||
|
StreamReader readStream = new StreamReader(receiveStream, Encoding.UTF8); |
||||
|
returnValue = readStream.ReadToEnd(); |
||||
|
response.Close(); |
||||
|
readStream.Close(); |
||||
|
} |
||||
|
} |
||||
|
catch (Exception ex) |
||||
|
{ |
||||
|
Log.MyLog.WriteLogFile("文件传输异常: " + ex.ToString()); |
||||
|
} |
||||
|
finally |
||||
|
{ |
||||
|
fileStream.Close(); |
||||
|
binaryReader.Close(); |
||||
|
} |
||||
|
return returnValue; |
||||
|
} |
||||
|
#endregion
|
||||
|
#region api
|
||||
|
#region 小后台 KioskUrl
|
||||
|
|
||||
|
#endregion
|
||||
|
#region 大后台 Http
|
||||
|
|
||||
|
#endregion
|
||||
|
/// <summary>
|
||||
|
/// 上传人脸统计数据
|
||||
|
/// </summary>
|
||||
|
public void UploadFaceList() |
||||
|
{ |
||||
|
try |
||||
|
{ |
||||
|
var param = JsonConvert.SerializeObject(ComParameters.Parameters._faceToUploadList); |
||||
|
var url = _httpUrl + "/api/Face/UploadFace"; |
||||
|
var res = Post(url, param, "application/json;charset=UTF-8"); |
||||
|
if (!string.IsNullOrEmpty(res) && res.Contains("\"code\"")) |
||||
|
{ |
||||
|
var jo = JObject.Parse(res); |
||||
|
var code = jo.Value<string>("code"); |
||||
|
if (code == "200") |
||||
|
{ |
||||
|
ComParameters.Parameters._faceToUploadList.Clear(); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
catch (Exception ex) |
||||
|
{ |
||||
|
Log.MyLog.WriteLogFile("上传人脸统计数据List异常:" + ex.Message, "HttpError"); |
||||
|
} |
||||
|
} |
||||
|
/// <summary>
|
||||
|
/// 上传图片
|
||||
|
/// </summary>
|
||||
|
/// <param name="param"></param>
|
||||
|
public void UploadFace(string param) |
||||
|
{ |
||||
|
try |
||||
|
{ |
||||
|
var url = ComParameters.Parameters._kioskUrl + "/api/Face/UpLoadFace"; |
||||
|
var res = Post(url, param); |
||||
|
if (!string.IsNullOrEmpty(res) && res.Contains("\"code\"")) |
||||
|
{ |
||||
|
var jo = JObject.Parse(res); |
||||
|
var code = jo.Value<string>("code"); |
||||
|
if (code == "200") |
||||
|
{ |
||||
|
var data = jo.Value<JObject>("data"); |
||||
|
if (data.HasValues) |
||||
|
{ |
||||
|
WebSocketManager.WebSocket.PushFaceData(data.ToString(Newtonsoft.Json.Formatting.None)); |
||||
|
} |
||||
|
if (param.Contains("&method=")) |
||||
|
{ |
||||
|
ComParameters.Parameters._isOpenLive = false; |
||||
|
WebSocketManager.WebSocket.PushCloseLive(); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
catch (Exception ex) |
||||
|
{ |
||||
|
Log.MyLog.WriteLogFile("上传图片异常:" + ex.Message, "HttpError"); |
||||
|
} |
||||
|
} |
||||
|
///// <summary>
|
||||
|
///// 上传图片
|
||||
|
///// </summary>
|
||||
|
//public Dictionary<string, Object> UploadImage(string param)
|
||||
|
//{
|
||||
|
// try
|
||||
|
// {
|
||||
|
// var url = ComParameters.Parameters._kioskUrl + "/Api/MemberCenter/FaceSearch";
|
||||
|
// var res = Post(url, param, "application/json;charset=UTF-8");
|
||||
|
// if (!string.IsNullOrEmpty(res) && res.Contains("\"code\""))
|
||||
|
// {
|
||||
|
// var jo = JObject.Parse(res);
|
||||
|
// var code = jo.Value<string>("code");
|
||||
|
// if (code == "200")
|
||||
|
// {
|
||||
|
// var data = jo.Value<JObject>("data");
|
||||
|
// var result = data.ToObject<Dictionary<string, Object>>();
|
||||
|
// return result;
|
||||
|
// }
|
||||
|
// }
|
||||
|
// return null;
|
||||
|
// }
|
||||
|
// catch (Exception ex)
|
||||
|
// {
|
||||
|
// Log.MyLog.WriteLogFile("上传人脸统计数据List异常:" + ex.Message, "HttpError");
|
||||
|
// return null;
|
||||
|
// }
|
||||
|
//}
|
||||
|
#endregion
|
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,184 @@ |
|||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.IO; |
||||
|
using System.Linq; |
||||
|
using System.Text; |
||||
|
using System.Threading.Tasks; |
||||
|
|
||||
|
namespace FaceDetect.Common |
||||
|
{ |
||||
|
public class Log |
||||
|
{ |
||||
|
public static Log MyLog |
||||
|
{ |
||||
|
get |
||||
|
{ |
||||
|
if (_log == null) |
||||
|
_log = new Log(); |
||||
|
return _log; |
||||
|
} |
||||
|
} |
||||
|
private static Log _log = new Log(); |
||||
|
|
||||
|
private Log() { } |
||||
|
/**/ |
||||
|
/// <summary>
|
||||
|
/// 写入日志文件
|
||||
|
/// </summary>
|
||||
|
/// <param name="input"></param>
|
||||
|
public void WriteLogFile(string input, string strfileName = "AppError") |
||||
|
{ |
||||
|
try |
||||
|
{ |
||||
|
/**/ |
||||
|
///指定日志文件的目录
|
||||
|
strfileName = strfileName + DateTime.Now.ToString("yyyy-MM-dd"); |
||||
|
string fpath = System.AppDomain.CurrentDomain.BaseDirectory + "\\log\\" + DateTime.Now.ToString("yyyy-MM-dd") + "\\"; |
||||
|
if (!Directory.Exists(fpath)) |
||||
|
{ |
||||
|
DirectoryInfo directoryInfo = new DirectoryInfo(fpath); |
||||
|
directoryInfo.Create(); |
||||
|
} |
||||
|
|
||||
|
string fname = System.AppDomain.CurrentDomain.BaseDirectory + "\\log\\" + DateTime.Now.ToString("yyyy-MM-dd") + "\\" + strfileName + ".txt"; |
||||
|
|
||||
|
/**/ |
||||
|
///定义文件信息对象
|
||||
|
///
|
||||
|
FileInfo finfo = new FileInfo(fname); |
||||
|
if (!finfo.Exists) |
||||
|
{ |
||||
|
FileStream fs = new FileStream(fname, FileMode.Create, FileAccess.Write); |
||||
|
//fs = File.Create(fname);
|
||||
|
fs.Close(); |
||||
|
finfo = new FileInfo(fname); |
||||
|
} |
||||
|
/**/ |
||||
|
///判断文件是否存在以及是否大于2K
|
||||
|
if (finfo.Length > 1024 * 1024 * 10) |
||||
|
{ |
||||
|
/**/ |
||||
|
///文件超过10MB则重命名
|
||||
|
File.Move(System.AppDomain.CurrentDomain.BaseDirectory + "\\LogFile.txt", System.AppDomain.CurrentDomain.BaseDirectory + DateTime.Now.TimeOfDay + "\\LogFile.txt"); |
||||
|
/**/ |
||||
|
///删除该文件
|
||||
|
//finfo.Delete();
|
||||
|
} |
||||
|
//finfo.AppendText();
|
||||
|
/**/ |
||||
|
///创建只写文件流
|
||||
|
|
||||
|
using (FileStream fs = finfo.OpenWrite()) |
||||
|
{ |
||||
|
/**/ |
||||
|
///根据上面创建的文件流创建写数据流
|
||||
|
StreamWriter w = new StreamWriter(fs); |
||||
|
|
||||
|
/**/ |
||||
|
///设置写数据流的起始位置为文件流的末尾
|
||||
|
w.BaseStream.Seek(0, SeekOrigin.End); |
||||
|
/**/ |
||||
|
///写入“Log Entry : ”
|
||||
|
w.Write("\n\rLog Entry : "); |
||||
|
/**/ |
||||
|
///写入当前系统时间并换行
|
||||
|
w.Write("{0} {1} \n\r", DateTime.Now.ToLongTimeString(), |
||||
|
DateTime.Now.ToLongDateString()); |
||||
|
/**/ |
||||
|
///写入日志内容并换行
|
||||
|
w.Write(input + "\n\r"); |
||||
|
/**/ |
||||
|
///写入------------------------------------“并换行
|
||||
|
w.Write("------------------------------------\n\r"); |
||||
|
/**/ |
||||
|
///清空缓冲区内容,并把缓冲区内容写入基础流
|
||||
|
w.Flush(); |
||||
|
/**/ |
||||
|
///关闭写数据流
|
||||
|
w.Close(); |
||||
|
} |
||||
|
} |
||||
|
catch { } |
||||
|
|
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 删除 month 个月之前的 strFileName日志
|
||||
|
/// </summary>
|
||||
|
/// <param name="strFileName"></param>
|
||||
|
/// <param name="month"></param>
|
||||
|
public static void DeleteLogFile(string strFileName = "AppError", int month = 1) |
||||
|
{ |
||||
|
try |
||||
|
{ |
||||
|
string logPath = System.AppDomain.CurrentDomain.BaseDirectory + "\\log\\" + strFileName; |
||||
|
if (!Directory.Exists(logPath))//若文件夹不存在则返回
|
||||
|
return; |
||||
|
else |
||||
|
logPath += "\\"; |
||||
|
DirectoryInfo theFolder = new DirectoryInfo(@logPath); |
||||
|
FileInfo[] fileInfo = theFolder.GetFiles(); |
||||
|
foreach (FileInfo NextFile in fileInfo) //遍历文件
|
||||
|
{ |
||||
|
DateTime dt1 = Convert.ToDateTime(NextFile.Name.Substring(strFileName.Length, NextFile.Name.Length - strFileName.Length - 4) + " 00:00:00"); |
||||
|
DateTime dt2 = DateTime.Now.AddMonths(-month); |
||||
|
if (dt1 < dt2) |
||||
|
{ |
||||
|
NextFile.Delete(); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
catch |
||||
|
{ |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
public void DeleteFiles(string fileName = "") |
||||
|
{ |
||||
|
try |
||||
|
{ |
||||
|
if (string.IsNullOrEmpty(fileName)) |
||||
|
fileName = System.AppDomain.CurrentDomain.BaseDirectory + "\\log"; |
||||
|
if (!Directory.Exists(fileName))//若文件夹不存在则返回
|
||||
|
return; |
||||
|
DirectoryInfo dir = new DirectoryInfo(fileName);//new DirectoryInfo(System.AppDomain.CurrentDomain.BaseDirectory + "\\log");
|
||||
|
//不是目录
|
||||
|
|
||||
|
if (dir == null) |
||||
|
return; |
||||
|
//DateTime DT = dir.CreationTime;
|
||||
|
|
||||
|
FileSystemInfo[] files = dir.GetFileSystemInfos(); |
||||
|
for (int i = 0; i < files.Length; i++) |
||||
|
{ |
||||
|
FileInfo file = files[i] as FileInfo; |
||||
|
//是文件
|
||||
|
if (file != null) |
||||
|
{ |
||||
|
DateTime DT = file.CreationTime; |
||||
|
if (DateTime.Now.Month - DT.Month >= 1) |
||||
|
{ |
||||
|
file.Delete(); |
||||
|
} |
||||
|
} |
||||
|
else |
||||
|
{ |
||||
|
DirectoryInfo dir1 = files[i] as DirectoryInfo; |
||||
|
if (dir1 != null) |
||||
|
{ |
||||
|
DateTime DT = dir1.CreationTime; |
||||
|
if (DateTime.Now.Month - DT.Month >= 1) |
||||
|
{ |
||||
|
//dir1.Delete();
|
||||
|
System.IO.Directory.Delete(fileName + "\\" + dir1.Name, true); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
catch |
||||
|
{ |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,28 @@ |
|||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Linq; |
||||
|
using System.Net; |
||||
|
using System.Text; |
||||
|
using System.Threading.Tasks; |
||||
|
|
||||
|
namespace FaceDetect.Common |
||||
|
{ |
||||
|
public class SystemManager |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// 获取本地Ip
|
||||
|
/// </summary>
|
||||
|
/// <returns></returns>
|
||||
|
public static string GetLocalIp() |
||||
|
{ |
||||
|
foreach (IPAddress _IPAddress in Dns.GetHostEntry(Dns.GetHostName()).AddressList) |
||||
|
{ |
||||
|
if (_IPAddress.AddressFamily.ToString() == "InterNetwork") |
||||
|
{ |
||||
|
return _IPAddress.ToString(); |
||||
|
} |
||||
|
} |
||||
|
return string.Empty; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,222 @@ |
|||||
|
using Fleck; |
||||
|
using Newtonsoft.Json; |
||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Linq; |
||||
|
using System.Text; |
||||
|
using System.Threading.Tasks; |
||||
|
|
||||
|
namespace FaceDetect.Common |
||||
|
{ |
||||
|
public class WebSocketManager |
||||
|
{ |
||||
|
public static WebSocketManager WebSocket |
||||
|
{ |
||||
|
get |
||||
|
{ |
||||
|
if (_websocket == null) |
||||
|
_websocket = new WebSocketManager(); |
||||
|
return _websocket; |
||||
|
} |
||||
|
} |
||||
|
private static WebSocketManager _websocket; |
||||
|
//public static List<IWebSocketConnection> allSockets = new List<IWebSocketConnection>();
|
||||
|
public static List<IWebSocketConnection> liveSockets = new List<IWebSocketConnection>(); |
||||
|
public static List<IWebSocketConnection> faceSockets = new List<IWebSocketConnection>(); |
||||
|
public static string noFaceModel = "{" + "\"faceID\" : \"\", \"isValid\" :false, \"beautyScore\" : 0, \"faceImage\": \"\", \"genderMale\" : \"\"" + "}"; |
||||
|
|
||||
|
#region AllWebSocket
|
||||
|
///// <summary>
|
||||
|
///// 打开AllWebSocket
|
||||
|
///// </summary>
|
||||
|
//public void OpenSocketForAll()
|
||||
|
//{
|
||||
|
// try
|
||||
|
// {
|
||||
|
// var server = new WebSocketServer(ComParameters.Parameters._allWSServer);
|
||||
|
// server.Start(socket =>
|
||||
|
// {
|
||||
|
// socket.OnOpen = () => //当建立Socket链接时执行此方法
|
||||
|
// {
|
||||
|
// allSockets.Add(socket);
|
||||
|
// };
|
||||
|
|
||||
|
// socket.OnClose = () =>// 当关闭Socket链接十执行此方法
|
||||
|
// {
|
||||
|
// allSockets.Remove(socket);
|
||||
|
// };
|
||||
|
|
||||
|
// socket.OnMessage = message =>// 接收客户端发送过来的信息
|
||||
|
// {
|
||||
|
// switch (message)
|
||||
|
// {
|
||||
|
// case "face":
|
||||
|
// {
|
||||
|
// break;
|
||||
|
// }
|
||||
|
// case "":
|
||||
|
// {
|
||||
|
// break;
|
||||
|
// }
|
||||
|
// }
|
||||
|
// };
|
||||
|
// });
|
||||
|
// }
|
||||
|
// catch (Exception ex)
|
||||
|
// {
|
||||
|
// Log.MyLog.WriteLogFile("人脸Websocket开启异常:" + ex.Message, "FaceWebSocketError");
|
||||
|
// }
|
||||
|
|
||||
|
//}
|
||||
|
|
||||
|
//public void PushFaceData(string content)
|
||||
|
//{
|
||||
|
// allSockets.ForEach(s => s.Send(content));
|
||||
|
//}
|
||||
|
|
||||
|
#endregion
|
||||
|
#region FaceWebSocket
|
||||
|
/// <summary>
|
||||
|
/// 打开FaceWebSocket
|
||||
|
/// </summary>
|
||||
|
public void OpenSocketForFace() |
||||
|
{ |
||||
|
try |
||||
|
{ |
||||
|
var server = new WebSocketServer(ComParameters.Parameters._faceWSServer); |
||||
|
server.Start(socket => |
||||
|
{ |
||||
|
socket.OnOpen = () => //当建立Socket链接时执行此方法
|
||||
|
{ |
||||
|
faceSockets.Add(socket); |
||||
|
}; |
||||
|
|
||||
|
socket.OnClose = () =>// 当关闭Socket链接十执行此方法
|
||||
|
{ |
||||
|
faceSockets.Remove(socket); |
||||
|
}; |
||||
|
|
||||
|
socket.OnMessage = message =>// 接收客户端发送过来的信息
|
||||
|
{ |
||||
|
switch (message) |
||||
|
{ |
||||
|
case "relay": |
||||
|
{ |
||||
|
BaiduFaceSdk.SDK._masterFace = null; |
||||
|
ComParameters.Parameters._method = "relay"; |
||||
|
break; |
||||
|
} |
||||
|
case "recommend": |
||||
|
{ |
||||
|
BaiduFaceSdk.SDK._masterFace = null; |
||||
|
ComParameters.Parameters._method = "recommend"; |
||||
|
break; |
||||
|
} |
||||
|
} |
||||
|
}; |
||||
|
}); |
||||
|
} |
||||
|
catch (Exception ex) |
||||
|
{ |
||||
|
Log.MyLog.WriteLogFile("人脸Websocket开启异常:" + ex.Message, "FaceWebSocketError"); |
||||
|
} |
||||
|
|
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 人脸摄像头通知导视有人进入
|
||||
|
/// </summary>
|
||||
|
public void PeopleEnter() |
||||
|
{ |
||||
|
faceSockets.ForEach(s => s.Send("richad")); |
||||
|
} |
||||
|
/// <summary>
|
||||
|
/// 人员离开
|
||||
|
/// </summary>
|
||||
|
public void PeopleLeave() |
||||
|
{ |
||||
|
faceSockets.ForEach(s => s.Send(noFaceModel)); |
||||
|
} |
||||
|
/// <summary>
|
||||
|
/// 通知导视已关闭视频流
|
||||
|
/// </summary>
|
||||
|
public void PushCloseLive() |
||||
|
{ |
||||
|
faceSockets.ForEach(s => s.Send("closelive")); |
||||
|
} |
||||
|
/// <summary>
|
||||
|
/// 将小后台的返回值推送给导视
|
||||
|
/// </summary>
|
||||
|
/// <param name="content"></param>
|
||||
|
public void PushFaceData(string content) |
||||
|
{ |
||||
|
faceSockets.ForEach(s => s.Send(content)); |
||||
|
} |
||||
|
#endregion
|
||||
|
#region LiveWebSocket
|
||||
|
public void OpenSocketForLive() |
||||
|
{ |
||||
|
try |
||||
|
{ |
||||
|
var server = new WebSocketServer(ComParameters.Parameters._liveWSServer); |
||||
|
server.Start(socket => |
||||
|
{ |
||||
|
socket.OnOpen = () => //当建立Socket链接时执行此方法
|
||||
|
{ |
||||
|
if (ComParameters.Parameters._needAlive) |
||||
|
{ |
||||
|
ComParameters.Parameters._isLive = true; |
||||
|
} |
||||
|
//var data = socket.ConnectionInfo; //通过data可以获得这个链接传递过来的Cookie信息,用来区分各个链接和用户之间的关系(如果需要后台主动推送信息到某个客户的时候,可以使用Cookie)
|
||||
|
liveSockets.Add(socket); |
||||
|
}; |
||||
|
|
||||
|
socket.OnClose = () =>// 当关闭Socket链接十执行此方法
|
||||
|
{ |
||||
|
ComParameters.Parameters._isLive = false; |
||||
|
//Console.WriteLine("Close!");
|
||||
|
liveSockets.Remove(socket); |
||||
|
}; |
||||
|
|
||||
|
socket.OnMessage = message =>// 接收客户端发送过来的信息
|
||||
|
{ |
||||
|
switch (message) |
||||
|
{ |
||||
|
case "openlive"://导视通知打开视频流
|
||||
|
{ |
||||
|
ComParameters.Parameters._isOpenLive = true; |
||||
|
break; |
||||
|
} |
||||
|
case "closelive"://导视通知关闭视频流
|
||||
|
{ |
||||
|
ComParameters.Parameters._isOpenLive = false; |
||||
|
break; |
||||
|
} |
||||
|
} |
||||
|
}; |
||||
|
}); |
||||
|
} |
||||
|
catch (Exception ex) |
||||
|
{ |
||||
|
Log.MyLog.WriteLogFile("直播Websocket开启异常:" + ex.Message, "LiveWebSocketError"); |
||||
|
} |
||||
|
} |
||||
|
/// <summary>
|
||||
|
/// 视频帧推送
|
||||
|
/// </summary>
|
||||
|
/// <param name="data"></param>
|
||||
|
public void PushImage(string data) |
||||
|
{ |
||||
|
try |
||||
|
{ |
||||
|
liveSockets.ForEach(s => s.Send(data)); |
||||
|
} |
||||
|
catch (Exception ex) |
||||
|
{ |
||||
|
Log.MyLog.WriteLogFile("直播Websocket推送异常:" + ex.Message, "LiveWebSocketError"); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
#endregion
|
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,124 @@ |
|||||
|
<?xml version="1.0" encoding="utf-8"?> |
||||
|
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
||||
|
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> |
||||
|
<PropertyGroup> |
||||
|
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> |
||||
|
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> |
||||
|
<ProjectGuid>{D1AC3DD6-CA8D-4141-A250-E17EF25D6091}</ProjectGuid> |
||||
|
<OutputType>WinExe</OutputType> |
||||
|
<RootNamespace>FaceDetect</RootNamespace> |
||||
|
<AssemblyName>FaceDetect</AssemblyName> |
||||
|
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion> |
||||
|
<FileAlignment>512</FileAlignment> |
||||
|
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> |
||||
|
<WarningLevel>4</WarningLevel> |
||||
|
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects> |
||||
|
<Deterministic>true</Deterministic> |
||||
|
</PropertyGroup> |
||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> |
||||
|
<PlatformTarget>x64</PlatformTarget> |
||||
|
<DebugSymbols>true</DebugSymbols> |
||||
|
<DebugType>full</DebugType> |
||||
|
<Optimize>false</Optimize> |
||||
|
<OutputPath>bin\Debug\</OutputPath> |
||||
|
<DefineConstants>DEBUG;TRACE</DefineConstants> |
||||
|
<ErrorReport>prompt</ErrorReport> |
||||
|
<WarningLevel>4</WarningLevel> |
||||
|
</PropertyGroup> |
||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> |
||||
|
<PlatformTarget>AnyCPU</PlatformTarget> |
||||
|
<DebugType>pdbonly</DebugType> |
||||
|
<Optimize>true</Optimize> |
||||
|
<OutputPath>bin\Release\</OutputPath> |
||||
|
<DefineConstants>TRACE</DefineConstants> |
||||
|
<ErrorReport>prompt</ErrorReport> |
||||
|
<WarningLevel>4</WarningLevel> |
||||
|
</PropertyGroup> |
||||
|
<PropertyGroup> |
||||
|
<StartupObject>FaceDetect.EntryPoint</StartupObject> |
||||
|
</PropertyGroup> |
||||
|
<ItemGroup> |
||||
|
<Reference Include="Fleck, Version=1.2.0.0, Culture=neutral, processorArchitecture=MSIL"> |
||||
|
<HintPath>..\packages\Fleck.1.2.0\lib\net45\Fleck.dll</HintPath> |
||||
|
</Reference> |
||||
|
<Reference Include="Microsoft.VisualBasic" /> |
||||
|
<Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL"> |
||||
|
<HintPath>..\packages\Newtonsoft.Json.13.0.1\lib\net45\Newtonsoft.Json.dll</HintPath> |
||||
|
</Reference> |
||||
|
<Reference Include="OpenCvSharp, Version=1.0.0.0, Culture=neutral, processorArchitecture=AMD64"> |
||||
|
<SpecificVersion>False</SpecificVersion> |
||||
|
<HintPath>bin\Debug\OpenCvSharp.dll</HintPath> |
||||
|
</Reference> |
||||
|
<Reference Include="System" /> |
||||
|
<Reference Include="System.Configuration" /> |
||||
|
<Reference Include="System.Data" /> |
||||
|
<Reference Include="System.Xml" /> |
||||
|
<Reference Include="Microsoft.CSharp" /> |
||||
|
<Reference Include="System.Core" /> |
||||
|
<Reference Include="System.Xml.Linq" /> |
||||
|
<Reference Include="System.Data.DataSetExtensions" /> |
||||
|
<Reference Include="System.Net.Http" /> |
||||
|
<Reference Include="System.Xaml"> |
||||
|
<RequiredTargetFramework>4.0</RequiredTargetFramework> |
||||
|
</Reference> |
||||
|
<Reference Include="WindowsBase" /> |
||||
|
<Reference Include="PresentationCore" /> |
||||
|
<Reference Include="PresentationFramework" /> |
||||
|
</ItemGroup> |
||||
|
<ItemGroup> |
||||
|
<ApplicationDefinition Include="App.xaml"> |
||||
|
<Generator>MSBuild:Compile</Generator> |
||||
|
<SubType>Designer</SubType> |
||||
|
</ApplicationDefinition> |
||||
|
<Page Include="MainWindow.xaml"> |
||||
|
<Generator>MSBuild:Compile</Generator> |
||||
|
<SubType>Designer</SubType> |
||||
|
</Page> |
||||
|
<Compile Include="App.xaml.cs"> |
||||
|
<DependentUpon>App.xaml</DependentUpon> |
||||
|
<SubType>Code</SubType> |
||||
|
</Compile> |
||||
|
<Compile Include="Common\SystemManager.cs" /> |
||||
|
<Compile Include="Model\BaiduConfigModel.cs" /> |
||||
|
<Compile Include="Common\BaiduFaceSdk.cs" /> |
||||
|
<Compile Include="Common\ComParameters.cs" /> |
||||
|
<Compile Include="Common\FaceDraw.cs" /> |
||||
|
<Compile Include="Common\FileManage.cs" /> |
||||
|
<Compile Include="Common\HttpComm.cs" /> |
||||
|
<Compile Include="Common\Log.cs" /> |
||||
|
<Compile Include="Common\WebSocketManager.cs" /> |
||||
|
<Compile Include="MainWindow.xaml.cs"> |
||||
|
<DependentUpon>MainWindow.xaml</DependentUpon> |
||||
|
<SubType>Code</SubType> |
||||
|
</Compile> |
||||
|
</ItemGroup> |
||||
|
<ItemGroup> |
||||
|
<Compile Include="Model\FaceDataModel.cs" /> |
||||
|
<Compile Include="Properties\AssemblyInfo.cs"> |
||||
|
<SubType>Code</SubType> |
||||
|
</Compile> |
||||
|
<Compile Include="Properties\Resources.Designer.cs"> |
||||
|
<AutoGen>True</AutoGen> |
||||
|
<DesignTime>True</DesignTime> |
||||
|
<DependentUpon>Resources.resx</DependentUpon> |
||||
|
</Compile> |
||||
|
<Compile Include="Properties\Settings.Designer.cs"> |
||||
|
<AutoGen>True</AutoGen> |
||||
|
<DependentUpon>Settings.settings</DependentUpon> |
||||
|
<DesignTimeSharedInput>True</DesignTimeSharedInput> |
||||
|
</Compile> |
||||
|
<EmbeddedResource Include="Properties\Resources.resx"> |
||||
|
<Generator>ResXFileCodeGenerator</Generator> |
||||
|
<LastGenOutput>Resources.Designer.cs</LastGenOutput> |
||||
|
</EmbeddedResource> |
||||
|
<None Include="packages.config" /> |
||||
|
<None Include="Properties\Settings.settings"> |
||||
|
<Generator>SettingsSingleFileGenerator</Generator> |
||||
|
<LastGenOutput>Settings.Designer.cs</LastGenOutput> |
||||
|
</None> |
||||
|
</ItemGroup> |
||||
|
<ItemGroup> |
||||
|
<None Include="App.config" /> |
||||
|
</ItemGroup> |
||||
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> |
||||
|
</Project> |
||||
@ -0,0 +1,14 @@ |
|||||
|
<Window x:Class="FaceDetect.MainWindow" |
||||
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" |
||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" |
||||
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" |
||||
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" |
||||
|
xmlns:local="clr-namespace:FaceDetect" |
||||
|
mc:Ignorable="d" |
||||
|
Title="MainWindow" Height="200" Width="300" Loaded="Window_Loaded" Closed="Window_Closed"> |
||||
|
<Grid MouseMove="Grid_MouseMove"> |
||||
|
<StackPanel HorizontalAlignment="Center" VerticalAlignment="Center"> |
||||
|
<Label Content="版本:V1.0" FontSize="16" ></Label> |
||||
|
</StackPanel> |
||||
|
</Grid> |
||||
|
</Window> |
||||
@ -0,0 +1,66 @@ |
|||||
|
using FaceDetect.Common; |
||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Configuration; |
||||
|
using System.Linq; |
||||
|
using System.Text; |
||||
|
using System.Threading.Tasks; |
||||
|
using System.Windows; |
||||
|
using System.Windows.Controls; |
||||
|
using System.Windows.Data; |
||||
|
using System.Windows.Documents; |
||||
|
using System.Windows.Input; |
||||
|
using System.Windows.Media; |
||||
|
using System.Windows.Media.Imaging; |
||||
|
using System.Windows.Navigation; |
||||
|
using System.Windows.Shapes; |
||||
|
|
||||
|
namespace FaceDetect |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// MainWindow.xaml 的交互逻辑
|
||||
|
/// </summary>
|
||||
|
public partial class MainWindow : Window |
||||
|
{ |
||||
|
#region 构造函数
|
||||
|
public MainWindow() |
||||
|
{ |
||||
|
InitializeComponent(); |
||||
|
//百度SDK初始化
|
||||
|
BaiduFaceSdk.Init(); |
||||
|
////开启AllWebSocket
|
||||
|
//WebSocketManager.WebSocket.OpenSocketForAll();
|
||||
|
//开启FaceWebSocket
|
||||
|
WebSocketManager.WebSocket.OpenSocketForFace(); |
||||
|
//开启LiveWebSocket
|
||||
|
WebSocketManager.WebSocket.OpenSocketForLive(); |
||||
|
} |
||||
|
#endregion
|
||||
|
|
||||
|
#region 事件
|
||||
|
private void Window_Loaded(object sender, RoutedEventArgs e) |
||||
|
{ |
||||
|
//主要逻辑
|
||||
|
BaiduFaceSdk.SDK.USBVideoTract(); |
||||
|
} |
||||
|
|
||||
|
private void Window_Closed(object sender, EventArgs e) |
||||
|
{ |
||||
|
//销毁SDK
|
||||
|
BaiduFaceSdk.Destory(); |
||||
|
Environment.Exit(0); |
||||
|
#region 上传未被上传的人脸统计信息
|
||||
|
//BaiduFaceSdk.SDK.ClearTrack();
|
||||
|
BaiduFaceSdk.SDK.UploadTheRestFace(); |
||||
|
#endregion
|
||||
|
} |
||||
|
private void Grid_MouseMove(object sender, MouseEventArgs e) |
||||
|
{ |
||||
|
if (Mouse.LeftButton == MouseButtonState.Pressed) |
||||
|
{ |
||||
|
this.DragMove(); |
||||
|
} |
||||
|
} |
||||
|
#endregion
|
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,16 @@ |
|||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Linq; |
||||
|
using System.Text; |
||||
|
using System.Threading.Tasks; |
||||
|
|
||||
|
namespace FaceDetect.Model |
||||
|
{ |
||||
|
public class DetectModel |
||||
|
{ |
||||
|
public int max_detect_num { get; set; } |
||||
|
public int min_face_size { get; set; } |
||||
|
public int scale_ratio { get; set; } |
||||
|
public float not_face_thr { get; set; } |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,32 @@ |
|||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Linq; |
||||
|
using System.Text; |
||||
|
using System.Threading.Tasks; |
||||
|
|
||||
|
namespace FaceDetect.Model |
||||
|
{ |
||||
|
public class FaceDataModel |
||||
|
{ |
||||
|
public string GenderMale { get; set; } |
||||
|
|
||||
|
public string Age { get; set; } |
||||
|
|
||||
|
public int StopTime { get; set; } |
||||
|
|
||||
|
public DateTime BeginTime { get; set; } |
||||
|
|
||||
|
public DateTime EndTime { get; set; } |
||||
|
|
||||
|
public string IP { get; set; } |
||||
|
} |
||||
|
public class FaceSocketModel |
||||
|
{ |
||||
|
public int age { get; set; } |
||||
|
public string vipId { get; set; } |
||||
|
public string faceID { get; set; } |
||||
|
public string carNo { get; set; } |
||||
|
public string genderMale { get; set; } |
||||
|
public string faceImage { get; set; } |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,55 @@ |
|||||
|
using System.Reflection; |
||||
|
using System.Resources; |
||||
|
using System.Runtime.CompilerServices; |
||||
|
using System.Runtime.InteropServices; |
||||
|
using System.Windows; |
||||
|
|
||||
|
// 有关程序集的一般信息由以下
|
||||
|
// 控制。更改这些特性值可修改
|
||||
|
// 与程序集关联的信息。
|
||||
|
[assembly: AssemblyTitle("FaceDetect")] |
||||
|
[assembly: AssemblyDescription("")] |
||||
|
[assembly: AssemblyConfiguration("")] |
||||
|
[assembly: AssemblyCompany("Organization")] |
||||
|
[assembly: AssemblyProduct("FaceDetect")] |
||||
|
[assembly: AssemblyCopyright("Copyright © Organization 2022")] |
||||
|
[assembly: AssemblyTrademark("")] |
||||
|
[assembly: AssemblyCulture("")] |
||||
|
|
||||
|
// 将 ComVisible 设置为 false 会使此程序集中的类型
|
||||
|
//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型
|
||||
|
//请将此类型的 ComVisible 特性设置为 true。
|
||||
|
[assembly: ComVisible(false)] |
||||
|
|
||||
|
//若要开始生成可本地化的应用程序,请设置
|
||||
|
//.csproj 文件中的 <UICulture>CultureYouAreCodingWith</UICulture>
|
||||
|
//例如,如果您在源文件中使用的是美国英语,
|
||||
|
//使用的是美国英语,请将 <UICulture> 设置为 en-US。 然后取消
|
||||
|
//对以下 NeutralResourceLanguage 特性的注释。 更新
|
||||
|
//以下行中的“en-US”以匹配项目文件中的 UICulture 设置。
|
||||
|
|
||||
|
//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]
|
||||
|
|
||||
|
|
||||
|
[assembly: ThemeInfo( |
||||
|
ResourceDictionaryLocation.None, //主题特定资源词典所处位置
|
||||
|
//(未在页面中找到资源时使用,
|
||||
|
//或应用程序资源字典中找到时使用)
|
||||
|
ResourceDictionaryLocation.SourceAssembly //常规资源词典所处位置
|
||||
|
//(未在页面中找到资源时使用,
|
||||
|
//、应用程序或任何主题专用资源字典中找到时使用)
|
||||
|
)] |
||||
|
|
||||
|
|
||||
|
// 程序集的版本信息由下列四个值组成:
|
||||
|
//
|
||||
|
// 主版本
|
||||
|
// 次版本
|
||||
|
// 生成号
|
||||
|
// 修订号
|
||||
|
//
|
||||
|
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
|
||||
|
//通过使用 "*",如下所示:
|
||||
|
// [assembly: AssemblyVersion("1.0.*")]
|
||||
|
[assembly: AssemblyVersion("1.0.0.0")] |
||||
|
[assembly: AssemblyFileVersion("1.0.0.0")] |
||||
@ -0,0 +1,71 @@ |
|||||
|
//------------------------------------------------------------------------------
|
||||
|
// <auto-generated>
|
||||
|
// 此代码由工具生成。
|
||||
|
// 运行时版本: 4.0.30319.42000
|
||||
|
//
|
||||
|
// 对此文件的更改可能导致不正确的行为,如果
|
||||
|
// 重新生成代码,则所做更改将丢失。
|
||||
|
// </auto-generated>
|
||||
|
//------------------------------------------------------------------------------
|
||||
|
|
||||
|
namespace FaceDetect.Properties |
||||
|
{ |
||||
|
|
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 强类型资源类,用于查找本地化字符串等。
|
||||
|
/// </summary>
|
||||
|
// 此类是由 StronglyTypedResourceBuilder
|
||||
|
// 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。
|
||||
|
// 若要添加或移除成员,请编辑 .ResX 文件,然后重新运行 ResGen
|
||||
|
// (以 /str 作为命令选项),或重新生成 VS 项目。
|
||||
|
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] |
||||
|
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()] |
||||
|
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] |
||||
|
internal class Resources |
||||
|
{ |
||||
|
|
||||
|
private static global::System.Resources.ResourceManager resourceMan; |
||||
|
|
||||
|
private static global::System.Globalization.CultureInfo resourceCulture; |
||||
|
|
||||
|
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] |
||||
|
internal Resources() |
||||
|
{ |
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 返回此类使用的缓存 ResourceManager 实例。
|
||||
|
/// </summary>
|
||||
|
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] |
||||
|
internal static global::System.Resources.ResourceManager ResourceManager |
||||
|
{ |
||||
|
get |
||||
|
{ |
||||
|
if ((resourceMan == null)) |
||||
|
{ |
||||
|
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("FaceDetect.Properties.Resources", typeof(Resources).Assembly); |
||||
|
resourceMan = temp; |
||||
|
} |
||||
|
return resourceMan; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 重写当前线程的 CurrentUICulture 属性,对
|
||||
|
/// 使用此强类型资源类的所有资源查找执行重写。
|
||||
|
/// </summary>
|
||||
|
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] |
||||
|
internal static global::System.Globalization.CultureInfo Culture |
||||
|
{ |
||||
|
get |
||||
|
{ |
||||
|
return resourceCulture; |
||||
|
} |
||||
|
set |
||||
|
{ |
||||
|
resourceCulture = value; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,117 @@ |
|||||
|
<?xml version="1.0" encoding="utf-8"?> |
||||
|
<root> |
||||
|
<!-- |
||||
|
Microsoft ResX Schema |
||||
|
|
||||
|
Version 2.0 |
||||
|
|
||||
|
The primary goals of this format is to allow a simple XML format |
||||
|
that is mostly human readable. The generation and parsing of the |
||||
|
various data types are done through the TypeConverter classes |
||||
|
associated with the data types. |
||||
|
|
||||
|
Example: |
||||
|
|
||||
|
... ado.net/XML headers & schema ... |
||||
|
<resheader name="resmimetype">text/microsoft-resx</resheader> |
||||
|
<resheader name="version">2.0</resheader> |
||||
|
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader> |
||||
|
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader> |
||||
|
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data> |
||||
|
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data> |
||||
|
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64"> |
||||
|
<value>[base64 mime encoded serialized .NET Framework object]</value> |
||||
|
</data> |
||||
|
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> |
||||
|
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value> |
||||
|
<comment>This is a comment</comment> |
||||
|
</data> |
||||
|
|
||||
|
There are any number of "resheader" rows that contain simple |
||||
|
name/value pairs. |
||||
|
|
||||
|
Each data row contains a name, and value. The row also contains a |
||||
|
type or mimetype. Type corresponds to a .NET class that support |
||||
|
text/value conversion through the TypeConverter architecture. |
||||
|
Classes that don't support this are serialized and stored with the |
||||
|
mimetype set. |
||||
|
|
||||
|
The mimetype is used for serialized objects, and tells the |
||||
|
ResXResourceReader how to depersist the object. This is currently not |
||||
|
extensible. For a given mimetype the value must be set accordingly: |
||||
|
|
||||
|
Note - application/x-microsoft.net.object.binary.base64 is the format |
||||
|
that the ResXResourceWriter will generate, however the reader can |
||||
|
read any of the formats listed below. |
||||
|
|
||||
|
mimetype: application/x-microsoft.net.object.binary.base64 |
||||
|
value : The object must be serialized with |
||||
|
: System.Serialization.Formatters.Binary.BinaryFormatter |
||||
|
: and then encoded with base64 encoding. |
||||
|
|
||||
|
mimetype: application/x-microsoft.net.object.soap.base64 |
||||
|
value : The object must be serialized with |
||||
|
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter |
||||
|
: and then encoded with base64 encoding. |
||||
|
|
||||
|
mimetype: application/x-microsoft.net.object.bytearray.base64 |
||||
|
value : The object must be serialized into a byte array |
||||
|
: using a System.ComponentModel.TypeConverter |
||||
|
: and then encoded with base64 encoding. |
||||
|
--> |
||||
|
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"> |
||||
|
<xsd:element name="root" msdata:IsDataSet="true"> |
||||
|
<xsd:complexType> |
||||
|
<xsd:choice maxOccurs="unbounded"> |
||||
|
<xsd:element name="metadata"> |
||||
|
<xsd:complexType> |
||||
|
<xsd:sequence> |
||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" /> |
||||
|
</xsd:sequence> |
||||
|
<xsd:attribute name="name" type="xsd:string" /> |
||||
|
<xsd:attribute name="type" type="xsd:string" /> |
||||
|
<xsd:attribute name="mimetype" type="xsd:string" /> |
||||
|
</xsd:complexType> |
||||
|
</xsd:element> |
||||
|
<xsd:element name="assembly"> |
||||
|
<xsd:complexType> |
||||
|
<xsd:attribute name="alias" type="xsd:string" /> |
||||
|
<xsd:attribute name="name" type="xsd:string" /> |
||||
|
</xsd:complexType> |
||||
|
</xsd:element> |
||||
|
<xsd:element name="data"> |
||||
|
<xsd:complexType> |
||||
|
<xsd:sequence> |
||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> |
||||
|
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" /> |
||||
|
</xsd:sequence> |
||||
|
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" /> |
||||
|
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" /> |
||||
|
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" /> |
||||
|
</xsd:complexType> |
||||
|
</xsd:element> |
||||
|
<xsd:element name="resheader"> |
||||
|
<xsd:complexType> |
||||
|
<xsd:sequence> |
||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> |
||||
|
</xsd:sequence> |
||||
|
<xsd:attribute name="name" type="xsd:string" use="required" /> |
||||
|
</xsd:complexType> |
||||
|
</xsd:element> |
||||
|
</xsd:choice> |
||||
|
</xsd:complexType> |
||||
|
</xsd:element> |
||||
|
</xsd:schema> |
||||
|
<resheader name="resmimetype"> |
||||
|
<value>text/microsoft-resx</value> |
||||
|
</resheader> |
||||
|
<resheader name="version"> |
||||
|
<value>2.0</value> |
||||
|
</resheader> |
||||
|
<resheader name="reader"> |
||||
|
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> |
||||
|
</resheader> |
||||
|
<resheader name="writer"> |
||||
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> |
||||
|
</resheader> |
||||
|
</root> |
||||
@ -0,0 +1,30 @@ |
|||||
|
//------------------------------------------------------------------------------
|
||||
|
// <auto-generated>
|
||||
|
// This code was generated by a tool.
|
||||
|
// Runtime Version:4.0.30319.42000
|
||||
|
//
|
||||
|
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
|
// the code is regenerated.
|
||||
|
// </auto-generated>
|
||||
|
//------------------------------------------------------------------------------
|
||||
|
|
||||
|
namespace FaceDetect.Properties |
||||
|
{ |
||||
|
|
||||
|
|
||||
|
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] |
||||
|
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")] |
||||
|
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase |
||||
|
{ |
||||
|
|
||||
|
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); |
||||
|
|
||||
|
public static Settings Default |
||||
|
{ |
||||
|
get |
||||
|
{ |
||||
|
return defaultInstance; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,7 @@ |
|||||
|
<?xml version='1.0' encoding='utf-8'?> |
||||
|
<SettingsFile xmlns="uri:settings" CurrentProfile="(Default)"> |
||||
|
<Profiles> |
||||
|
<Profile Name="(Default)" /> |
||||
|
</Profiles> |
||||
|
<Settings /> |
||||
|
</SettingsFile> |
||||
Binary file not shown.
Binary file not shown.
@ -0,0 +1,34 @@ |
|||||
|
<?xml version="1.0" encoding="utf-8" ?> |
||||
|
<configuration> |
||||
|
<appSettings> |
||||
|
<!--是否需要常开视频流--> |
||||
|
<add key="NeedAlive" value="0"/> |
||||
|
<!--视频流像素X位--> |
||||
|
<add key="LiveX" value="200"/> |
||||
|
<!--视频流像素Y位--> |
||||
|
<add key="LiveY" value="200"/> |
||||
|
<!--视频流宽度--> |
||||
|
<add key="LiveWidth" value="250"/> |
||||
|
<!--视频流高度--> |
||||
|
<add key="LiveHeight" value="250"/> |
||||
|
<!--比对阈值--> |
||||
|
<add key="Threshold" value="80"/> |
||||
|
<!--摄像头配置,有n个摄像头,可配置为0到n-1,分别调用不同的摄像头--> |
||||
|
<add key="CameraIndex" value="0"/> |
||||
|
<!--百度人脸Sdk最大检测数--> |
||||
|
<add key="MaxDectNum" value="10"/> |
||||
|
<!--大后台服务器地址--> |
||||
|
<add key="HttpUrl" value="http://192.168.1.141:8015"/> |
||||
|
<!--小后台服务器地址--> |
||||
|
<add key="KioskUrl" value="https://localhost:7143"/> |
||||
|
<!--AllWebSocket地址--> |
||||
|
<!--<add key="WebsocketForAll" value="ws://127.0.0.1:7180"/>--> |
||||
|
<!--人脸WebSocket地址--> |
||||
|
<add key="WebsocketForFace" value="ws://127.0.0.1:7179"/> |
||||
|
<!--直播WebSocket地址--> |
||||
|
<add key="WebsocketForLive" value="ws://127.0.0.1:7188"/> |
||||
|
</appSettings> |
||||
|
<startup> |
||||
|
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8" /> |
||||
|
</startup> |
||||
|
</configuration> |
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
File diff suppressed because it is too large
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,13 @@ |
|||||
|
{ |
||||
|
"eye_open_threshold":0.5, |
||||
|
"eye_close_threshold":0.5, |
||||
|
"mouth_open_threshold":0.5, |
||||
|
"mouth_close_threshold":0.5, |
||||
|
"look_up_threshold":0.5, |
||||
|
"look_down_threshold":0.5, |
||||
|
"turn_left_threshold":0.5, |
||||
|
"turn_right_threshold":0.5, |
||||
|
"nod_threshold":0.5, |
||||
|
"shake_threshold":0.5, |
||||
|
"max_cache_num":1 |
||||
|
} |
||||
@ -0,0 +1,5 @@ |
|||||
|
{ |
||||
|
"is_flat":200, |
||||
|
"crop_size":100, |
||||
|
"enlarge_ratio":1 |
||||
|
} |
||||
@ -0,0 +1 @@ |
|||||
|
{"max_detect_num":10,"min_face_size":0,"scale_ratio":-1,"not_face_thr":0.5} |
||||
@ -0,0 +1,4 @@ |
|||||
|
{ |
||||
|
"detect_intv_before_track":0.02, |
||||
|
"detect_intv_during_track":0.02 |
||||
|
} |
||||
Binary file not shown.
@ -0,0 +1 @@ |
|||||
|
{"log_open":false} |
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,2 @@ |
|||||
|
2AD25B1506B1AB8A4DBDC2BE9EC14026DCED932D6952103DF549E57F4EFD931A537DFA8B04F1EAD1EB52178B25F417C9BA494E4845FB2A810DA869CC2FCF3B7A253C917AF723F3DB2CD9BEFE08841FD9FA6110BF58DA0F86D41FC597AE8ADC198FCE4690AAD832255564CCB99339ECE9DF541CE3627BEF59CBFBF92B3BDC8DE2FDD53AF78565A7A14D59602480BB67610B2EA0B0FDC1D177989713FDC056C2CE3F159EAE036BEABE73B7FA7A0FB034F86D6515D91A70B1171032F862043CCCA4C8D67BC433A27AB60BDB3546D1B37B947E500C2223A9EA8EE97B0FA9EE5400304F80A0DE9D931A02D2905210F42B695AC422CC6EF95E69699846EFACF92D1B20 |
||||
|
6DCA134DD95CE1F1C60F6791257EB0EC8CAC074E571DCDA77DEFD86F044B1BF5C185AF761C6423DF6736E8D487BE0796D055E77595602229224E535336EA577E1D385AC1A484A301FCEBAA5B3065714E9BBC4CADD720E2AF85400C21B8FAB0E134A7370665D948D5AC5ABB728E99C83081029FE7CC7BF1193B4D80204EAAC0CDEEBEE4C67911B27D71A088DDFCAB0C25FBFA43B23DD7DF816CE033281308D4FFDBE4E58119BC6A6B9D63D740321EDAA0653675A2E8134B9FC3048A80B824E08CE9F44D84C31346A959F7135A5272248901B8B2B36C6F7549AD0FEEBCC442CA7C9436799B71C97C43AC56F23AC63529D32FF0EE40849A3D3601D5E827C81B8CE0 |
||||
@ -0,0 +1 @@ |
|||||
|
FA6B-BHPC-TXFK-STGV |
||||
@ -0,0 +1,13 @@ |
|||||
|
|
||||
|
Log Entry : 14:25:20 2022年7月26日 |
||||
|
百度人脸Sdk初始化异常:试图加载格式不正确的程序。 (异常来自 HRESULT:0x8007000B) |
||||
|
------------------------------------ |
||||
|
|
||||
|
Log Entry : 14:31:16 2022年7月26日 |
||||
|
百度人脸Sdk初始化异常:试图加载格式不正确的程序。 (异常来自 HRESULT:0x8007000B) |
||||
|
------------------------------------ |
||||
|
|
||||
|
Log Entry : 14:31:28 2022年7月26日 |
||||
|
百度人脸Sdk初始化异常:试图加载格式不正确的程序。 (异常来自 HRESULT:0x8007000B) |
||||
|
------------------------------------ |
||||
|
|
||||
@ -0,0 +1,217 @@ |
|||||
|
|
||||
|
Log Entry : 15:31:22 2022年7月27日 |
||||
|
System.Net.WebException: 操作超时 |
||||
|
在 System.Net.HttpWebRequest.GetResponse() |
||||
|
在 FaceDetect.Common.HttpComm.Post(String url, String data, String contentType, Dictionary`2 headers) 位置 F:\WJL\IOT\FaceDetect\FaceDetect\FaceDetect\Common\HttpComm.cs:行号 90 |
||||
|
------------------------------------ |
||||
|
|
||||
|
Log Entry : 15:55:25 2022年7月27日 |
||||
|
System.Net.WebException: 无法连接到远程服务器 ---> System.Net.Sockets.SocketException: 由于目标计算机积极拒绝,无法连接。 127.0.0.1:53300 |
||||
|
在 System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress) |
||||
|
在 System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Exception& exception) |
||||
|
--- 内部异常堆栈跟踪的结尾 --- |
||||
|
在 System.Net.HttpWebRequest.GetRequestStream(TransportContext& context) |
||||
|
在 System.Net.HttpWebRequest.GetRequestStream() |
||||
|
在 FaceDetect.Common.HttpComm.Post(String url, String data, String contentType, Dictionary`2 headers) 位置 F:\WJL\IOT\FaceDetect\FaceDetect\FaceDetect\Common\HttpComm.cs:行号 86 |
||||
|
------------------------------------ |
||||
|
|
||||
|
Log Entry : 15:55:29 2022年7月27日 |
||||
|
System.Net.WebException: 无法连接到远程服务器 ---> System.Net.Sockets.SocketException: 由于目标计算机积极拒绝,无法连接。 127.0.0.1:53300 |
||||
|
在 System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress) |
||||
|
在 System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Exception& exception) |
||||
|
--- 内部异常堆栈跟踪的结尾 --- |
||||
|
在 System.Net.HttpWebRequest.GetRequestStream(TransportContext& context) |
||||
|
在 System.Net.HttpWebRequest.GetRequestStream() |
||||
|
在 FaceDetect.Common.HttpComm.Post(String url, String data, String contentType, Dictionary`2 headers) 位置 F:\WJL\IOT\FaceDetect\FaceDetect\FaceDetect\Common\HttpComm.cs:行号 86 |
||||
|
------------------------------------ |
||||
|
|
||||
|
Log Entry : 15:55:34 2022年7月27日 |
||||
|
System.Net.WebException: 无法连接到远程服务器 ---> System.Net.Sockets.SocketException: 由于目标计算机积极拒绝,无法连接。 127.0.0.1:53300 |
||||
|
在 System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress) |
||||
|
在 System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Exception& exception) |
||||
|
--- 内部异常堆栈跟踪的结尾 --- |
||||
|
在 System.Net.HttpWebRequest.GetRequestStream(TransportContext& context) |
||||
|
在 System.Net.HttpWebRequest.GetRequestStream() |
||||
|
在 FaceDetect.Common.HttpComm.Post(String url, String data, String contentType, Dictionary`2 headers) 位置 F:\WJL\IOT\FaceDetect\FaceDetect\FaceDetect\Common\HttpComm.cs:行号 86 |
||||
|
------------------------------------ |
||||
|
|
||||
|
Log Entry : 15:55:38 2022年7月27日 |
||||
|
System.Net.WebException: 无法连接到远程服务器 ---> System.Net.Sockets.SocketException: 由于目标计算机积极拒绝,无法连接。 127.0.0.1:53300 |
||||
|
在 System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress) |
||||
|
在 System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Exception& exception) |
||||
|
--- 内部异常堆栈跟踪的结尾 --- |
||||
|
在 System.Net.HttpWebRequest.GetRequestStream(TransportContext& context) |
||||
|
在 System.Net.HttpWebRequest.GetRequestStream() |
||||
|
在 FaceDetect.Common.HttpComm.Post(String url, String data, String contentType, Dictionary`2 headers) 位置 F:\WJL\IOT\FaceDetect\FaceDetect\FaceDetect\Common\HttpComm.cs:行号 86 |
||||
|
------------------------------------ |
||||
|
|
||||
|
Log Entry : 15:59:07 2022年7月27日 |
||||
|
System.Net.WebException: 无法连接到远程服务器 ---> System.Net.Sockets.SocketException: 由于目标计算机积极拒绝,无法连接。 127.0.0.1:53300 |
||||
|
在 System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress) |
||||
|
在 System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Exception& exception) |
||||
|
--- 内部异常堆栈跟踪的结尾 --- |
||||
|
在 System.Net.HttpWebRequest.GetRequestStream(TransportContext& context) |
||||
|
在 System.Net.HttpWebRequest.GetRequestStream() |
||||
|
在 FaceDetect.Common.HttpComm.Post(String url, String data, String contentType, Dictionary`2 headers) 位置 F:\WJL\IOT\FaceDetect\FaceDetect\FaceDetect\Common\HttpComm.cs:行号 86 |
||||
|
------------------------------------ |
||||
|
|
||||
|
Log Entry : 16:01:46 2022年7月27日 |
||||
|
System.Net.WebException: 无法连接到远程服务器 ---> System.Net.Sockets.SocketException: 由于目标计算机积极拒绝,无法连接。 127.0.0.1:53300 |
||||
|
在 System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress) |
||||
|
在 System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Exception& exception) |
||||
|
--- 内部异常堆栈跟踪的结尾 --- |
||||
|
在 System.Net.HttpWebRequest.GetRequestStream(TransportContext& context) |
||||
|
在 System.Net.HttpWebRequest.GetRequestStream() |
||||
|
在 FaceDetect.Common.HttpComm.Post(String url, String data, String contentType, Dictionary`2 headers) 位置 F:\WJL\IOT\FaceDetect\FaceDetect\FaceDetect\Common\HttpComm.cs:行号 86 |
||||
|
------------------------------------ |
||||
|
|
||||
|
Log Entry : 16:01:50 2022年7月27日 |
||||
|
System.Net.WebException: 无法连接到远程服务器 ---> System.Net.Sockets.SocketException: 由于目标计算机积极拒绝,无法连接。 127.0.0.1:53300 |
||||
|
在 System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress) |
||||
|
在 System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Exception& exception) |
||||
|
--- 内部异常堆栈跟踪的结尾 --- |
||||
|
在 System.Net.HttpWebRequest.GetRequestStream(TransportContext& context) |
||||
|
在 System.Net.HttpWebRequest.GetRequestStream() |
||||
|
在 FaceDetect.Common.HttpComm.Post(String url, String data, String contentType, Dictionary`2 headers) 位置 F:\WJL\IOT\FaceDetect\FaceDetect\FaceDetect\Common\HttpComm.cs:行号 86 |
||||
|
------------------------------------ |
||||
|
|
||||
|
Log Entry : 16:02:04 2022年7月27日 |
||||
|
System.Net.WebException: 无法连接到远程服务器 ---> System.Net.Sockets.SocketException: 由于目标计算机积极拒绝,无法连接。 127.0.0.1:53300 |
||||
|
在 System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress) |
||||
|
在 System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Exception& exception) |
||||
|
--- 内部异常堆栈跟踪的结尾 --- |
||||
|
在 System.Net.HttpWebRequest.GetRequestStream(TransportContext& context) |
||||
|
在 System.Net.HttpWebRequest.GetRequestStream() |
||||
|
在 FaceDetect.Common.HttpComm.Post(String url, String data, String contentType, Dictionary`2 headers) 位置 F:\WJL\IOT\FaceDetect\FaceDetect\FaceDetect\Common\HttpComm.cs:行号 86 |
||||
|
------------------------------------ |
||||
|
|
||||
|
Log Entry : 16:02:14 2022年7月27日 |
||||
|
System.Net.WebException: 无法连接到远程服务器 ---> System.Net.Sockets.SocketException: 由于目标计算机积极拒绝,无法连接。 127.0.0.1:53300 |
||||
|
在 System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress) |
||||
|
在 System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Exception& exception) |
||||
|
--- 内部异常堆栈跟踪的结尾 --- |
||||
|
在 System.Net.HttpWebRequest.GetRequestStream(TransportContext& context) |
||||
|
在 System.Net.HttpWebRequest.GetRequestStream() |
||||
|
在 FaceDetect.Common.HttpComm.Post(String url, String data, String contentType, Dictionary`2 headers) 位置 F:\WJL\IOT\FaceDetect\FaceDetect\FaceDetect\Common\HttpComm.cs:行号 86 |
||||
|
------------------------------------ |
||||
|
|
||||
|
Log Entry : 16:02:25 2022年7月27日 |
||||
|
System.Net.WebException: 无法连接到远程服务器 ---> System.Net.Sockets.SocketException: 由于目标计算机积极拒绝,无法连接。 127.0.0.1:53300 |
||||
|
在 System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress) |
||||
|
在 System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Exception& exception) |
||||
|
--- 内部异常堆栈跟踪的结尾 --- |
||||
|
在 System.Net.HttpWebRequest.GetRequestStream(TransportContext& context) |
||||
|
在 System.Net.HttpWebRequest.GetRequestStream() |
||||
|
在 FaceDetect.Common.HttpComm.Post(String url, String data, String contentType, Dictionary`2 headers) 位置 F:\WJL\IOT\FaceDetect\FaceDetect\FaceDetect\Common\HttpComm.cs:行号 86 |
||||
|
------------------------------------ |
||||
|
|
||||
|
Log Entry : 16:02:30 2022年7月27日 |
||||
|
System.Net.WebException: 无法连接到远程服务器 ---> System.Net.Sockets.SocketException: 由于目标计算机积极拒绝,无法连接。 127.0.0.1:53300 |
||||
|
在 System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress) |
||||
|
在 System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Exception& exception) |
||||
|
--- 内部异常堆栈跟踪的结尾 --- |
||||
|
在 System.Net.HttpWebRequest.GetRequestStream(TransportContext& context) |
||||
|
在 System.Net.HttpWebRequest.GetRequestStream() |
||||
|
在 FaceDetect.Common.HttpComm.Post(String url, String data, String contentType, Dictionary`2 headers) 位置 F:\WJL\IOT\FaceDetect\FaceDetect\FaceDetect\Common\HttpComm.cs:行号 86 |
||||
|
------------------------------------ |
||||
|
|
||||
|
Log Entry : 16:02:36 2022年7月27日 |
||||
|
System.Net.WebException: 无法连接到远程服务器 ---> System.Net.Sockets.SocketException: 由于目标计算机积极拒绝,无法连接。 127.0.0.1:53300 |
||||
|
在 System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress) |
||||
|
在 System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Exception& exception) |
||||
|
--- 内部异常堆栈跟踪的结尾 --- |
||||
|
在 System.Net.HttpWebRequest.GetRequestStream(TransportContext& context) |
||||
|
在 System.Net.HttpWebRequest.GetRequestStream() |
||||
|
在 FaceDetect.Common.HttpComm.Post(String url, String data, String contentType, Dictionary`2 headers) 位置 F:\WJL\IOT\FaceDetect\FaceDetect\FaceDetect\Common\HttpComm.cs:行号 86 |
||||
|
------------------------------------ |
||||
|
|
||||
|
Log Entry : 16:03:13 2022年7月27日 |
||||
|
System.Net.WebException: 无法连接到远程服务器 ---> System.Net.Sockets.SocketException: 由于目标计算机积极拒绝,无法连接。 127.0.0.1:53300 |
||||
|
在 System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress) |
||||
|
在 System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Exception& exception) |
||||
|
--- 内部异常堆栈跟踪的结尾 --- |
||||
|
在 System.Net.HttpWebRequest.GetRequestStream(TransportContext& context) |
||||
|
在 System.Net.HttpWebRequest.GetRequestStream() |
||||
|
在 FaceDetect.Common.HttpComm.Post(String url, String data, String contentType, Dictionary`2 headers) 位置 F:\WJL\IOT\FaceDetect\FaceDetect\FaceDetect\Common\HttpComm.cs:行号 86 |
||||
|
------------------------------------ |
||||
|
|
||||
|
Log Entry : 16:03:18 2022年7月27日 |
||||
|
System.Net.WebException: 无法连接到远程服务器 ---> System.Net.Sockets.SocketException: 由于目标计算机积极拒绝,无法连接。 127.0.0.1:53300 |
||||
|
在 System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress) |
||||
|
在 System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Exception& exception) |
||||
|
--- 内部异常堆栈跟踪的结尾 --- |
||||
|
在 System.Net.HttpWebRequest.GetRequestStream(TransportContext& context) |
||||
|
在 System.Net.HttpWebRequest.GetRequestStream() |
||||
|
在 FaceDetect.Common.HttpComm.Post(String url, String data, String contentType, Dictionary`2 headers) 位置 F:\WJL\IOT\FaceDetect\FaceDetect\FaceDetect\Common\HttpComm.cs:行号 86 |
||||
|
------------------------------------ |
||||
|
|
||||
|
Log Entry : 16:03:22 2022年7月27日 |
||||
|
System.Net.WebException: 无法连接到远程服务器 ---> System.Net.Sockets.SocketException: 由于目标计算机积极拒绝,无法连接。 127.0.0.1:53300 |
||||
|
在 System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress) |
||||
|
在 System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Exception& exception) |
||||
|
--- 内部异常堆栈跟踪的结尾 --- |
||||
|
在 System.Net.HttpWebRequest.GetRequestStream(TransportContext& context) |
||||
|
在 System.Net.HttpWebRequest.GetRequestStream() |
||||
|
在 FaceDetect.Common.HttpComm.Post(String url, String data, String contentType, Dictionary`2 headers) 位置 F:\WJL\IOT\FaceDetect\FaceDetect\FaceDetect\Common\HttpComm.cs:行号 86 |
||||
|
------------------------------------ |
||||
|
|
||||
|
Log Entry : 16:16:53 2022年7月27日 |
||||
|
System.Net.WebException: 无法连接到远程服务器 ---> System.Net.Sockets.SocketException: 由于目标计算机积极拒绝,无法连接。 127.0.0.1:53300 |
||||
|
在 System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress) |
||||
|
在 System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Exception& exception) |
||||
|
--- 内部异常堆栈跟踪的结尾 --- |
||||
|
在 System.Net.HttpWebRequest.GetRequestStream(TransportContext& context) |
||||
|
在 System.Net.HttpWebRequest.GetRequestStream() |
||||
|
在 FaceDetect.Common.HttpComm.Post(String url, String data, String contentType, Dictionary`2 headers) 位置 F:\WJL\IOT\FaceDetect\FaceDetect\FaceDetect\Common\HttpComm.cs:行号 86 |
||||
|
------------------------------------ |
||||
|
|
||||
|
Log Entry : 16:16:57 2022年7月27日 |
||||
|
System.Net.WebException: 无法连接到远程服务器 ---> System.Net.Sockets.SocketException: 由于目标计算机积极拒绝,无法连接。 127.0.0.1:53300 |
||||
|
在 System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress) |
||||
|
在 System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Exception& exception) |
||||
|
--- 内部异常堆栈跟踪的结尾 --- |
||||
|
在 System.Net.HttpWebRequest.GetRequestStream(TransportContext& context) |
||||
|
在 System.Net.HttpWebRequest.GetRequestStream() |
||||
|
在 FaceDetect.Common.HttpComm.Post(String url, String data, String contentType, Dictionary`2 headers) 位置 F:\WJL\IOT\FaceDetect\FaceDetect\FaceDetect\Common\HttpComm.cs:行号 86 |
||||
|
------------------------------------ |
||||
|
|
||||
|
Log Entry : 16:17:44 2022年7月27日 |
||||
|
System.Net.WebException: 无法连接到远程服务器 ---> System.Net.Sockets.SocketException: 由于目标计算机积极拒绝,无法连接。 127.0.0.1:53300 |
||||
|
在 System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress) |
||||
|
在 System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Exception& exception) |
||||
|
--- 内部异常堆栈跟踪的结尾 --- |
||||
|
在 System.Net.HttpWebRequest.GetRequestStream(TransportContext& context) |
||||
|
在 System.Net.HttpWebRequest.GetRequestStream() |
||||
|
在 FaceDetect.Common.HttpComm.Post(String url, String data, String contentType, Dictionary`2 headers) 位置 F:\WJL\IOT\FaceDetect\FaceDetect\FaceDetect\Common\HttpComm.cs:行号 86 |
||||
|
------------------------------------ |
||||
|
|
||||
|
Log Entry : 16:17:52 2022年7月27日 |
||||
|
System.Net.WebException: 无法连接到远程服务器 ---> System.Net.Sockets.SocketException: 由于目标计算机积极拒绝,无法连接。 127.0.0.1:53300 |
||||
|
在 System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress) |
||||
|
在 System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Exception& exception) |
||||
|
--- 内部异常堆栈跟踪的结尾 --- |
||||
|
在 System.Net.HttpWebRequest.GetRequestStream(TransportContext& context) |
||||
|
在 System.Net.HttpWebRequest.GetRequestStream() |
||||
|
在 FaceDetect.Common.HttpComm.Post(String url, String data, String contentType, Dictionary`2 headers) 位置 F:\WJL\IOT\FaceDetect\FaceDetect\FaceDetect\Common\HttpComm.cs:行号 86 |
||||
|
------------------------------------ |
||||
|
|
||||
|
Log Entry : 16:18:07 2022年7月27日 |
||||
|
System.Net.WebException: 无法连接到远程服务器 ---> System.Net.Sockets.SocketException: 由于目标计算机积极拒绝,无法连接。 127.0.0.1:53300 |
||||
|
在 System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress) |
||||
|
在 System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Exception& exception) |
||||
|
--- 内部异常堆栈跟踪的结尾 --- |
||||
|
在 System.Net.HttpWebRequest.GetRequestStream(TransportContext& context) |
||||
|
在 System.Net.HttpWebRequest.GetRequestStream() |
||||
|
在 FaceDetect.Common.HttpComm.Post(String url, String data, String contentType, Dictionary`2 headers) 位置 F:\WJL\IOT\FaceDetect\FaceDetect\FaceDetect\Common\HttpComm.cs:行号 86 |
||||
|
------------------------------------ |
||||
|
|
||||
|
Log Entry : 16:18:16 2022年7月27日 |
||||
|
System.Net.WebException: 无法连接到远程服务器 ---> System.Net.Sockets.SocketException: 由于目标计算机积极拒绝,无法连接。 127.0.0.1:53300 |
||||
|
在 System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress) |
||||
|
在 System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Exception& exception) |
||||
|
--- 内部异常堆栈跟踪的结尾 --- |
||||
|
在 System.Net.HttpWebRequest.GetRequestStream(TransportContext& context) |
||||
|
在 System.Net.HttpWebRequest.GetRequestStream() |
||||
|
在 FaceDetect.Common.HttpComm.Post(String url, String data, String contentType, Dictionary`2 headers) 位置 F:\WJL\IOT\FaceDetect\FaceDetect\FaceDetect\Common\HttpComm.cs:行号 86 |
||||
|
------------------------------------ |
||||
|
|
||||
@ -0,0 +1,5 @@ |
|||||
|
|
||||
|
Log Entry : 15:46:42 2022年7月27日 |
||||
|
屏保socket |
||||
|
------------------------------------ |
||||
|
|
||||
@ -0,0 +1,5 @@ |
|||||
|
|
||||
|
Log Entry : 15:03:16 2022年7月27日 |
||||
|
人脸Websocket开启异常:在其上下文中,该请求的地址无效。 |
||||
|
------------------------------------ |
||||
|
|
||||
File diff suppressed because it is too large
@ -0,0 +1,70 @@ |
|||||
|
|
||||
|
Log Entry : 13:43:16 2022年7月28日 |
||||
|
上传图片异常:Cannot cast Newtonsoft.Json.Linq.JObject to Newtonsoft.Json.Linq.JToken. |
||||
|
------------------------------------ |
||||
|
|
||||
|
Log Entry : 13:52:52 2022年7月28日 |
||||
|
上传图片异常:Cannot cast Newtonsoft.Json.Linq.JObject to Newtonsoft.Json.Linq.JToken. |
||||
|
------------------------------------ |
||||
|
|
||||
|
Log Entry : 14:19:06 2022年7月28日 |
||||
|
上传图片异常:Cannot cast Newtonsoft.Json.Linq.JObject to Newtonsoft.Json.Linq.JToken. |
||||
|
------------------------------------ |
||||
|
|
||||
|
Log Entry : 14:27:29 2022年7月28日 |
||||
|
上传图片异常:Cannot cast Newtonsoft.Json.Linq.JObject to Newtonsoft.Json.Linq.JToken. |
||||
|
------------------------------------ |
||||
|
|
||||
|
Log Entry : 14:28:16 2022年7月28日 |
||||
|
上传图片异常:Cannot cast Newtonsoft.Json.Linq.JObject to Newtonsoft.Json.Linq.JToken. |
||||
|
------------------------------------ |
||||
|
|
||||
|
Log Entry : 14:30:59 2022年7月28日 |
||||
|
上传图片异常:Cannot cast Newtonsoft.Json.Linq.JObject to Newtonsoft.Json.Linq.JToken. |
||||
|
------------------------------------ |
||||
|
|
||||
|
Log Entry : 14:31:10 2022年7月28日 |
||||
|
上传图片异常:Cannot cast Newtonsoft.Json.Linq.JObject to Newtonsoft.Json.Linq.JToken. |
||||
|
------------------------------------ |
||||
|
|
||||
|
Log Entry : 14:32:50 2022年7月28日 |
||||
|
上传图片异常:Cannot cast Newtonsoft.Json.Linq.JObject to Newtonsoft.Json.Linq.JToken. |
||||
|
------------------------------------ |
||||
|
|
||||
|
Log Entry : 15:06:18 2022年7月28日 |
||||
|
上传图片异常:Cannot cast Newtonsoft.Json.Linq.JObject to Newtonsoft.Json.Linq.JToken. |
||||
|
------------------------------------ |
||||
|
|
||||
|
Log Entry : 15:56:53 2022年7月28日 |
||||
|
上传图片异常:Cannot cast Newtonsoft.Json.Linq.JObject to Newtonsoft.Json.Linq.JToken. |
||||
|
------------------------------------ |
||||
|
|
||||
|
Log Entry : 15:59:40 2022年7月28日 |
||||
|
上传图片异常:Cannot cast Newtonsoft.Json.Linq.JObject to Newtonsoft.Json.Linq.JToken. |
||||
|
------------------------------------ |
||||
|
|
||||
|
Log Entry : 16:03:27 2022年7月28日 |
||||
|
上传图片异常:Cannot cast Newtonsoft.Json.Linq.JObject to Newtonsoft.Json.Linq.JToken. |
||||
|
------------------------------------ |
||||
|
|
||||
|
Log Entry : 16:09:53 2022年7月28日 |
||||
|
上传图片异常:Cannot cast Newtonsoft.Json.Linq.JObject to Newtonsoft.Json.Linq.JToken. |
||||
|
------------------------------------ |
||||
|
|
||||
|
Log Entry : 16:11:18 2022年7月28日 |
||||
|
上传图片异常:String 引用没有设置为 String 的实例。 |
||||
|
参数名: s |
||||
|
------------------------------------ |
||||
|
|
||||
|
Log Entry : 16:28:25 2022年7月28日 |
||||
|
上传图片异常:Cannot cast Newtonsoft.Json.Linq.JObject to Newtonsoft.Json.Linq.JToken. |
||||
|
------------------------------------ |
||||
|
|
||||
|
Log Entry : 16:29:02 2022年7月28日 |
||||
|
上传图片异常:Cannot cast Newtonsoft.Json.Linq.JObject to Newtonsoft.Json.Linq.JToken. |
||||
|
------------------------------------ |
||||
|
|
||||
|
Log Entry : 16:29:19 2022年7月28日 |
||||
|
上传图片异常:Cannot cast Newtonsoft.Json.Linq.JObject to Newtonsoft.Json.Linq.JToken. |
||||
|
------------------------------------ |
||||
|
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,5 @@ |
|||||
|
<?xml version="1.0" encoding="utf-8"?> |
||||
|
<packages> |
||||
|
<package id="Fleck" version="1.2.0" targetFramework="net48" /> |
||||
|
<package id="Newtonsoft.Json" version="13.0.1" targetFramework="net48" /> |
||||
|
</packages> |
||||
Loading…
Reference in new issue