using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
namespace DemoUI.SDK
{
///
///
///
public class NativeCWFaceRecognition
{
private const string CloudWalkSDKDll = "CWFaceSDK.dll";
///
///功能:创建识别句柄
///
/// 创建的识别句柄
/// 配置文件路径
/// 创建的句柄类型
///
[DllImport(CloudWalkSDKDll, EntryPoint = "cwCreateRecogHandle", CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr cwCreateRecogHandle(out cw_errcode_t errCode, string pConfigurePath, string pLicence, cw_recog_pattern_t emRecogPattern);
///
/// 释放通道
///
/// 识别句柄
///
[DllImport(CloudWalkSDKDll, EntryPoint = "cwReleaseRecogHandle", CallingConvention = CallingConvention.Cdecl)]
public static extern void cwReleaseRecogHandle(IntPtr pRecogHandle);
///
/// 功能:获取特征值长度
///
/// 识别句柄
///
[DllImport(CloudWalkSDKDll, EntryPoint = "cwGetFeatureLength", CallingConvention = CallingConvention.Cdecl)]
public static extern int cwGetFeatureLength(IntPtr pRecogHandle);
///
/// 功能:提取人脸特征值
///
/// 识别句柄
/// 对齐人脸数据指针
/// 返回的特征数,需要预先分配足够空间
///
[DllImport(CloudWalkSDKDll, EntryPoint = "cwGetFaceFeature", CallingConvention = CallingConvention.Cdecl)]
public static extern cw_errcode_t cwGetFaceFeature(IntPtr pRecogHandle, ref cw_aligned_face_t alignedFace, byte[] featueData);
///
/// 功能:计算2个特征与N个特征的相似度,返回的相似度scores的个数为N个
///
/// 识别句柄
/// 特征1,只能是一个特征
/// 特征2,可以是N个特征
/// 特征2的个数
/// 返回的相似度分数数组,长度为Fea2num,需要预先分配空间
///
[DllImport(CloudWalkSDKDll, EntryPoint = "cwComputeMatchScore", CallingConvention = CallingConvention.Cdecl)]
public static extern cw_errcode_t cwComputeMatchScore(IntPtr pRecogHandle, byte[] pFea1, byte[] pFea2, int Fea2Num, float[] scores);
///
/// 功能:比对两个人脸图片中最大人脸特征,获取相似度
///
/// 检测句柄
/// 识别句柄
/// 图片1数据
/// 图片2数据
/// 比对分数
///
[DllImport(CloudWalkSDKDll, EntryPoint = "cwVerifyImageData", CallingConvention = CallingConvention.Cdecl)]
public static extern cw_errcode_t cwVerifyImageData(IntPtr pDetector, IntPtr pRecogHandle, cw_img_t[] pFrameImg1, cw_img_t[] pFrameImg2, float[] scores);
}
}