Browse Source

提交接口请求方式以及双目

master
胡超1 1 year ago
parent
commit
c3602e2f95
  1. 159
      CPF_Cef/Devices/LhtCF.cs
  2. 2
      CPF_Cef/Devices/PrintPJ.cs
  3. 188
      CPF_Cef/Devices/SignDll.cs
  4. 6
      CPF_Cef/FrmMain.cs
  5. 801
      CPF_Cef/MainModel.cs
  6. 2
      CPF_Cef/Parame.cs

159
CPF_Cef/Devices/LhtCF.cs

@ -0,0 +1,159 @@
using AKSWebBrowser.Commen;
using CPF.Windows;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
namespace AksWebBrowser.Devices
{
public class LhtCF
{
public LhtCF() { }
/// <summary>
/// 人脸比对
/// </summary>
/// <param name="code"></param>
/// <returns></returns>
public static string LhtCFFace(string code,string faceA)
{
string result = string.Empty;
try
{
int status = libLhtCFs.CF_Init();
Log.Info("初始化函数" + status);
if (status == 0)
{
status = libLhtCFs.CF_GetCameraStatus(0);
Log.Info("获取摄像头状态" + status);
if (status == 0)
{
status = libLhtCFs.CF_OpenCamera();
Log.Info("打开摄像头" + status);
if (status == 0)
{
status = libLhtCFs.CF_CreatWindow(0, 0, 300, 800, 600, 500);
Log.Info("创建视频预览窗口" + status);
if (status == 0)
{
status = libLhtCFs.CF_StartLiveDetectEx(10000);
Log.Info("活体检测超时时间:" + status);
if (status == 0)
{
string time = DateTime.Now.ToString("yyyyMMddHHmmss", DateTimeFormatInfo.InvariantInfo);
var tmpFile = "/tmp/" + time + ".jpg";
//停止活体检测
Task.Run(() => { libLhtCFs.CF_StopLiveDetect(); });
}
//关闭视频预览窗口
Task.Run(() => { libLhtCFs.CF_CloseWindow(0); });
}
//关闭摄像头
Task.Run(() => { libLhtCFs.CF_CloseCamera(); });
}
}
}
}
catch (Exception ex)
{
Log.Error("双目摄像头采集人脸异常:" + ex.Message);
}
return "";
}
}
class libLhtCFs
{
// 检测回调函数定义
[System.Runtime.InteropServices.UnmanagedFunctionPointerAttribute(System.Runtime.InteropServices.CallingConvention.Cdecl)]
public delegate void DetectCallBack(int nEventId, IntPtr lpContext);
//RGB数据回调函数定义
[System.Runtime.InteropServices.UnmanagedFunctionPointerAttribute(System.Runtime.InteropServices.CallingConvention.Cdecl)]
public delegate void GetVideoStream([MarshalAs(UnmanagedType.LPArray)] byte[] rgbData, int width, int height);
//mjpeg数据回调函数定义
[System.Runtime.InteropServices.UnmanagedFunctionPointerAttribute(System.Runtime.InteropServices.CallingConvention.Cdecl)]
public delegate void GetMjpegStream([MarshalAs(UnmanagedType.LPArray)] byte[] mjpegData, int dataLen);
//初始化
[DllImport("libLhtCF", EntryPoint = "CF_Init", SetLastError = true, CharSet = CharSet.Auto, ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
public static extern int CF_Init();
//反初始化函数
[DllImport("libLhtCF", EntryPoint = "CF_Uninit", SetLastError = true, CharSet = CharSet.Auto, ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
public static extern int CF_Uninit();
//反初始化函数
[DllImport("libLhtCF", EntryPoint = "CF_GetCameraStatus", SetLastError = true, CharSet = CharSet.Auto, ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
public static extern int CF_GetCameraStatus(int status);
//设置检测回调函数
[DllImport("libLhtCF", EntryPoint = "CF_GetCameraStatus", SetLastError = true, CharSet = CharSet.Auto, ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
public static extern int CF_SetDetectCallBack(DetectCallBack pCB, IntPtr lpContext);
//设置彩色摄像头视频流回调
[DllImport("libLhtCF", EntryPoint = "SetCamADataCallback", SetLastError = true, CharSet = CharSet.Auto, ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
public static extern int SetCamADataCallback(GetVideoStream cb);
//设置红外摄像头视频流回调
[DllImport("libLhtCF", EntryPoint = "SetCamBDataCallback", SetLastError = true, CharSet = CharSet.Auto, ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
public static extern int SetCamBDataCallback(GetVideoStream cb);
//设置彩色摄像头mjpeg数据流回调
[DllImport("libLhtCF", EntryPoint = "SetCamADataCallbackEx", SetLastError = true, CharSet = CharSet.Auto, ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
public static extern int SetCamADataCallbackEx(GetMjpegStream cb);
//设置红外摄像头mjpeg数据流回调
[DllImport("libLhtCF", EntryPoint = "SetCamBDataCallbackEx", SetLastError = true, CharSet = CharSet.Auto, ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
public static extern int SetCamBDataCallbackEx(GetMjpegStream cb);
//设置分辨率
[DllImport("libLhtCF", EntryPoint = "CF_SetResolution", SetLastError = true, CharSet = CharSet.Auto, ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
public static extern int CF_SetResolution(int width, int height);
//打开摄像头
[DllImport("libLhtCF", EntryPoint = "CF_OpenCamera", SetLastError = true, CharSet = CharSet.Auto, ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
public static extern int CF_OpenCamera();
//关闭摄像头
[DllImport("libLhtCF", EntryPoint = "CF_CloseCamera", SetLastError = true, CharSet = CharSet.Auto, ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
public static extern int CF_CloseCamera();
//开始活体检测
[DllImport("libLhtCF", EntryPoint = "CF_StartLiveDetect", SetLastError = true, CharSet = CharSet.Auto, ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
public static extern int CF_StartLiveDetect();
//活体检测超时时间
[DllImport("libLhtCF", EntryPoint = "CF_StartLiveDetectEx", SetLastError = true, CharSet = CharSet.Auto, ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
public static extern int CF_StartLiveDetectEx(int timeout);
//停止活体检测
[DllImport("libLhtCF", EntryPoint = "CF_StopLiveDetect", SetLastError = true, CharSet = CharSet.Auto, ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
public static extern int CF_StopLiveDetect();
//获取采集图像
[DllImport("libLhtCF", EntryPoint = "CF_GetImage", SetLastError = true, CharSet = CharSet.Auto, ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
public static extern int CF_GetImage(int nImageType, [MarshalAs(UnmanagedType.LPArray)] byte[] FilePath);
//获取采集图像
[DllImport("libLhtCF", EntryPoint = "CF_GetImage", SetLastError = true, CharSet = CharSet.Auto, ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
public static extern int CF_FaceCompare(byte[] picPathA, byte[] picPathB, int score);
//创建视频预览窗口
[DllImport("libLhtCF", EntryPoint = "CF_CreatWindow", SetLastError = true, CharSet = CharSet.Auto, ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
public static extern int CF_CreatWindow(int nWndType, long hWnd, int iX, int iY, int iWidth, int iHeight);
//关闭视频预览窗口
[DllImport("libLhtCF", EntryPoint = "CF_CloseWindow", SetLastError = true, CharSet = CharSet.Auto, ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
public static extern int CF_CloseWindow(int nWndType);
}
}

2
CPF_Cef/Devices/PrintPJ.cs

@ -71,8 +71,6 @@ namespace AksWebBrowser.Devices
{ {
try try
{ {
//注册gb2312
Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
string txt = string.Format(" 您预约办理的{0}业务-,排号为:", ywmc); string txt = string.Format(" 您预约办理的{0}业务-,排号为:", ywmc);
LibPrint.SetClean(); LibPrint.SetClean();
LibPrint.SetReadZKmode(0); LibPrint.SetReadZKmode(0);

188
CPF_Cef/Devices/SignDll.cs

@ -1,188 +0,0 @@
using AksWebBrowser;
using AksWebBrowser.Common;
using AKSWebBrowser.Commen;
using System;
using System.Globalization;
using System.IO;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
public struct TOUCH_INFO
{
public int btnID;//5寸 确定 重签 取消按钮
}
namespace DevicesService.Devices
{
public class SignDll
{
public static int status = -1;
public static string callback;
public SignDll()
{
//OpenSDK();
}
//打开签字版
public void OpenSDK()
{
try
{
status = FiveInchDll.GWQ_Init();
Log.Info("初始化SDK:" + status.ToString());
string UIFile = System.IO.Directory.GetCurrentDirectory();
UIFile = UIFile + @"/aks/adv_ui.jpg";
FiveInchDll.GWQ_SetImage(UIFile);
FiveInchDll.GWQ_ShowImage();
//加载回调
FiveInchDll.GWQ_setCallback(callback_str_receive);
FiveInchDll.GWQ_OnOffPointReporting(0);
//FiveInchDll.GWQ_setSignatureData(callback_signatureData);
}
catch (Exception ex) { Log.Error(ex.Message); }
finally { }
}
public void callback_str_receive(int number, byte[] data, byte[] path)
{
try
{
//Log.Info(number.ToString());
//1 签字确定按钮 2签字取消按钮 3 签字重签按钮(清空界面)
if (number == 0x10)
{
//確認
int ret = FiveInchDll.GWQ_GetImage();
Log.Info("GWQ_GetImage:" + ret);
FiveInchDll.GWQ_ShowImage();
}
else if (number == 0x40)
{
//重簽
int ret = FiveInchDll.GWQ_ReSign();
Log.Info("GWQ_ReSign:" + ret);
}
else if (number == 0xB0)
{
//Task.Run(async () =>
//{
// Log.Info(callback);
// Log.Info(path);
// byte[] img = File.ReadAllBytes(path);
// string base64 = Convert.ToBase64String(img);
// Log.Info(base64);
// //完成圖片保存
// string result = "{\"message\":\"success\",\"code\":\"200\",\"status\":true,\"suffix\":\"png\",\"data\":\"" + base64 + "\"}";
// Log.Info(result);
// string _parm = callback + "('" + result + "')";
// await Parame.webBrowser.ExecuteJavaScript(_parm);
//});
}
else if (number == 0x30)
{
//取消
FiveInchDll.GWQ_ShowImage();
}
}
catch (Exception ex) { Log.Error(ex.Message); }
finally { }
}
//0816加报点
public void callback_signatureData(int x, int y, int p, int sn)
{
return;
}
//打开签字版
public void OpenComDevice(string _callback)
{
try
{
callback = _callback;
OpenSDK();
FiveInchDll.GWQ_SwitchLanguage(0);
}
catch (Exception ex) { Log.Error(ex.Message); }
finally { }
}
//釋放簽字版
public int ReleaseComDevice()
{
int ret = -1;
//try
//{
// if (status == 0)
// {
// ret = FiveInchDll.GWQ_Release();
// if (ret == 0)
// {
// status = -1;
// //取消
// FiveInchDll.GWQ_ShowImage();
// }
// }
//}
//catch { }
//finally { }
return ret;
}
}
class FiveInchDll
{
[System.Runtime.InteropServices.UnmanagedFunctionPointerAttribute(System.Runtime.InteropServices.CallingConvention.StdCall)]
public delegate void callback_str_receive(int type, byte[] data, byte[] path);// (int number);
[System.Runtime.InteropServices.UnmanagedFunctionPointerAttribute(System.Runtime.InteropServices.CallingConvention.StdCall)]
public delegate void callback_signatureData(int x, int y, int p, int sn);
//0816加报点
[System.Runtime.InteropServices.UnmanagedFunctionPointerAttribute(System.Runtime.InteropServices.CallingConvention.StdCall)]
public delegate void TOUCH_INFO_FUNC([MarshalAs(UnmanagedType.LPArray, SizeConst = 160)] TOUCH_INFO[] info);
[DllImport("libdevice5_hid_sdk", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern int GWQ_Init(); //1.1SDK初始化
[DllImport("libdevice5_hid_sdk", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern int GWQ_Release();//SDK释放
[DllImport("libdevice5_hid_sdk.so", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern int GWQ_DeviceOnline();//检查设备是否在线
[DllImport("libdevice5_hid_sdk", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern int GWQ_setCallback(callback_str_receive cb);
[DllImport("libdevice5_hid_sdk", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern int GWQ_setSignatureData(callback_signatureData cb);
[DllImport("libdevice5_hid_sdk", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern int GWQ_SwitchLanguage(int language);//语言切换
[DllImport("libdevice5_hid_sdk", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern int GWQ_GetImage();//获取签字图片(用户点击确定后发送)
[DllImport("libdevice5_hid_sdk", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern int GWQ_SetImage(string uifile);//设置签字图片
[DllImport("libdevice5_hid_sdk", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern int GWQ_ShowImage();//显示设置的图片
[DllImport("libdevice5_hid_sdk", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern int GWQ_OnOffScreen(int type);//亮屏熄屏 1 熄屏 0亮屏
[DllImport("libdevice5_hid_sdk", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern int GWQ_Reboot();//重启设备
[DllImport("libdevice5_hid_sdk", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern int GWQ_ReSign();// 重新签字
[DllImport("libdevice5_hid_sdk", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern int GWQ_OnOffPointReporting(int type);//开启关闭报点(同屏报点) 1 开启 0关闭
[DllImport("libdevice5_hid_sdk", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern int GWQ_SetStartUpLogo(string path);//设置开机logo
[DllImport("libdevice5_hid_sdk", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern int GWQ_SetSigningBackground(byte[] path, int len);//发送签字背景
[DllImport("libdevice5_hid_sdk", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern int GWQ_SetSigningBackground2(byte[] path, int len);//设置开机logo
}
}

6
CPF_Cef/FrmMain.cs

@ -24,13 +24,15 @@ namespace AKS.EnterpriseLibrary.WebBrowser
protected override void InitializeComponent() protected override void InitializeComponent()
{ {
//注册gb2312
Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
LoadStyleFile("res://AksWebBrowser/StyleSheet.css"); LoadStyleFile("res://AksWebBrowser/StyleSheet.css");
//加载样式文件,文件需要设置为内嵌资源 //加载样式文件,文件需要设置为内嵌资源
Title = "控申业务专用浏览器"; Title = "控申业务专用浏览器";
CanResize = false; CanResize = false;
ShowInTaskbar = true; ShowInTaskbar = true;
WindowState = WindowState.FullScreen; WindowState = WindowState.FullScreen;
var v = new VideoView Parame.videoV = new VideoView
{ {
Name = "player", Name = "player",
PresenterFor = this, PresenterFor = this,
@ -48,7 +50,7 @@ namespace AKS.EnterpriseLibrary.WebBrowser
Size = SizeField.Fill, Size = SizeField.Fill,
Children = Children =
{ {
v, //Parame.videoV,
new CusWebBrowser new CusWebBrowser
{ {
PresenterFor = this, PresenterFor = this,

801
CPF_Cef/MainModel.cs

File diff suppressed because it is too large Load Diff

2
CPF_Cef/Parame.cs

@ -1,4 +1,5 @@
using AKS.EnterpriseLibrary.WebBrowser; using AKS.EnterpriseLibrary.WebBrowser;
using CPF.Controls;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
@ -11,6 +12,7 @@ namespace AksWebBrowser
public class Parame public class Parame
{ {
public static TcpClient tcpClient { get; set; } public static TcpClient tcpClient { get; set; }
public static VideoView videoV { get; set; }
public static CusWebBrowser webBrowser { get; set; } public static CusWebBrowser webBrowser { get; set; }
public static List<Func> FuncObject { get; set; } public static List<Func> FuncObject { get; set; }
//接口地址 //接口地址

Loading…
Cancel
Save