From ee5e3a086a5dc145e7f5df3de32e0e072c183949 Mon Sep 17 00:00:00 2001 From: z8018 <1282578289@qq.com> Date: 星期五, 06 六月 2025 15:19:40 +0800 Subject: [PATCH] 1 --- project/WCS/WIDESEAWCS_Server/WIDESEAWCS_Common/FaceAI/FaceCompare.cs | 1488 +++++++++++++++++++++++++++++----------------------------- 1 files changed, 744 insertions(+), 744 deletions(-) diff --git a/project/WCS/WIDESEAWCS_Server/WIDESEAWCS_Common/FaceAI/FaceCompare.cs b/project/WCS/WIDESEAWCS_Server/WIDESEAWCS_Common/FaceAI/FaceCompare.cs index b9db029..9f34a50 100644 --- a/project/WCS/WIDESEAWCS_Server/WIDESEAWCS_Common/FaceAI/FaceCompare.cs +++ b/project/WCS/WIDESEAWCS_Server/WIDESEAWCS_Common/FaceAI/FaceCompare.cs @@ -1,781 +1,781 @@ -锘縰sing System; -using System.Runtime.InteropServices; -using System.IO; -using OpenCvSharp; +锘�//using System; +//using System.Runtime.InteropServices; +//using System.IO; +//using OpenCvSharp; -// 浜鸿劯姣斿锛堝娉細浜鸿劯姣斿锛屽疄闄呬笂鏄汉鑴哥殑鐗瑰緛鍊兼瘮瀵癸紝鎻愬彇鍑轰汉鑴哥壒寰佸�硷紝鐢╟ompare_feature鏂规硶姣斿) -namespace FaceAI -{ - // 浜鸿劯姣旇緝1:1銆�1:N銆佹娊鍙栦汉鑴哥壒寰佸�笺�佹寜鐗瑰緛鍊兼瘮杈冪瓑 - public class FaceCompare - { - // 鎻愬彇浜鸿劯鐗瑰緛鍊�(浼犲浘鐗囨枃浠惰矾寰�) - /// <summary> - /// 鎻愬彇浜鸿劯鐗瑰緛鍊硷紝涓�512涓诞鐐瑰�硷紝宸插姞瀵� - /// </summary> - /// <param name="file_name">鍥剧墖淇℃伅锛屾暟鎹ぇ灏忓皬浜�10M锛屼紶鍏ュ浘鐗囨枃浠惰矾寰�</param> - /// <param name="length">閫氳繃寮曠敤杩斿洖鐗瑰緛鍊肩殑闀垮害锛岃嫢涓�2048琛ㄧず鎻愬彇姝g‘锛屽叾浠栧�艰〃绀烘彁鍙栦簡閿欒鐨勭壒寰佸��</param> - /// <returns></returns> - [DllImport("BaiduFaceApi.dll", EntryPoint = "get_face_feature", CharSet = CharSet.Ansi - , CallingConvention = CallingConvention.Cdecl)] - public static extern IntPtr get_face_feature(string file_name, ref int length); - // 鎻愬彇浜鸿劯鐗瑰緛鍊�(浼犱簩杩涘埗鍥剧墖buffer锛� - /// <summary> - /// 鎻愬彇浜鸿劯鐗瑰緛鍊硷紝涓�2048涓猙yte (浼犲叆浜岃繘鍒跺浘鐗嘼uffer) - /// </summary> - /// <param name="buf"></param> - /// <param name="size"></param> - /// <param name="length"></param> - /// <returns></returns> - [DllImport("BaiduFaceApi.dll", EntryPoint = "get_face_feature_by_buf", CharSet = CharSet.Ansi - , CallingConvention = CallingConvention.Cdecl)] - public static extern IntPtr get_face_feature_by_buf(byte[] buf, int size, ref int length); - //// 鑾峰彇浜鸿劯鐗瑰緛鍊硷紙浼犲叆opencv瑙嗛甯у強浜鸿劯淇℃伅锛岄�傚簲浜庡浜鸿劯锛� - ///// <summary> - ///// 鑾峰彇浜鸿劯鐗瑰緛鍊硷紙浼犲叆opencv瑙嗛甯у強浜鸿劯淇℃伅锛岄�傚簲浜庡浜鸿劯锛� - ///// </summary> - ///// <param name="mat"></param> - ///// <param name="info"></param> - ///// <param name="feaptr"></param> - ///// <returns></returns> - //[DllImport("BaiduFaceApi.dll", EntryPoint = "get_face_feature_by_face", CharSet = CharSet.Ansi - // , CallingConvention = CallingConvention.Cdecl)] - //public static extern int get_face_feature_by_face(IntPtr mat, ref TrackFaceInfo info, ref IntPtr feaptr); - // 浜鸿劯1:1姣斿(浼犲浘鐗囨枃浠惰矾寰�) - /// <summary> - /// 浜鸿劯瀵规瘮鎺ュ彛锛堜紶鍏ュ浘鐗囨枃浠惰矾寰勶級 - /// </summary> - /// <param name="file_name1">闇�瑕佸姣旂殑绗竴寮犲浘鐗囷紝灏忎簬10M锛屼紶鍏ュ浘鐗囨枃浠惰矾寰�</param> - /// <param name="file_name2">闇�瑕佸姣旂殑绗簩寮犲浘鐗囷紝灏忎簬10M锛屼紶鍏ュ浘鐗囨枃浠惰矾寰�</param> - /// <returns></returns> - [DllImport("BaiduFaceApi.dll", EntryPoint = "match", CharSet = CharSet.Ansi - , CallingConvention = CallingConvention.Cdecl)] - public static extern IntPtr match(string file_name1, string file_name2); - // 浜鸿劯1:1姣斿锛堜紶浜岃繘鍒跺浘鐗嘼uffer锛� - /// <summary> - /// 浜鸿劯瀵规瘮鎺ュ彛锛堜紶鍏ヤ簩杩涘埗鍥剧墖buffer锛� - /// </summary> - /// <param name="buf1">闇�瑕佸姣旂殑绗竴寮犲浘鐗囷紝灏忎簬10M</param> - /// <param name="size1">鍥剧墖1鐨勫ぇ灏�</param> - /// <param name="buf2">闇�瑕佸姣旂殑绗簩寮犲浘鐗囷紝灏忎簬10M</param> - /// <param name="size2">鍥剧墖2鐨勫ぇ灏�</param> - /// <returns></returns> - [DllImport("BaiduFaceApi.dll", EntryPoint = "match_by_buf", CharSet = CharSet.Ansi - , CallingConvention = CallingConvention.Cdecl)] - public static extern IntPtr match_by_buf(byte[] buf1, int size1, byte[] buf2, int size2); - // 浜鸿劯1:1姣斿锛堜紶opencv瑙嗛甯э級 - /// <summary> - /// 浜鸿劯1:1姣斿锛堜紶opencv瑙嗛甯э級 - /// </summary> - /// <param name="img1"></param> - /// <param name="img2"></param> - /// <returns></returns> - [DllImport("BaiduFaceApi.dll", EntryPoint = "match_by_mat", CharSet = CharSet.Ansi - , CallingConvention = CallingConvention.Cdecl)] - public static extern IntPtr match_by_mat(IntPtr img1, IntPtr img2);// byte[] buf1, int size1, byte[] buf2, int size2); - // 浜鸿劯1:1姣斿锛堜紶浜鸿劯鐗瑰緛鍊煎拰浜岃繘鍒跺浘鐗嘼uffer) - /// <summary> - /// 浜鸿劯瀵规瘮鎺ュ彛(浼犲叆浜岃繘鍒跺浘鐗嘼uffer) - /// </summary> - /// <param name="feature">鏂囦欢鐗瑰緛</param> - /// <param name="fea_len"></param> - /// <param name="buf2"></param> - /// <param name="size2"></param> - /// <returns></returns> - [DllImport("BaiduFaceApi.dll", EntryPoint = "match_by_feature", CharSet = CharSet.Ansi - , CallingConvention = CallingConvention.Cdecl)] - public static extern IntPtr match_by_feature(byte[] feature, int fea_len, byte[] buf2, int size2); - // 鐗瑰緛鍊兼瘮瀵癸紙浼�2涓汉鑴哥殑鐗瑰緛鍊硷級 - /// <summary> - /// 鐗瑰緛鍊兼瘮瀵� - /// </summary> - /// <param name="f1"></param> - /// <param name="f1_len"></param> - /// <param name="f2"></param> - /// <param name="f2_len"></param> - /// <returns></returns> - [DllImport("BaiduFaceApi.dll", EntryPoint = "compare_feature", CharSet = CharSet.Ansi - , CallingConvention = CallingConvention.Cdecl)] - public static extern float compare_feature(byte[] f1, int f1_len, byte[] f2, int f2_len); - // 1:N浜鸿劯璇嗗埆锛堜紶鍥剧墖鏂囦欢璺緞鍜屽簱閲岀殑姣斿锛� - /// <summary> - /// 浜鸿劯璇嗗埆锛屾彁渚�1锛歂鏌ユ壘 (浼犲叆鍥剧墖鏂囦欢璺緞) - /// </summary> - /// <param name="image">鍥剧墖淇℃伅锛屾暟鎹ぇ灏忓皬浜�10M锛屼紶鍏ュ浘鐗囨枃浠惰矾寰�</param> - /// <param name="group_id_list">缁刬d鍒楄〃銆傞粯璁よ嚦灏戝~鍐欎竴涓猤roup_id锛屼粠鎸囧畾鐨刧roup涓繘琛屾煡鎵俱�傞渶瑕佸悓鏃舵煡璇㈠涓猤roup锛岀敤閫楀彿鍒嗛殧锛屼笂闄�10涓�</param> - /// <param name="user_id">鐢ㄦ埛id锛岃嫢鎸囧畾浜嗘煇涓猽ser锛屽垯鍙細涓庢寚瀹歡roup涓嬬殑杩欎釜user杩涜瀵规瘮锛涜嫢user_id浼犵┖瀛楃涓测�� 鈥濓紝鍒欎細涓庢group涓嬬殑鎵�鏈塽ser杩涜1锛歂璇嗗埆</param> - /// <param name="user_top_num">璇嗗埆鍚庤繑鍥炵殑鐢ㄦ埛top鏁帮紝榛樿涓�1锛屾渶澶氳繑鍥�50涓粨鏋�</param> - /// <returns></returns> - [DllImport("BaiduFaceApi.dll", EntryPoint = "identify", CharSet = CharSet.Ansi - , CallingConvention = CallingConvention.Cdecl)] - public static extern IntPtr identify(string image, string group_id_list, string user_id, int user_top_num = 1); - // 1:N浜鸿劯璇嗗埆锛堜紶鍥剧墖浜岃繘鍒舵枃浠禸uffer鍜屽簱閲岀殑姣斿锛� - /// <summary> - /// 浜鸿劯璇嗗埆锛屾彁渚�1锛歂鏌ユ壘 (浼犲叆浜岃繘鍒跺浘鐗嘼uffer锛� - /// </summary> - /// <param name="buf">浜岃繘鍒跺浘鐗囦俊鎭紝鏁版嵁澶у皬灏忎簬10M</param> - /// <param name="size">鍥剧墖澶у皬</param> - /// <param name="group_id_list">缁刬d鍒楄〃銆傞粯璁よ嚦灏戝~鍐欎竴涓猤roup_id锛屼粠鎸囧畾鐨刧roup涓繘琛屾煡鎵俱�傞渶瑕佸悓鏃舵煡璇㈠涓猤roup锛岀敤閫楀彿鍒嗛殧锛屼笂闄�10涓�</param> - /// <param name="user_id">鐢ㄦ埛id锛岃嫢鎸囧畾浜嗘煇涓猽ser锛屽垯鍙細涓庢寚瀹歡roup涓嬬殑杩欎釜user杩涜瀵规瘮锛涜嫢user_id浼犵┖瀛楃涓测�� 鈥濓紝鍒欎細涓庢group涓嬬殑鎵�鏈塽ser杩涜1锛歂璇嗗埆</param> - /// <param name="user_top_num">璇嗗埆鍚庤繑鍥炵殑鐢ㄦ埛top鏁帮紝榛樿涓�1锛屾渶澶氳繑鍥�50涓粨鏋�</param> - /// <returns></returns> - [DllImport("BaiduFaceApi.dll", EntryPoint = "identify_by_buf", CharSet = CharSet.Ansi - , CallingConvention = CallingConvention.Cdecl)] - public static extern IntPtr identify_by_buf(byte[] buf, int size, string group_id_list, - string user_id, int user_top_num = 1); - // 1:N浜鸿劯璇嗗埆锛堜紶浜鸿劯鐗瑰緛鍊煎拰搴撻噷鐨勬瘮瀵癸級 - /// <summary> - /// 1:N浜鸿劯璇嗗埆锛堜紶浜鸿劯鐗瑰緛鍊煎拰搴撻噷鐨勬瘮瀵癸級 - /// </summary> - /// <param name="feature"></param> - /// <param name="fea_len"></param> - /// <param name="group_id_list">缁刬d鍒楄〃銆傞粯璁よ嚦灏戝~鍐欎竴涓猤roup_id锛屼粠鎸囧畾鐨刧roup涓繘琛屾煡鎵俱�傞渶瑕佸悓鏃舵煡璇㈠涓猤roup锛岀敤閫楀彿鍒嗛殧锛屼笂闄�10涓�</param> - /// <param name="user_id">鐢ㄦ埛id锛岃嫢鎸囧畾浜嗘煇涓猽ser锛屽垯鍙細涓庢寚瀹歡roup涓嬬殑杩欎釜user杩涜瀵规瘮锛涜嫢user_id浼犵┖瀛楃涓测�� 鈥濓紝鍒欎細涓庢group涓嬬殑鎵�鏈塽ser杩涜1锛歂璇嗗埆</param> - /// <param name="user_top_num">璇嗗埆鍚庤繑鍥炵殑鐢ㄦ埛top鏁帮紝榛樿涓�1锛屾渶澶氳繑鍥�50涓粨鏋�</param> - /// <returns></returns> - [DllImport("BaiduFaceApi.dll", EntryPoint = "identify_by_feature", CharSet = CharSet.Ansi - , CallingConvention = CallingConvention.Cdecl)] - public static extern IntPtr identify_by_feature(byte[] feature, int fea_len, string group_id_list, - string user_id, int user_top_num = 1); +//// 浜鸿劯姣斿锛堝娉細浜鸿劯姣斿锛屽疄闄呬笂鏄汉鑴哥殑鐗瑰緛鍊兼瘮瀵癸紝鎻愬彇鍑轰汉鑴哥壒寰佸�硷紝鐢╟ompare_feature鏂规硶姣斿) +//namespace FaceAI +//{ +// // 浜鸿劯姣旇緝1:1銆�1:N銆佹娊鍙栦汉鑴哥壒寰佸�笺�佹寜鐗瑰緛鍊兼瘮杈冪瓑 +// public class FaceCompare +// { +// // 鎻愬彇浜鸿劯鐗瑰緛鍊�(浼犲浘鐗囨枃浠惰矾寰�) +// /// <summary> +// /// 鎻愬彇浜鸿劯鐗瑰緛鍊硷紝涓�512涓诞鐐瑰�硷紝宸插姞瀵� +// /// </summary> +// /// <param name="file_name">鍥剧墖淇℃伅锛屾暟鎹ぇ灏忓皬浜�10M锛屼紶鍏ュ浘鐗囨枃浠惰矾寰�</param> +// /// <param name="length">閫氳繃寮曠敤杩斿洖鐗瑰緛鍊肩殑闀垮害锛岃嫢涓�2048琛ㄧず鎻愬彇姝g‘锛屽叾浠栧�艰〃绀烘彁鍙栦簡閿欒鐨勭壒寰佸��</param> +// /// <returns></returns> +// [DllImport("BaiduFaceApi.dll", EntryPoint = "get_face_feature", CharSet = CharSet.Ansi +// , CallingConvention = CallingConvention.Cdecl)] +// public static extern IntPtr get_face_feature(string file_name, ref int length); +// // 鎻愬彇浜鸿劯鐗瑰緛鍊�(浼犱簩杩涘埗鍥剧墖buffer锛� +// /// <summary> +// /// 鎻愬彇浜鸿劯鐗瑰緛鍊硷紝涓�2048涓猙yte (浼犲叆浜岃繘鍒跺浘鐗嘼uffer) +// /// </summary> +// /// <param name="buf"></param> +// /// <param name="size"></param> +// /// <param name="length"></param> +// /// <returns></returns> +// [DllImport("BaiduFaceApi.dll", EntryPoint = "get_face_feature_by_buf", CharSet = CharSet.Ansi +// , CallingConvention = CallingConvention.Cdecl)] +// public static extern IntPtr get_face_feature_by_buf(byte[] buf, int size, ref int length); +// //// 鑾峰彇浜鸿劯鐗瑰緛鍊硷紙浼犲叆opencv瑙嗛甯у強浜鸿劯淇℃伅锛岄�傚簲浜庡浜鸿劯锛� +// ///// <summary> +// ///// 鑾峰彇浜鸿劯鐗瑰緛鍊硷紙浼犲叆opencv瑙嗛甯у強浜鸿劯淇℃伅锛岄�傚簲浜庡浜鸿劯锛� +// ///// </summary> +// ///// <param name="mat"></param> +// ///// <param name="info"></param> +// ///// <param name="feaptr"></param> +// ///// <returns></returns> +// //[DllImport("BaiduFaceApi.dll", EntryPoint = "get_face_feature_by_face", CharSet = CharSet.Ansi +// // , CallingConvention = CallingConvention.Cdecl)] +// //public static extern int get_face_feature_by_face(IntPtr mat, ref TrackFaceInfo info, ref IntPtr feaptr); +// // 浜鸿劯1:1姣斿(浼犲浘鐗囨枃浠惰矾寰�) +// /// <summary> +// /// 浜鸿劯瀵规瘮鎺ュ彛锛堜紶鍏ュ浘鐗囨枃浠惰矾寰勶級 +// /// </summary> +// /// <param name="file_name1">闇�瑕佸姣旂殑绗竴寮犲浘鐗囷紝灏忎簬10M锛屼紶鍏ュ浘鐗囨枃浠惰矾寰�</param> +// /// <param name="file_name2">闇�瑕佸姣旂殑绗簩寮犲浘鐗囷紝灏忎簬10M锛屼紶鍏ュ浘鐗囨枃浠惰矾寰�</param> +// /// <returns></returns> +// [DllImport("BaiduFaceApi.dll", EntryPoint = "match", CharSet = CharSet.Ansi +// , CallingConvention = CallingConvention.Cdecl)] +// public static extern IntPtr match(string file_name1, string file_name2); +// // 浜鸿劯1:1姣斿锛堜紶浜岃繘鍒跺浘鐗嘼uffer锛� +// /// <summary> +// /// 浜鸿劯瀵规瘮鎺ュ彛锛堜紶鍏ヤ簩杩涘埗鍥剧墖buffer锛� +// /// </summary> +// /// <param name="buf1">闇�瑕佸姣旂殑绗竴寮犲浘鐗囷紝灏忎簬10M</param> +// /// <param name="size1">鍥剧墖1鐨勫ぇ灏�</param> +// /// <param name="buf2">闇�瑕佸姣旂殑绗簩寮犲浘鐗囷紝灏忎簬10M</param> +// /// <param name="size2">鍥剧墖2鐨勫ぇ灏�</param> +// /// <returns></returns> +// [DllImport("BaiduFaceApi.dll", EntryPoint = "match_by_buf", CharSet = CharSet.Ansi +// , CallingConvention = CallingConvention.Cdecl)] +// public static extern IntPtr match_by_buf(byte[] buf1, int size1, byte[] buf2, int size2); +// // 浜鸿劯1:1姣斿锛堜紶opencv瑙嗛甯э級 +// /// <summary> +// /// 浜鸿劯1:1姣斿锛堜紶opencv瑙嗛甯э級 +// /// </summary> +// /// <param name="img1"></param> +// /// <param name="img2"></param> +// /// <returns></returns> +// [DllImport("BaiduFaceApi.dll", EntryPoint = "match_by_mat", CharSet = CharSet.Ansi +// , CallingConvention = CallingConvention.Cdecl)] +// public static extern IntPtr match_by_mat(IntPtr img1, IntPtr img2);// byte[] buf1, int size1, byte[] buf2, int size2); +// // 浜鸿劯1:1姣斿锛堜紶浜鸿劯鐗瑰緛鍊煎拰浜岃繘鍒跺浘鐗嘼uffer) +// /// <summary> +// /// 浜鸿劯瀵规瘮鎺ュ彛(浼犲叆浜岃繘鍒跺浘鐗嘼uffer) +// /// </summary> +// /// <param name="feature">鏂囦欢鐗瑰緛</param> +// /// <param name="fea_len"></param> +// /// <param name="buf2"></param> +// /// <param name="size2"></param> +// /// <returns></returns> +// [DllImport("BaiduFaceApi.dll", EntryPoint = "match_by_feature", CharSet = CharSet.Ansi +// , CallingConvention = CallingConvention.Cdecl)] +// public static extern IntPtr match_by_feature(byte[] feature, int fea_len, byte[] buf2, int size2); +// // 鐗瑰緛鍊兼瘮瀵癸紙浼�2涓汉鑴哥殑鐗瑰緛鍊硷級 +// /// <summary> +// /// 鐗瑰緛鍊兼瘮瀵� +// /// </summary> +// /// <param name="f1"></param> +// /// <param name="f1_len"></param> +// /// <param name="f2"></param> +// /// <param name="f2_len"></param> +// /// <returns></returns> +// [DllImport("BaiduFaceApi.dll", EntryPoint = "compare_feature", CharSet = CharSet.Ansi +// , CallingConvention = CallingConvention.Cdecl)] +// public static extern float compare_feature(byte[] f1, int f1_len, byte[] f2, int f2_len); +// // 1:N浜鸿劯璇嗗埆锛堜紶鍥剧墖鏂囦欢璺緞鍜屽簱閲岀殑姣斿锛� +// /// <summary> +// /// 浜鸿劯璇嗗埆锛屾彁渚�1锛歂鏌ユ壘 (浼犲叆鍥剧墖鏂囦欢璺緞) +// /// </summary> +// /// <param name="image">鍥剧墖淇℃伅锛屾暟鎹ぇ灏忓皬浜�10M锛屼紶鍏ュ浘鐗囨枃浠惰矾寰�</param> +// /// <param name="group_id_list">缁刬d鍒楄〃銆傞粯璁よ嚦灏戝~鍐欎竴涓猤roup_id锛屼粠鎸囧畾鐨刧roup涓繘琛屾煡鎵俱�傞渶瑕佸悓鏃舵煡璇㈠涓猤roup锛岀敤閫楀彿鍒嗛殧锛屼笂闄�10涓�</param> +// /// <param name="user_id">鐢ㄦ埛id锛岃嫢鎸囧畾浜嗘煇涓猽ser锛屽垯鍙細涓庢寚瀹歡roup涓嬬殑杩欎釜user杩涜瀵规瘮锛涜嫢user_id浼犵┖瀛楃涓测�� 鈥濓紝鍒欎細涓庢group涓嬬殑鎵�鏈塽ser杩涜1锛歂璇嗗埆</param> +// /// <param name="user_top_num">璇嗗埆鍚庤繑鍥炵殑鐢ㄦ埛top鏁帮紝榛樿涓�1锛屾渶澶氳繑鍥�50涓粨鏋�</param> +// /// <returns></returns> +// [DllImport("BaiduFaceApi.dll", EntryPoint = "identify", CharSet = CharSet.Ansi +// , CallingConvention = CallingConvention.Cdecl)] +// public static extern IntPtr identify(string image, string group_id_list, string user_id, int user_top_num = 1); +// // 1:N浜鸿劯璇嗗埆锛堜紶鍥剧墖浜岃繘鍒舵枃浠禸uffer鍜屽簱閲岀殑姣斿锛� +// /// <summary> +// /// 浜鸿劯璇嗗埆锛屾彁渚�1锛歂鏌ユ壘 (浼犲叆浜岃繘鍒跺浘鐗嘼uffer锛� +// /// </summary> +// /// <param name="buf">浜岃繘鍒跺浘鐗囦俊鎭紝鏁版嵁澶у皬灏忎簬10M</param> +// /// <param name="size">鍥剧墖澶у皬</param> +// /// <param name="group_id_list">缁刬d鍒楄〃銆傞粯璁よ嚦灏戝~鍐欎竴涓猤roup_id锛屼粠鎸囧畾鐨刧roup涓繘琛屾煡鎵俱�傞渶瑕佸悓鏃舵煡璇㈠涓猤roup锛岀敤閫楀彿鍒嗛殧锛屼笂闄�10涓�</param> +// /// <param name="user_id">鐢ㄦ埛id锛岃嫢鎸囧畾浜嗘煇涓猽ser锛屽垯鍙細涓庢寚瀹歡roup涓嬬殑杩欎釜user杩涜瀵规瘮锛涜嫢user_id浼犵┖瀛楃涓测�� 鈥濓紝鍒欎細涓庢group涓嬬殑鎵�鏈塽ser杩涜1锛歂璇嗗埆</param> +// /// <param name="user_top_num">璇嗗埆鍚庤繑鍥炵殑鐢ㄦ埛top鏁帮紝榛樿涓�1锛屾渶澶氳繑鍥�50涓粨鏋�</param> +// /// <returns></returns> +// [DllImport("BaiduFaceApi.dll", EntryPoint = "identify_by_buf", CharSet = CharSet.Ansi +// , CallingConvention = CallingConvention.Cdecl)] +// public static extern IntPtr identify_by_buf(byte[] buf, int size, string group_id_list, +// string user_id, int user_top_num = 1); +// // 1:N浜鸿劯璇嗗埆锛堜紶浜鸿劯鐗瑰緛鍊煎拰搴撻噷鐨勬瘮瀵癸級 +// /// <summary> +// /// 1:N浜鸿劯璇嗗埆锛堜紶浜鸿劯鐗瑰緛鍊煎拰搴撻噷鐨勬瘮瀵癸級 +// /// </summary> +// /// <param name="feature"></param> +// /// <param name="fea_len"></param> +// /// <param name="group_id_list">缁刬d鍒楄〃銆傞粯璁よ嚦灏戝~鍐欎竴涓猤roup_id锛屼粠鎸囧畾鐨刧roup涓繘琛屾煡鎵俱�傞渶瑕佸悓鏃舵煡璇㈠涓猤roup锛岀敤閫楀彿鍒嗛殧锛屼笂闄�10涓�</param> +// /// <param name="user_id">鐢ㄦ埛id锛岃嫢鎸囧畾浜嗘煇涓猽ser锛屽垯鍙細涓庢寚瀹歡roup涓嬬殑杩欎釜user杩涜瀵规瘮锛涜嫢user_id浼犵┖瀛楃涓测�� 鈥濓紝鍒欎細涓庢group涓嬬殑鎵�鏈塽ser杩涜1锛歂璇嗗埆</param> +// /// <param name="user_top_num">璇嗗埆鍚庤繑鍥炵殑鐢ㄦ埛top鏁帮紝榛樿涓�1锛屾渶澶氳繑鍥�50涓粨鏋�</param> +// /// <returns></returns> +// [DllImport("BaiduFaceApi.dll", EntryPoint = "identify_by_feature", CharSet = CharSet.Ansi +// , CallingConvention = CallingConvention.Cdecl)] +// public static extern IntPtr identify_by_feature(byte[] feature, int fea_len, string group_id_list, +// string user_id, int user_top_num = 1); - // 鎻愬墠鍔犺浇搴撻噷鎵�鏈夋暟鎹埌鍐呭瓨涓� - /// <summary> - /// 鎻愬墠鍔犺浇搴撻噷鎵�鏈夋暟鎹埌鍐呭瓨涓� - /// </summary> - /// <returns></returns> - [DllImport("BaiduFaceApi.dll", EntryPoint = "load_db_face", CharSet = CharSet.Ansi - , CallingConvention = CallingConvention.Cdecl)] - public static extern bool load_db_face(); +// // 鎻愬墠鍔犺浇搴撻噷鎵�鏈夋暟鎹埌鍐呭瓨涓� +// /// <summary> +// /// 鎻愬墠鍔犺浇搴撻噷鎵�鏈夋暟鎹埌鍐呭瓨涓� +// /// </summary> +// /// <returns></returns> +// [DllImport("BaiduFaceApi.dll", EntryPoint = "load_db_face", CharSet = CharSet.Ansi +// , CallingConvention = CallingConvention.Cdecl)] +// public static extern bool load_db_face(); - // 1:N浜鸿劯璇嗗埆锛堜紶浜鸿劯鍥剧墖鏂囦欢鍜屽唴瀛樺凡鍔犺浇鐨勬暣涓簱鏁版嵁姣斿锛� - /// <summary> - /// 1:N浜鸿劯璇嗗埆锛堜紶浜鸿劯鍥剧墖鏂囦欢鍜屽唴瀛樺凡鍔犺浇鐨勬暣涓簱鏁版嵁姣斿锛� - /// </summary> - /// <param name="image"></param> - /// <param name="user_top_num"></param> - /// <returns></returns> - [DllImport("BaiduFaceApi.dll", EntryPoint = "identify_with_all", CharSet = CharSet.Ansi - , CallingConvention = CallingConvention.Cdecl)] - public static extern IntPtr identify_with_all(string image, int user_top_num = 1); +// // 1:N浜鸿劯璇嗗埆锛堜紶浜鸿劯鍥剧墖鏂囦欢鍜屽唴瀛樺凡鍔犺浇鐨勬暣涓簱鏁版嵁姣斿锛� +// /// <summary> +// /// 1:N浜鸿劯璇嗗埆锛堜紶浜鸿劯鍥剧墖鏂囦欢鍜屽唴瀛樺凡鍔犺浇鐨勬暣涓簱鏁版嵁姣斿锛� +// /// </summary> +// /// <param name="image"></param> +// /// <param name="user_top_num"></param> +// /// <returns></returns> +// [DllImport("BaiduFaceApi.dll", EntryPoint = "identify_with_all", CharSet = CharSet.Ansi +// , CallingConvention = CallingConvention.Cdecl)] +// public static extern IntPtr identify_with_all(string image, int user_top_num = 1); - // 1:N浜鸿劯璇嗗埆锛堜紶浜鸿劯鍥剧墖鏂囦欢鍜屽唴瀛樺凡鍔犺浇鐨勬暣涓簱鏁版嵁姣斿锛� - /// <summary> - /// - /// </summary> - /// <param name="image">鍥剧墖鐨勪簩杩涘埗鏂囦欢</param> - /// <param name="size"></param> - /// <param name="user_top_num"></param> - /// <returns></returns> - [DllImport("BaiduFaceApi.dll", EntryPoint = "identify_by_buf_with_all", CharSet = CharSet.Ansi - , CallingConvention = CallingConvention.Cdecl)] - public static extern IntPtr identify_by_buf_with_all(byte[] image, int size, int user_top_num = 1); +// // 1:N浜鸿劯璇嗗埆锛堜紶浜鸿劯鍥剧墖鏂囦欢鍜屽唴瀛樺凡鍔犺浇鐨勬暣涓簱鏁版嵁姣斿锛� +// /// <summary> +// /// +// /// </summary> +// /// <param name="image">鍥剧墖鐨勪簩杩涘埗鏂囦欢</param> +// /// <param name="size"></param> +// /// <param name="user_top_num"></param> +// /// <returns></returns> +// [DllImport("BaiduFaceApi.dll", EntryPoint = "identify_by_buf_with_all", CharSet = CharSet.Ansi +// , CallingConvention = CallingConvention.Cdecl)] +// public static extern IntPtr identify_by_buf_with_all(byte[] image, int size, int user_top_num = 1); - // 1:N浜鸿劯璇嗗埆锛堜紶浜鸿劯鐗瑰緛鍊煎拰鍐呭瓨宸插姞杞界殑鏁翠釜搴撴暟鎹瘮瀵癸級 - /// <summary> - /// 1:N浜鸿劯璇嗗埆锛堜紶浜鸿劯鐗瑰緛鍊煎拰鍐呭瓨宸插姞杞界殑鏁翠釜搴撴暟鎹瘮瀵癸級 - /// </summary> - /// <param name="feature"></param> - /// <param name="fea_len"></param> - /// <param name="user_top_num"></param> - /// <returns></returns> - [DllImport("BaiduFaceApi.dll", EntryPoint = "identify_by_feature_with_all", CharSet = CharSet.Ansi - , CallingConvention = CallingConvention.Cdecl)] - public static extern IntPtr identify_by_feature_with_all(byte[] feature, int fea_len, int user_top_num = 1); +// // 1:N浜鸿劯璇嗗埆锛堜紶浜鸿劯鐗瑰緛鍊煎拰鍐呭瓨宸插姞杞界殑鏁翠釜搴撴暟鎹瘮瀵癸級 +// /// <summary> +// /// 1:N浜鸿劯璇嗗埆锛堜紶浜鸿劯鐗瑰緛鍊煎拰鍐呭瓨宸插姞杞界殑鏁翠釜搴撴暟鎹瘮瀵癸級 +// /// </summary> +// /// <param name="feature"></param> +// /// <param name="fea_len"></param> +// /// <param name="user_top_num"></param> +// /// <returns></returns> +// [DllImport("BaiduFaceApi.dll", EntryPoint = "identify_by_feature_with_all", CharSet = CharSet.Ansi +// , CallingConvention = CallingConvention.Cdecl)] +// public static extern IntPtr identify_by_feature_with_all(byte[] feature, int fea_len, int user_top_num = 1); - // 娴嬭瘯鑾峰彇浜鸿劯鐗瑰緛鍊�(2048涓猙yte锛� - public void test_get_face_feature() - { - byte[] fea = new byte[2048]; - string file_name = "G:\\Development\\Application\\testface\\img\\beckham\\2.jpg"; - int len = 0; - IntPtr ptr = get_face_feature(file_name, ref len); - if (ptr == IntPtr.Zero) - { - Console.WriteLine("get face feature error"); - } - else - { - if (len == 2048) - { - Console.WriteLine("get face feature success"); - Marshal.Copy(ptr, fea, 0, 2048); - // 鍙繚瀛樼壒寰佸��2048涓瓧鑺傜殑fea鍒版枃浠朵腑 - // FileUtil.byte2file("G:\\Development\\Application\\testface\\img\\beckham\\fea1.txt",fea, 2048); - } - else - { - Console.WriteLine("get face feature error"); - } - } - } - /// <summary> - /// 鑾峰彇浜鸿劯鐗瑰緛鍊�(2048涓猙yte锛� - /// </summary> - /// <param name="fileName"></param> - /// <returns></returns> - public string GetFaceFeature(string fileName) - { - try - { - byte[] fea = new byte[2048]; - string file_name = fileName == null ? fileName : "G:\\Development\\Application\\testface\\img\\beckham\\2.jpg"; - int len = 0; - IntPtr ptr = get_face_feature(file_name, ref len); - if (ptr == IntPtr.Zero) - { - Console.WriteLine("get face feature error"); - return "error"; - } - else - { - if (len == 2048) - { - Console.WriteLine("get face feature success"); - Marshal.Copy(ptr, fea, 0, 2048); - return fea.ToString(); - // 鍙繚瀛樼壒寰佸��2048涓瓧鑺傜殑fea鍒版枃浠朵腑 - // FileUtil.byte2file("G:\\Development\\Application\\testface\\img\\beckham\\fea1.txt",fea, 2048); - } - else - { - Console.WriteLine("get face feature error"); - return "error"; - } - } - } - catch (Exception e) - { - throw e; - } - } - /// <summary> - /// 鑾峰彇浜鸿劯鐗瑰緛鍊� 2048Byte - /// </summary> - /// <param name="file_name">鍥剧墖淇℃伅锛屾暟鎹ぇ灏忓皬浜�10M锛屼紶鍏ュ浘鐗囨枃浠惰矾寰�</param> - /// <param name="length">閫氳繃寮曠敤杩斿洖鐗瑰緛鍊肩殑闀垮害锛岃嫢涓�2048琛ㄧず鎻愬彇姝g‘锛屽叾浠栧�艰〃绀烘彁鍙栦簡閿欒鐨勭壒寰佸��</param> - /// <returns></returns> - public string GetFaceFeature(string file_name, ref int length) - { - byte[] fea = new byte[2048]; - int len = length == 0 ? 0 : length; //defalut=0 - string result = ""; - IntPtr ptr = get_face_feature(file_name, ref len); - if (ptr == IntPtr.Zero) - { - result = ("get face feature error"); - } - else - { - if (len == 2048) - { - result = ("get face feature success"); - Marshal.Copy(ptr, fea, 0, 2048); - // 鍙繚瀛樼壒寰佸��2048涓瓧鑺傜殑fea鍒版枃浠朵腑 - // FileUtil.byte2file("G:\\Development\\Application\\testface\\img\\beckham\\fea1.txt",fea, 2048); - } - else - { - result = ("get face feature error"); - } - } - return result; - } +// // 娴嬭瘯鑾峰彇浜鸿劯鐗瑰緛鍊�(2048涓猙yte锛� +// public void test_get_face_feature() +// { +// byte[] fea = new byte[2048]; +// string file_name = "G:\\Development\\Application\\testface\\img\\beckham\\2.jpg"; +// int len = 0; +// IntPtr ptr = get_face_feature(file_name, ref len); +// if (ptr == IntPtr.Zero) +// { +// Console.WriteLine("get face feature error"); +// } +// else +// { +// if (len == 2048) +// { +// Console.WriteLine("get face feature success"); +// Marshal.Copy(ptr, fea, 0, 2048); +// // 鍙繚瀛樼壒寰佸��2048涓瓧鑺傜殑fea鍒版枃浠朵腑 +// // FileUtil.byte2file("G:\\Development\\Application\\testface\\img\\beckham\\fea1.txt",fea, 2048); +// } +// else +// { +// Console.WriteLine("get face feature error"); +// } +// } +// } +// /// <summary> +// /// 鑾峰彇浜鸿劯鐗瑰緛鍊�(2048涓猙yte锛� +// /// </summary> +// /// <param name="fileName"></param> +// /// <returns></returns> +// public string GetFaceFeature(string fileName) +// { +// try +// { +// byte[] fea = new byte[2048]; +// string file_name = fileName == null ? fileName : "G:\\Development\\Application\\testface\\img\\beckham\\2.jpg"; +// int len = 0; +// IntPtr ptr = get_face_feature(file_name, ref len); +// if (ptr == IntPtr.Zero) +// { +// Console.WriteLine("get face feature error"); +// return "error"; +// } +// else +// { +// if (len == 2048) +// { +// Console.WriteLine("get face feature success"); +// Marshal.Copy(ptr, fea, 0, 2048); +// return fea.ToString(); +// // 鍙繚瀛樼壒寰佸��2048涓瓧鑺傜殑fea鍒版枃浠朵腑 +// // FileUtil.byte2file("G:\\Development\\Application\\testface\\img\\beckham\\fea1.txt",fea, 2048); +// } +// else +// { +// Console.WriteLine("get face feature error"); +// return "error"; +// } +// } +// } +// catch (Exception e) +// { +// throw e; +// } +// } +// /// <summary> +// /// 鑾峰彇浜鸿劯鐗瑰緛鍊� 2048Byte +// /// </summary> +// /// <param name="file_name">鍥剧墖淇℃伅锛屾暟鎹ぇ灏忓皬浜�10M锛屼紶鍏ュ浘鐗囨枃浠惰矾寰�</param> +// /// <param name="length">閫氳繃寮曠敤杩斿洖鐗瑰緛鍊肩殑闀垮害锛岃嫢涓�2048琛ㄧず鎻愬彇姝g‘锛屽叾浠栧�艰〃绀烘彁鍙栦簡閿欒鐨勭壒寰佸��</param> +// /// <returns></returns> +// public string GetFaceFeature(string file_name, ref int length) +// { +// byte[] fea = new byte[2048]; +// int len = length == 0 ? 0 : length; //defalut=0 +// string result = ""; +// IntPtr ptr = get_face_feature(file_name, ref len); +// if (ptr == IntPtr.Zero) +// { +// result = ("get face feature error"); +// } +// else +// { +// if (len == 2048) +// { +// result = ("get face feature success"); +// Marshal.Copy(ptr, fea, 0, 2048); +// // 鍙繚瀛樼壒寰佸��2048涓瓧鑺傜殑fea鍒版枃浠朵腑 +// // FileUtil.byte2file("G:\\Development\\Application\\testface\\img\\beckham\\fea1.txt",fea, 2048); +// } +// else +// { +// result = ("get face feature error"); +// } +// } +// return result; +// } - //// 娴嬭瘯鑾峰彇浜鸿劯鐗瑰緛鍊�(2048涓猙yte锛� - //public void test_get_face_feature_by_buf() - //{ - // byte[] fea = new byte[2048]; - // System.Drawing.Image img = System.Drawing.Image.FromFile("G:\\Development\\Application\\testface\\img\\beckham\\2.jpg"); - // byte[] img_bytes = ImageUtil.img2byte(img); - // int len = 0; - // IntPtr ptr = get_face_feature_by_buf(img_bytes, img_bytes.Length, ref len); - // if (ptr == IntPtr.Zero) - // { - // Console.WriteLine("get face feature error"); - // } - // else - // { - // if (len == 2048) - // { - // Console.WriteLine("get face feature success"); - // Marshal.Copy(ptr, fea, 0, 2048); - // // 鍙繚瀛樼壒寰佸��2048涓瓧鑺傜殑fea鍒版枃浠朵腑 - // // FileUtil.byte2file("G:\\Development\\Application\\testface\\img\\beckham\\fea2.txt",fea, 2048); - // } - // else - // { - // Console.WriteLine("get face feature error"); - // } - // } - //} +// //// 娴嬭瘯鑾峰彇浜鸿劯鐗瑰緛鍊�(2048涓猙yte锛� +// //public void test_get_face_feature_by_buf() +// //{ +// // byte[] fea = new byte[2048]; +// // System.Drawing.Image img = System.Drawing.Image.FromFile("G:\\Development\\Application\\testface\\img\\beckham\\2.jpg"); +// // byte[] img_bytes = ImageUtil.img2byte(img); +// // int len = 0; +// // IntPtr ptr = get_face_feature_by_buf(img_bytes, img_bytes.Length, ref len); +// // if (ptr == IntPtr.Zero) +// // { +// // Console.WriteLine("get face feature error"); +// // } +// // else +// // { +// // if (len == 2048) +// // { +// // Console.WriteLine("get face feature success"); +// // Marshal.Copy(ptr, fea, 0, 2048); +// // // 鍙繚瀛樼壒寰佸��2048涓瓧鑺傜殑fea鍒版枃浠朵腑 +// // // FileUtil.byte2file("G:\\Development\\Application\\testface\\img\\beckham\\fea2.txt",fea, 2048); +// // } +// // else +// // { +// // Console.WriteLine("get face feature error"); +// // } +// // } +// //} - ///// <summary> - ///// 鑾峰彇浜鸿劯鐗瑰緛鍊� 2048byte - ///// </summary> - ///// <param name="filePath"></param> - ///// <returns></returns> - //public string GetFaceFeatureByBuffer(string filePath) - //{ - // byte[] fea = new byte[2048]; - // string result = ""; - // System.Drawing.Image img = System.Drawing.Image.FromFile(filePath); - // byte[] img_bytes = ImageUtil.img2byte(img); - // int len = 0; - // IntPtr ptr = get_face_feature_by_buf(img_bytes, img_bytes.Length, ref len); - // if (ptr == IntPtr.Zero) - // { - // result = ("get face feature error"); - // } - // else - // { - // if (len == 2048) - // { - // result = ("get face feature success"); - // Marshal.Copy(ptr, fea, 0, 2048); - // // 鍙繚瀛樼壒寰佸��2048涓瓧鑺傜殑fea鍒版枃浠朵腑 - // // FileUtil.byte2file("G:\\Development\\Application\\testface\\img\\beckham\\fea2.txt",fea, 2048); - // } - // else - // { - // result = ("get face feature error"); - // } - // } - // return result; - //} +// ///// <summary> +// ///// 鑾峰彇浜鸿劯鐗瑰緛鍊� 2048byte +// ///// </summary> +// ///// <param name="filePath"></param> +// ///// <returns></returns> +// //public string GetFaceFeatureByBuffer(string filePath) +// //{ +// // byte[] fea = new byte[2048]; +// // string result = ""; +// // System.Drawing.Image img = System.Drawing.Image.FromFile(filePath); +// // byte[] img_bytes = ImageUtil.img2byte(img); +// // int len = 0; +// // IntPtr ptr = get_face_feature_by_buf(img_bytes, img_bytes.Length, ref len); +// // if (ptr == IntPtr.Zero) +// // { +// // result = ("get face feature error"); +// // } +// // else +// // { +// // if (len == 2048) +// // { +// // result = ("get face feature success"); +// // Marshal.Copy(ptr, fea, 0, 2048); +// // // 鍙繚瀛樼壒寰佸��2048涓瓧鑺傜殑fea鍒版枃浠朵腑 +// // // FileUtil.byte2file("G:\\Development\\Application\\testface\\img\\beckham\\fea2.txt",fea, 2048); +// // } +// // else +// // { +// // result = ("get face feature error"); +// // } +// // } +// // return result; +// //} - // 娴嬭瘯1:1姣旇緝锛屼紶鍏ュ浘鐗囨枃浠惰矾寰� - public void test_match() - { - string file1 = "G:\\Development\\Application\\testface\\img\\beckham\\1.jpg"; - string file2 = "G:\\Development\\Application\\testface\\img\\beckham\\9.jpg"; - IntPtr ptr = match(file1, file2); - string buf = Marshal.PtrToStringAnsi(ptr); - Console.WriteLine("match res is:" + buf); - } - /// <summary> - /// 1:1姣旇緝 浼犲叆鍥剧墖鏂囦欢璺緞 - /// </summary> - /// <param name="file1"></param> - /// <param name="file2"></param> - /// <returns></returns> - public string FaceMatch(string file1, string file2) - { - IntPtr ptr = match(file1, file2); - string buf = Marshal.PtrToStringAnsi(ptr); - Console.WriteLine("match res is:" + buf); - return buf; - } - // 娴嬭瘯1:1姣旇緝锛屼紶鍏ュ浘鐗囨枃浠朵簩杩涘埗buffer - //public void test_match_by_buf() - //{ - // System.Drawing.Image img1 = System.Drawing.Image.FromFile("d:\\444.bmp"); - // byte[] img_bytes1 = ImageUtil.img2byte(img1); +// // 娴嬭瘯1:1姣旇緝锛屼紶鍏ュ浘鐗囨枃浠惰矾寰� +// public void test_match() +// { +// string file1 = "G:\\Development\\Application\\testface\\img\\beckham\\1.jpg"; +// string file2 = "G:\\Development\\Application\\testface\\img\\beckham\\9.jpg"; +// IntPtr ptr = match(file1, file2); +// string buf = Marshal.PtrToStringAnsi(ptr); +// Console.WriteLine("match res is:" + buf); +// } +// /// <summary> +// /// 1:1姣旇緝 浼犲叆鍥剧墖鏂囦欢璺緞 +// /// </summary> +// /// <param name="file1"></param> +// /// <param name="file2"></param> +// /// <returns></returns> +// public string FaceMatch(string file1, string file2) +// { +// IntPtr ptr = match(file1, file2); +// string buf = Marshal.PtrToStringAnsi(ptr); +// Console.WriteLine("match res is:" + buf); +// return buf; +// } +// // 娴嬭瘯1:1姣旇緝锛屼紶鍏ュ浘鐗囨枃浠朵簩杩涘埗buffer +// //public void test_match_by_buf() +// //{ +// // System.Drawing.Image img1 = System.Drawing.Image.FromFile("d:\\444.bmp"); +// // byte[] img_bytes1 = ImageUtil.img2byte(img1); - // System.Drawing.Image img2 = System.Drawing.Image.FromFile("d:\\555.png"); - // byte[] img_bytes2 = ImageUtil.img2byte(img2); - // Console.WriteLine("IntPtr ptr = match_by_buf"); - // IntPtr ptr = match_by_buf(img_bytes1, img_bytes1.Length, img_bytes2, img_bytes2.Length); - // string buf = Marshal.PtrToStringAnsi(ptr); - // Console.WriteLine("match_by_buf res is:" + buf); - //} - /// <summary> - /// 1:1姣旇緝 浼犲浘鐗囦簩杩涘埗Buffer - /// </summary> - /// <param name="file1"></param> - /// <param name="file2"></param> - /// <returns></returns> - public string FaceMatchByBuffer(byte[] file1, byte[] file2) - { - // System.Drawing.Image img1 = System.Drawing.Image.FromFile(file1); - byte[] img_bytes1 = file1; // ImageUtil.img2byte(img1); +// // System.Drawing.Image img2 = System.Drawing.Image.FromFile("d:\\555.png"); +// // byte[] img_bytes2 = ImageUtil.img2byte(img2); +// // Console.WriteLine("IntPtr ptr = match_by_buf"); +// // IntPtr ptr = match_by_buf(img_bytes1, img_bytes1.Length, img_bytes2, img_bytes2.Length); +// // string buf = Marshal.PtrToStringAnsi(ptr); +// // Console.WriteLine("match_by_buf res is:" + buf); +// //} +// /// <summary> +// /// 1:1姣旇緝 浼犲浘鐗囦簩杩涘埗Buffer +// /// </summary> +// /// <param name="file1"></param> +// /// <param name="file2"></param> +// /// <returns></returns> +// public string FaceMatchByBuffer(byte[] file1, byte[] file2) +// { +// // System.Drawing.Image img1 = System.Drawing.Image.FromFile(file1); +// byte[] img_bytes1 = file1; // ImageUtil.img2byte(img1); - // System.Drawing.Image img2 = System.Drawing.Image.FromFile(file2); - byte[] img_bytes2 = file2; // ImageUtil.img2byte(img2); - Console.WriteLine("IntPtr ptr = match_by_buf"); - IntPtr ptr = match_by_buf(img_bytes1, img_bytes1.Length, img_bytes2, img_bytes2.Length); - string buf = Marshal.PtrToStringAnsi(ptr); - return ("match_by_buf res is:" + buf); - } - // 娴嬭瘯1:1姣旇緝锛屼紶鍏pencv瑙嗛甯� - public void test_match_by_mat() - { - Mat img1 = Cv2.ImRead("d:\\444.bmp"); - Mat img2 = Cv2.ImRead("d:\\555.png"); - IntPtr ptr = match_by_mat(img1.CvPtr, img2.CvPtr);// img_bytes1, img_bytes1.Length, img_bytes2, img_bytes2.Length); - string buf = Marshal.PtrToStringAnsi(ptr); - Console.WriteLine("match_by_buf res is:" + buf); - } - /// <summary> - /// 1:1姣旇緝锛屼紶鍏pencv瑙嗛甯� - /// </summary> - /// <param name="file1"></param> - /// <param name="file2"></param> - /// <returns></returns> - public string FaceMatchByMat(string file1, string file2) - { - Mat img1 = Cv2.ImRead(file1); - Mat img2 = Cv2.ImRead(file2); - IntPtr ptr = match_by_mat(img1.CvPtr, img2.CvPtr);// img_bytes1, img_bytes1.Length, img_bytes2, img_bytes2.Length); - string buf = Marshal.PtrToStringAnsi(ptr); - return ("match_by_buf res is:" + buf); +// // System.Drawing.Image img2 = System.Drawing.Image.FromFile(file2); +// byte[] img_bytes2 = file2; // ImageUtil.img2byte(img2); +// Console.WriteLine("IntPtr ptr = match_by_buf"); +// IntPtr ptr = match_by_buf(img_bytes1, img_bytes1.Length, img_bytes2, img_bytes2.Length); +// string buf = Marshal.PtrToStringAnsi(ptr); +// return ("match_by_buf res is:" + buf); +// } +// // 娴嬭瘯1:1姣旇緝锛屼紶鍏pencv瑙嗛甯� +// public void test_match_by_mat() +// { +// Mat img1 = Cv2.ImRead("d:\\444.bmp"); +// Mat img2 = Cv2.ImRead("d:\\555.png"); +// IntPtr ptr = match_by_mat(img1.CvPtr, img2.CvPtr);// img_bytes1, img_bytes1.Length, img_bytes2, img_bytes2.Length); +// string buf = Marshal.PtrToStringAnsi(ptr); +// Console.WriteLine("match_by_buf res is:" + buf); +// } +// /// <summary> +// /// 1:1姣旇緝锛屼紶鍏pencv瑙嗛甯� +// /// </summary> +// /// <param name="file1"></param> +// /// <param name="file2"></param> +// /// <returns></returns> +// public string FaceMatchByMat(string file1, string file2) +// { +// Mat img1 = Cv2.ImRead(file1); +// Mat img2 = Cv2.ImRead(file2); +// IntPtr ptr = match_by_mat(img1.CvPtr, img2.CvPtr);// img_bytes1, img_bytes1.Length, img_bytes2, img_bytes2.Length); +// string buf = Marshal.PtrToStringAnsi(ptr); +// return ("match_by_buf res is:" + buf); - } - // 娴嬭瘯鏍规嵁鐗瑰緛鍊煎拰鍥剧墖浜岃繘鍒禸uf姣旇緝 - //public void test_match_by_feature() - //{ - // // 鑾峰彇鐗瑰緛鍊�2048涓瓧鑺� - // byte[] fea = new byte[2048]; - // string file_name = "G:\\Development\\Application\\testface\\img\\beckham\\2.jpg"; - // int len = 0; - // IntPtr ptr = get_face_feature(file_name, ref len); - // if (len != 2048) - // { - // Console.WriteLine("get face feature error!"); - // return; - // } - // Marshal.Copy(ptr, fea, 0, 2048); - // // 鑾峰彇鍥剧墖浜岃繘鍒禸uffer - // System.Drawing.Image img2 = System.Drawing.Image.FromFile("G:\\Development\\Application\\testface\\img\\beckham\\8.jpg"); - // byte[] img_bytes2 = ImageUtil.img2byte(img2); +// } +// // 娴嬭瘯鏍规嵁鐗瑰緛鍊煎拰鍥剧墖浜岃繘鍒禸uf姣旇緝 +// //public void test_match_by_feature() +// //{ +// // // 鑾峰彇鐗瑰緛鍊�2048涓瓧鑺� +// // byte[] fea = new byte[2048]; +// // string file_name = "G:\\Development\\Application\\testface\\img\\beckham\\2.jpg"; +// // int len = 0; +// // IntPtr ptr = get_face_feature(file_name, ref len); +// // if (len != 2048) +// // { +// // Console.WriteLine("get face feature error!"); +// // return; +// // } +// // Marshal.Copy(ptr, fea, 0, 2048); +// // // 鑾峰彇鍥剧墖浜岃繘鍒禸uffer +// // System.Drawing.Image img2 = System.Drawing.Image.FromFile("G:\\Development\\Application\\testface\\img\\beckham\\8.jpg"); +// // byte[] img_bytes2 = ImageUtil.img2byte(img2); - // IntPtr ptr_res = match_by_feature(fea, fea.Length, img_bytes2, img_bytes2.Length); - // string buf = Marshal.PtrToStringAnsi(ptr_res); - // Console.WriteLine("match_by_feature res is:" + buf); +// // IntPtr ptr_res = match_by_feature(fea, fea.Length, img_bytes2, img_bytes2.Length); +// // string buf = Marshal.PtrToStringAnsi(ptr_res); +// // Console.WriteLine("match_by_feature res is:" + buf); - //} - /// <summary> - /// 鏍规嵁鐗瑰緛鍊煎拰鍥剧墖浜岃繘鍒禸uf姣旇緝 - /// </summary> - /// <param name="file_name">闇�瑕佸姣旂殑鐗瑰緛鍊�</param> - /// <param name="file_buffer">闇�瑕佸姣旂殑绗簩寮犲浘鐗囷紝灏忎簬10M</param> - /// <returns></returns> - public string FaceMatchByFeature(byte[] file_name, byte[] file_buffer) - { - // 鑾峰彇鐗瑰緛鍊�2048涓瓧鑺� - byte[] fea = file_name; // new byte[2048]; - //int len = 0; - //IntPtr ptr = get_face_feature(file_name, ref len); - //if (len != 2048) - //{ - // return ("get face feature error!"); - //} - //Marshal.Copy(ptr, fea, 0, 2048); - //// 鑾峰彇鍥剧墖浜岃繘鍒禸uffer - //System.Drawing.Image img2 = System.Drawing.Image.FromFile(file_buffer); - byte[] img_bytes2 = file_buffer; // ImageUtil.img2byte(img2); +// //} +// /// <summary> +// /// 鏍规嵁鐗瑰緛鍊煎拰鍥剧墖浜岃繘鍒禸uf姣旇緝 +// /// </summary> +// /// <param name="file_name">闇�瑕佸姣旂殑鐗瑰緛鍊�</param> +// /// <param name="file_buffer">闇�瑕佸姣旂殑绗簩寮犲浘鐗囷紝灏忎簬10M</param> +// /// <returns></returns> +// public string FaceMatchByFeature(byte[] file_name, byte[] file_buffer) +// { +// // 鑾峰彇鐗瑰緛鍊�2048涓瓧鑺� +// byte[] fea = file_name; // new byte[2048]; +// //int len = 0; +// //IntPtr ptr = get_face_feature(file_name, ref len); +// //if (len != 2048) +// //{ +// // return ("get face feature error!"); +// //} +// //Marshal.Copy(ptr, fea, 0, 2048); +// //// 鑾峰彇鍥剧墖浜岃繘鍒禸uffer +// //System.Drawing.Image img2 = System.Drawing.Image.FromFile(file_buffer); +// byte[] img_bytes2 = file_buffer; // ImageUtil.img2byte(img2); - IntPtr ptr_res = match_by_feature(fea, fea.Length, img_bytes2, img_bytes2.Length); - string buf = Marshal.PtrToStringAnsi(ptr_res); - Console.WriteLine("match_by_feature res is:" + buf); - return buf; +// IntPtr ptr_res = match_by_feature(fea, fea.Length, img_bytes2, img_bytes2.Length); +// string buf = Marshal.PtrToStringAnsi(ptr_res); +// Console.WriteLine("match_by_feature res is:" + buf); +// return buf; - } +// } - // 娴嬭瘯1:N姣旇緝锛屼紶鍏ュ浘鐗囨枃浠惰矾寰� - public /*void*/string test_identify(string str, string usr_grp, string usr_id) - { - string file1 = str;//"G:\\Development\\Application\\testface\\img\\beckham\\6.jpg"; - string user_group = usr_grp;//"test_group"; - string user_id = usr_id;//"test_user"; - IntPtr ptr = identify(file1, user_group, user_id); - string buf = Marshal.PtrToStringAnsi(ptr); - Console.WriteLine("identify res is:" + buf); - return buf; - } - /// <summary> - /// 1:N姣旇緝锛屼紶鍏ュ浘鐗囨枃浠惰矾寰� - /// </summary> - /// <param name="file">鍥剧墖淇℃伅锛屾暟鎹ぇ灏忓皬浜�10M锛屼紶鍏ュ浘鐗囨枃浠惰矾寰�</param> - /// <param name="user_group">缁刬d鍒楄〃銆傞粯璁よ嚦灏戝~鍐欎竴涓猤roup_id锛屼粠鎸囧畾鐨刧roup涓繘琛屾煡鎵俱�傞渶瑕佸悓鏃舵煡璇㈠涓猤roup锛岀敤閫楀彿鍒嗛殧锛屼笂闄�10涓�</param> - /// <param name="user_id">鐢ㄦ埛id锛岃嫢鎸囧畾浜嗘煇涓猽ser锛屽垯鍙細涓庢寚瀹歡roup涓嬬殑杩欎釜user杩涜瀵规瘮锛涜嫢user_id浼犵┖瀛楃涓测�� 鈥濓紝鍒欎細涓庢group涓嬬殑鎵�鏈塽ser杩涜1锛歂璇嗗埆</param> - /// <returns></returns> - public static string FaceIdentify(string file, string user_group, string user_id) - { - string file1 = file; - IntPtr ptr = identify(file1, user_group, user_id); - string buf = Marshal.PtrToStringAnsi(ptr); - Console.WriteLine("identify res is:" + buf); - return buf; - } +// // 娴嬭瘯1:N姣旇緝锛屼紶鍏ュ浘鐗囨枃浠惰矾寰� +// public /*void*/string test_identify(string str, string usr_grp, string usr_id) +// { +// string file1 = str;//"G:\\Development\\Application\\testface\\img\\beckham\\6.jpg"; +// string user_group = usr_grp;//"test_group"; +// string user_id = usr_id;//"test_user"; +// IntPtr ptr = identify(file1, user_group, user_id); +// string buf = Marshal.PtrToStringAnsi(ptr); +// Console.WriteLine("identify res is:" + buf); +// return buf; +// } +// /// <summary> +// /// 1:N姣旇緝锛屼紶鍏ュ浘鐗囨枃浠惰矾寰� +// /// </summary> +// /// <param name="file">鍥剧墖淇℃伅锛屾暟鎹ぇ灏忓皬浜�10M锛屼紶鍏ュ浘鐗囨枃浠惰矾寰�</param> +// /// <param name="user_group">缁刬d鍒楄〃銆傞粯璁よ嚦灏戝~鍐欎竴涓猤roup_id锛屼粠鎸囧畾鐨刧roup涓繘琛屾煡鎵俱�傞渶瑕佸悓鏃舵煡璇㈠涓猤roup锛岀敤閫楀彿鍒嗛殧锛屼笂闄�10涓�</param> +// /// <param name="user_id">鐢ㄦ埛id锛岃嫢鎸囧畾浜嗘煇涓猽ser锛屽垯鍙細涓庢寚瀹歡roup涓嬬殑杩欎釜user杩涜瀵规瘮锛涜嫢user_id浼犵┖瀛楃涓测�� 鈥濓紝鍒欎細涓庢group涓嬬殑鎵�鏈塽ser杩涜1锛歂璇嗗埆</param> +// /// <returns></returns> +// public static string FaceIdentify(string file, string user_group, string user_id) +// { +// string file1 = file; +// IntPtr ptr = identify(file1, user_group, user_id); +// string buf = Marshal.PtrToStringAnsi(ptr); +// Console.WriteLine("identify res is:" + buf); +// return buf; +// } - // 娴嬭瘯1:N姣旇緝锛屼紶鍏ュ浘鐗囨枃浠朵簩杩涘埗buffer - //public void test_identify_by_buf(string str, string usr_grp, string usr_id) - //{ - // System.Drawing.Image img = System.Drawing.Image.FromFile(str);//"G:\\Development\\Application\\testface\\img\\beckham\\2.jpg"); - // byte[] img_bytes = ImageUtil.img2byte(img); +// // 娴嬭瘯1:N姣旇緝锛屼紶鍏ュ浘鐗囨枃浠朵簩杩涘埗buffer +// //public void test_identify_by_buf(string str, string usr_grp, string usr_id) +// //{ +// // System.Drawing.Image img = System.Drawing.Image.FromFile(str);//"G:\\Development\\Application\\testface\\img\\beckham\\2.jpg"); +// // byte[] img_bytes = ImageUtil.img2byte(img); - // string user_group = usr_grp;//"test_group"; - // string user_id = usr_id;// "test_user"; - // IntPtr ptr = identify_by_buf(img_bytes, img_bytes.Length, user_group, user_id); - // string buf = Marshal.PtrToStringAnsi(ptr); - // Console.WriteLine("identify_by_buf res is:" + buf); - //} - /// <summary> - /// 1:N姣旇緝锛屼紶鍏ュ浘鐗囨枃浠朵簩杩涘埗buffer - /// </summary> - /// <param name="str">浜岃繘鍒跺浘鐗囦俊鎭紝鏁版嵁澶у皬灏忎簬10M</param> - /// <param name="usr_grp">缁刬d鍒楄〃銆傞粯璁よ嚦灏戝~鍐欎竴涓猤roup_id锛屼粠鎸囧畾鐨刧roup涓繘琛屾煡鎵俱�傞渶瑕佸悓鏃舵煡璇㈠涓猤roup锛岀敤閫楀彿鍒嗛殧锛屼笂闄�10涓�</param> - /// <param name="usr_id">鐢ㄦ埛id锛岃嫢鎸囧畾浜嗘煇涓猽ser锛屽垯鍙細涓庢寚瀹歡roup涓嬬殑杩欎釜user杩涜瀵规瘮锛涜嫢user_id浼犵┖瀛楃涓测�� 鈥濓紝鍒欎細涓庢group涓嬬殑鎵�鏈塽ser杩涜1锛歂璇嗗埆</param> - /// <returns></returns> - public string FaceIdentifyByBuffer(byte[] str, string usr_grp, string usr_id) - { - // System.Drawing.Image img = System.Drawing.Image.FromFile(str); - byte[] img_bytes = str; // ImageUtil.img2byte(img); +// // string user_group = usr_grp;//"test_group"; +// // string user_id = usr_id;// "test_user"; +// // IntPtr ptr = identify_by_buf(img_bytes, img_bytes.Length, user_group, user_id); +// // string buf = Marshal.PtrToStringAnsi(ptr); +// // Console.WriteLine("identify_by_buf res is:" + buf); +// //} +// /// <summary> +// /// 1:N姣旇緝锛屼紶鍏ュ浘鐗囨枃浠朵簩杩涘埗buffer +// /// </summary> +// /// <param name="str">浜岃繘鍒跺浘鐗囦俊鎭紝鏁版嵁澶у皬灏忎簬10M</param> +// /// <param name="usr_grp">缁刬d鍒楄〃銆傞粯璁よ嚦灏戝~鍐欎竴涓猤roup_id锛屼粠鎸囧畾鐨刧roup涓繘琛屾煡鎵俱�傞渶瑕佸悓鏃舵煡璇㈠涓猤roup锛岀敤閫楀彿鍒嗛殧锛屼笂闄�10涓�</param> +// /// <param name="usr_id">鐢ㄦ埛id锛岃嫢鎸囧畾浜嗘煇涓猽ser锛屽垯鍙細涓庢寚瀹歡roup涓嬬殑杩欎釜user杩涜瀵规瘮锛涜嫢user_id浼犵┖瀛楃涓测�� 鈥濓紝鍒欎細涓庢group涓嬬殑鎵�鏈塽ser杩涜1锛歂璇嗗埆</param> +// /// <returns></returns> +// public string FaceIdentifyByBuffer(byte[] str, string usr_grp, string usr_id) +// { +// // System.Drawing.Image img = System.Drawing.Image.FromFile(str); +// byte[] img_bytes = str; // ImageUtil.img2byte(img); - string user_group = usr_grp;//"test_group"; - string user_id = usr_id;// "test_user"; - IntPtr ptr = identify_by_buf(img_bytes, img_bytes.Length, user_group, user_id); - string buf = Marshal.PtrToStringAnsi(ptr); - Console.WriteLine("identify_by_buf res is:" + buf); - return buf; - } +// string user_group = usr_grp;//"test_group"; +// string user_id = usr_id;// "test_user"; +// IntPtr ptr = identify_by_buf(img_bytes, img_bytes.Length, user_group, user_id); +// string buf = Marshal.PtrToStringAnsi(ptr); +// Console.WriteLine("identify_by_buf res is:" + buf); +// return buf; +// } - // 娴嬭瘯1:N姣旇緝锛屼紶鍏ユ彁鍙栫殑浜鸿劯鐗瑰緛鍊� - public void test_identify_by_feature() - { - // 鑾峰彇鐗瑰緛鍊�2048涓瓧鑺� - byte[] fea = new byte[2048]; - string file_name = "G:\\Development\\Application\\testface\\img\\beckham\\2.jpg"; - int len = 0; - IntPtr ptr = get_face_feature(file_name, ref len); - if (len != 2048) - { - Console.WriteLine("get face feature error!"); - return; - } - Marshal.Copy(ptr, fea, 0, 2048); +// // 娴嬭瘯1:N姣旇緝锛屼紶鍏ユ彁鍙栫殑浜鸿劯鐗瑰緛鍊� +// public void test_identify_by_feature() +// { +// // 鑾峰彇鐗瑰緛鍊�2048涓瓧鑺� +// byte[] fea = new byte[2048]; +// string file_name = "G:\\Development\\Application\\testface\\img\\beckham\\2.jpg"; +// int len = 0; +// IntPtr ptr = get_face_feature(file_name, ref len); +// if (len != 2048) +// { +// Console.WriteLine("get face feature error!"); +// return; +// } +// Marshal.Copy(ptr, fea, 0, 2048); - string user_group = "test_group"; - string user_id = "test_user"; - IntPtr ptr_res = identify_by_feature(fea, fea.Length, user_group, user_id); - string buf = Marshal.PtrToStringAnsi(ptr_res); - Console.WriteLine("identify_by_feature res is:" + buf); - } - /// <summary> - /// 1:N姣旇緝锛屼紶鍏ユ彁鍙栫殑浜鸿劯鐗瑰緛鍊� - /// </summary> - /// <param name="file_name">浼犲叆鍥剧墖鐗瑰緛</param> - /// <param name="userGroup">缁刬d鍒楄〃銆傞粯璁よ嚦灏戝~鍐欎竴涓猤roup_id锛屼粠鎸囧畾鐨刧roup涓繘琛屾煡鎵俱�傞渶瑕佸悓鏃舵煡璇㈠涓猤roup锛岀敤閫楀彿鍒嗛殧锛屼笂闄�10涓�</param> - /// <param name="userId">鐢ㄦ埛id锛岃嫢鎸囧畾浜嗘煇涓猽ser锛屽垯鍙細涓庢寚瀹歡roup涓嬬殑杩欎釜user杩涜瀵规瘮锛涜嫢user_id浼犵┖瀛楃涓测�� 鈥濓紝鍒欎細涓庢group涓嬬殑鎵�鏈塽ser杩涜1锛歂璇嗗埆</param> - /// - public static string FaceIdentifyByFeature(string file_name, string userGroup, string userId) - { - // 鑾峰彇鐗瑰緛鍊�2048涓瓧鑺� - byte[] fea = new byte[2048]; - int len = 0; - IntPtr ptr = get_face_feature(file_name, ref len); - if (len != 2048) - { - return ("get face feature error!"); - } - Marshal.Copy(ptr, fea, 0, 2048); +// string user_group = "test_group"; +// string user_id = "test_user"; +// IntPtr ptr_res = identify_by_feature(fea, fea.Length, user_group, user_id); +// string buf = Marshal.PtrToStringAnsi(ptr_res); +// Console.WriteLine("identify_by_feature res is:" + buf); +// } +// /// <summary> +// /// 1:N姣旇緝锛屼紶鍏ユ彁鍙栫殑浜鸿劯鐗瑰緛鍊� +// /// </summary> +// /// <param name="file_name">浼犲叆鍥剧墖鐗瑰緛</param> +// /// <param name="userGroup">缁刬d鍒楄〃銆傞粯璁よ嚦灏戝~鍐欎竴涓猤roup_id锛屼粠鎸囧畾鐨刧roup涓繘琛屾煡鎵俱�傞渶瑕佸悓鏃舵煡璇㈠涓猤roup锛岀敤閫楀彿鍒嗛殧锛屼笂闄�10涓�</param> +// /// <param name="userId">鐢ㄦ埛id锛岃嫢鎸囧畾浜嗘煇涓猽ser锛屽垯鍙細涓庢寚瀹歡roup涓嬬殑杩欎釜user杩涜瀵规瘮锛涜嫢user_id浼犵┖瀛楃涓测�� 鈥濓紝鍒欎細涓庢group涓嬬殑鎵�鏈塽ser杩涜1锛歂璇嗗埆</param> +// /// +// public static string FaceIdentifyByFeature(string file_name, string userGroup, string userId) +// { +// // 鑾峰彇鐗瑰緛鍊�2048涓瓧鑺� +// byte[] fea = new byte[2048]; +// int len = 0; +// IntPtr ptr = get_face_feature(file_name, ref len); +// if (len != 2048) +// { +// return ("get face feature error!"); +// } +// Marshal.Copy(ptr, fea, 0, 2048); - string user_group = userGroup == null ? "test_group" : userGroup; - string user_id = userId == null ? "test_user" : userId; - IntPtr ptr_res = identify_by_feature(fea, fea.Length, user_group, user_id); - string buf = Marshal.PtrToStringAnsi(ptr_res); - Console.WriteLine("identify_by_feature res is:" + buf); - return buf; - } +// string user_group = userGroup == null ? "test_group" : userGroup; +// string user_id = userId == null ? "test_user" : userId; +// IntPtr ptr_res = identify_by_feature(fea, fea.Length, user_group, user_id); +// string buf = Marshal.PtrToStringAnsi(ptr_res); +// Console.WriteLine("identify_by_feature res is:" + buf); +// return buf; +// } - // 閫氳繃鐗瑰緛鍊兼瘮瀵癸紙1:1锛� - public void test_compare_feature() - { - // 鑾峰彇鐗瑰緛鍊�1 鍏�2048涓瓧鑺� - byte[] fea1 = new byte[2048]; - string file_name1 = "G:\\Development\\Application\\testface\\img\\beckham\\2.jpg"; - int len1 = 0; - IntPtr ptr1 = get_face_feature(file_name1, ref len1); - if (len1 != 2048) - { - Console.WriteLine("get face feature error!"); - return; - } - Marshal.Copy(ptr1, fea1, 0, 2048); +// // 閫氳繃鐗瑰緛鍊兼瘮瀵癸紙1:1锛� +// public void test_compare_feature() +// { +// // 鑾峰彇鐗瑰緛鍊�1 鍏�2048涓瓧鑺� +// byte[] fea1 = new byte[2048]; +// string file_name1 = "G:\\Development\\Application\\testface\\img\\beckham\\2.jpg"; +// int len1 = 0; +// IntPtr ptr1 = get_face_feature(file_name1, ref len1); +// if (len1 != 2048) +// { +// Console.WriteLine("get face feature error!"); +// return; +// } +// Marshal.Copy(ptr1, fea1, 0, 2048); - // 鑾峰彇鐗瑰緛鍊�2 鍏�2048涓瓧鑺� - byte[] fea2 = new byte[2048]; - string file_name2 = "G:\\Development\\Application\\testface\\img\\beckham\\8.jpg"; - int len2 = 0; - IntPtr ptr2 = get_face_feature(file_name2, ref len2); - if (len2 != 2048) - { - Console.WriteLine("get face feature error!"); - return; - } - Marshal.Copy(ptr2, fea2, 0, 2048); - // 姣斿 - float score = compare_feature(fea1, len1, fea2, len2); - Console.WriteLine("compare_feature score is:" + score); - } - /// <summary> - /// 閫氳繃鐗瑰緛鍊兼瘮瀵癸紙1:1锛� 瀵逛汉鑴哥壒寰佸�艰繘琛屾瘮杈冿紝鍙繑鍥炰汉鑴哥壒寰佺浉浼煎垎鍊硷紙鐧惧垎鍒讹級 - /// </summary> - /// <param name="file_name1">2048涓猙yte鏁扮粍鐨勭壒寰佸��(浼犲浘鐗囪矾寰�)</param> - /// <param name="file_name2">2048涓猙yte鏁扮粍鐨勭壒寰佸�硷紙浼犲浘鐗囪矾寰勶級</param> - /// <returns></returns> - public static string FaceCompareFeature(string file_name1, string file_name2) - { - string mes = "鍏ワ細"; - try - { +// // 鑾峰彇鐗瑰緛鍊�2 鍏�2048涓瓧鑺� +// byte[] fea2 = new byte[2048]; +// string file_name2 = "G:\\Development\\Application\\testface\\img\\beckham\\8.jpg"; +// int len2 = 0; +// IntPtr ptr2 = get_face_feature(file_name2, ref len2); +// if (len2 != 2048) +// { +// Console.WriteLine("get face feature error!"); +// return; +// } +// Marshal.Copy(ptr2, fea2, 0, 2048); +// // 姣斿 +// float score = compare_feature(fea1, len1, fea2, len2); +// Console.WriteLine("compare_feature score is:" + score); +// } +// /// <summary> +// /// 閫氳繃鐗瑰緛鍊兼瘮瀵癸紙1:1锛� 瀵逛汉鑴哥壒寰佸�艰繘琛屾瘮杈冿紝鍙繑鍥炰汉鑴哥壒寰佺浉浼煎垎鍊硷紙鐧惧垎鍒讹級 +// /// </summary> +// /// <param name="file_name1">2048涓猙yte鏁扮粍鐨勭壒寰佸��(浼犲浘鐗囪矾寰�)</param> +// /// <param name="file_name2">2048涓猙yte鏁扮粍鐨勭壒寰佸�硷紙浼犲浘鐗囪矾寰勶級</param> +// /// <returns></returns> +// public static string FaceCompareFeature(string file_name1, string file_name2) +// { +// string mes = "鍏ワ細"; +// try +// { - // 鑾峰彇鐗瑰緛鍊�1 鍏�2048涓瓧鑺� - byte[] fea1 = new byte[2048]; - int len1 = 0; - IntPtr ptr1 = get_face_feature(file_name1, ref len1); - if (len1 != 2048) - { - return mes += "get face feature error!"; - } - Marshal.Copy(ptr1, fea1, 0, 2048); +// // 鑾峰彇鐗瑰緛鍊�1 鍏�2048涓瓧鑺� +// byte[] fea1 = new byte[2048]; +// int len1 = 0; +// IntPtr ptr1 = get_face_feature(file_name1, ref len1); +// if (len1 != 2048) +// { +// return mes += "get face feature error!"; +// } +// Marshal.Copy(ptr1, fea1, 0, 2048); - // 鑾峰彇鐗瑰緛鍊�2 鍏�2048涓瓧鑺� - byte[] fea2 = new byte[2048]; - int len2 = 0; - IntPtr ptr2 = get_face_feature(file_name2, ref len2); - if (len2 != 2048) - { - return mes += "get face feature error!"; - } - Marshal.Copy(ptr2, fea2, 0, 2048); - // 姣斿 - // len1 鐗瑰緛鍊�1鐨勯暱搴� - float score = compare_feature(fea1, len1, fea2, len2); - Console.WriteLine("compare_feature score is:" + score); - return mes += score.ToString(); +// // 鑾峰彇鐗瑰緛鍊�2 鍏�2048涓瓧鑺� +// byte[] fea2 = new byte[2048]; +// int len2 = 0; +// IntPtr ptr2 = get_face_feature(file_name2, ref len2); +// if (len2 != 2048) +// { +// return mes += "get face feature error!"; +// } +// Marshal.Copy(ptr2, fea2, 0, 2048); +// // 姣斿 +// // len1 鐗瑰緛鍊�1鐨勯暱搴� +// float score = compare_feature(fea1, len1, fea2, len2); +// Console.WriteLine("compare_feature score is:" + score); +// return mes += score.ToString(); - } - catch (Exception ex) - { - return mes += ex; - } - } - /// <summary> - /// 閫氳繃鐗瑰緛鍊兼瘮瀵癸紙1:1锛� 瀵逛汉鑴哥壒寰佸�艰繘琛屾瘮杈冿紝鍙繑鍥炰汉鑴哥壒寰佺浉浼煎垎鍊硷紙鐧惧垎鍒讹級 - /// </summary> - /// <param name="face1">2048涓猙yte鏁扮粍鐨勭壒寰佸��</param> - /// <param name="face2">2048涓猙yte鏁扮粍鐨勭壒寰佸��</param> - /// <returns></returns> - public string FaceCompareFeatureByBuffer(byte[] face1, byte[] face2) - { - if (face1.Length == 2048 && face2.Length == 2048) - { - // 鑾峰彇鐗瑰緛鍊�1 鍏�2048涓瓧鑺� - byte[] fea1 = new byte[2048]; - fea1 = face1; - int len1 = 0; - // 鑾峰彇鐗瑰緛鍊�1 鍏�2048涓瓧鑺� - byte[] fea2 = new byte[2048]; - fea2 = face2; - int len2 = 0; - // 姣斿 - // len1 鐗瑰緛鍊�1鐨勯暱搴� - float score = compare_feature(fea1, len1, fea2, len2); - Console.WriteLine("compare_feature score is:" + score); - return score.ToString(); - } - else - { - return "byte should be 2048"; - } - } +// } +// catch (Exception ex) +// { +// return mes += ex; +// } +// } +// /// <summary> +// /// 閫氳繃鐗瑰緛鍊兼瘮瀵癸紙1:1锛� 瀵逛汉鑴哥壒寰佸�艰繘琛屾瘮杈冿紝鍙繑鍥炰汉鑴哥壒寰佺浉浼煎垎鍊硷紙鐧惧垎鍒讹級 +// /// </summary> +// /// <param name="face1">2048涓猙yte鏁扮粍鐨勭壒寰佸��</param> +// /// <param name="face2">2048涓猙yte鏁扮粍鐨勭壒寰佸��</param> +// /// <returns></returns> +// public string FaceCompareFeatureByBuffer(byte[] face1, byte[] face2) +// { +// if (face1.Length == 2048 && face2.Length == 2048) +// { +// // 鑾峰彇鐗瑰緛鍊�1 鍏�2048涓瓧鑺� +// byte[] fea1 = new byte[2048]; +// fea1 = face1; +// int len1 = 0; +// // 鑾峰彇鐗瑰緛鍊�1 鍏�2048涓瓧鑺� +// byte[] fea2 = new byte[2048]; +// fea2 = face2; +// int len2 = 0; +// // 姣斿 +// // len1 鐗瑰緛鍊�1鐨勯暱搴� +// float score = compare_feature(fea1, len1, fea2, len2); +// Console.WriteLine("compare_feature score is:" + score); +// return score.ToString(); +// } +// else +// { +// return "byte should be 2048"; +// } +// } - // 娴嬭瘯1:N姣旇緝锛屼紶鍏ユ彁鍙栫殑浜鸿劯鐗瑰緛鍊煎拰宸插姞杞界殑鍐呭瓨涓暣涓簱姣旇緝 - public void test_identify_by_feature_with_all() - { - // 鍔犺浇鏁翠釜鏁版嵁搴撳埌鍐呭瓨涓� - load_db_face(); - // 鑾峰彇鐗瑰緛鍊�2048涓瓧鑺� - byte[] fea = new byte[2048]; - string file_name = "G:\\Development\\Application\\testface\\img\\beckham\\2.jpg"; - int len = 0; - IntPtr ptr = get_face_feature(file_name, ref len); - if (len != 2048) - { - Console.WriteLine("get face feature error!"); - return; - } - Marshal.Copy(ptr, fea, 0, 2048); - IntPtr ptr_res = identify_by_feature_with_all(fea, fea.Length); - string buf = Marshal.PtrToStringAnsi(ptr_res); - Console.WriteLine("identify_by_feature_with_all res is:" + buf); - } - /// <summary> - /// 1:N姣旇緝锛屼紶鍏ユ彁鍙栫殑浜鸿劯鐗瑰緛鍊煎拰宸插姞杞界殑鍐呭瓨涓暣涓簱姣旇緝 - /// </summary> - /// <param name="file_name">浼犲叆浜鸿劯鏂囦欢鐗瑰緛鍊�</param> - /// <returns></returns> - public string FaceIdentifyByFeatureWithAll(byte[] file_name) - { - // 鍔犺浇鏁翠釜鏁版嵁搴撳埌鍐呭瓨涓� - load_db_face(); - // 鑾峰彇鐗瑰緛鍊�2048涓瓧鑺� - byte[] fea = new byte[2048]; - fea = file_name; - int len = 0; - //IntPtr ptr = get_face_feature(file_name, ref len); - //if (len != 2048) - //{ - // Console.WriteLine("get face feature error!"); - // return "error"; - //} - // Marshal.Copy(ptr, fea, 0, 2048); - IntPtr ptr_res = identify_by_feature_with_all(fea, fea.Length); - string buf = Marshal.PtrToStringAnsi(ptr_res); - Console.WriteLine("identify_by_feature_with_all res is:" + buf); - return buf; - } +// // 娴嬭瘯1:N姣旇緝锛屼紶鍏ユ彁鍙栫殑浜鸿劯鐗瑰緛鍊煎拰宸插姞杞界殑鍐呭瓨涓暣涓簱姣旇緝 +// public void test_identify_by_feature_with_all() +// { +// // 鍔犺浇鏁翠釜鏁版嵁搴撳埌鍐呭瓨涓� +// load_db_face(); +// // 鑾峰彇鐗瑰緛鍊�2048涓瓧鑺� +// byte[] fea = new byte[2048]; +// string file_name = "G:\\Development\\Application\\testface\\img\\beckham\\2.jpg"; +// int len = 0; +// IntPtr ptr = get_face_feature(file_name, ref len); +// if (len != 2048) +// { +// Console.WriteLine("get face feature error!"); +// return; +// } +// Marshal.Copy(ptr, fea, 0, 2048); +// IntPtr ptr_res = identify_by_feature_with_all(fea, fea.Length); +// string buf = Marshal.PtrToStringAnsi(ptr_res); +// Console.WriteLine("identify_by_feature_with_all res is:" + buf); +// } +// /// <summary> +// /// 1:N姣旇緝锛屼紶鍏ユ彁鍙栫殑浜鸿劯鐗瑰緛鍊煎拰宸插姞杞界殑鍐呭瓨涓暣涓簱姣旇緝 +// /// </summary> +// /// <param name="file_name">浼犲叆浜鸿劯鏂囦欢鐗瑰緛鍊�</param> +// /// <returns></returns> +// public string FaceIdentifyByFeatureWithAll(byte[] file_name) +// { +// // 鍔犺浇鏁翠釜鏁版嵁搴撳埌鍐呭瓨涓� +// load_db_face(); +// // 鑾峰彇鐗瑰緛鍊�2048涓瓧鑺� +// byte[] fea = new byte[2048]; +// fea = file_name; +// int len = 0; +// //IntPtr ptr = get_face_feature(file_name, ref len); +// //if (len != 2048) +// //{ +// // Console.WriteLine("get face feature error!"); +// // return "error"; +// //} +// // Marshal.Copy(ptr, fea, 0, 2048); +// IntPtr ptr_res = identify_by_feature_with_all(fea, fea.Length); +// string buf = Marshal.PtrToStringAnsi(ptr_res); +// Console.WriteLine("identify_by_feature_with_all res is:" + buf); +// return buf; +// } - // 娴嬭瘯1:N姣旇緝锛屼紶鍏ュ浘鐗囨枃浠惰矾寰勫拰宸插姞杞界殑鍐呭瓨涓暣涓簱姣旇緝 - public void test_identify_with_all() - { - // 鍔犺浇鏁翠釜鏁版嵁搴撳埌鍐呭瓨涓� - load_db_face(); - // 1:N - string file1 = "G:\\Development\\Application\\testface\\img\\beckham\\3.jpg"; - IntPtr ptr = identify_with_all(file1); - string buf = Marshal.PtrToStringAnsi(ptr); - Console.WriteLine("identify_with_all res is:" + buf); - } - /// <summary> - /// 1:N姣旇緝锛屼紶鍏ュ浘鐗囨枃浠惰矾寰勫拰宸插姞杞界殑鍐呭瓨涓暣涓簱姣旇緝 - /// </summary> - /// <param name="file1">浼犲叆鍥剧墖璺緞</param> - /// <returns></returns> - public string FaceIndentifyWithAll(string file1) - { - // 鍔犺浇鏁翠釜鏁版嵁搴撳埌鍐呭瓨涓� - load_db_face(); - // 1:N - IntPtr ptr = identify_with_all(file1); - string buf = Marshal.PtrToStringAnsi(ptr); - Console.WriteLine("identify_with_all res is:" + buf); - return buf; - } +// // 娴嬭瘯1:N姣旇緝锛屼紶鍏ュ浘鐗囨枃浠惰矾寰勫拰宸插姞杞界殑鍐呭瓨涓暣涓簱姣旇緝 +// public void test_identify_with_all() +// { +// // 鍔犺浇鏁翠釜鏁版嵁搴撳埌鍐呭瓨涓� +// load_db_face(); +// // 1:N +// string file1 = "G:\\Development\\Application\\testface\\img\\beckham\\3.jpg"; +// IntPtr ptr = identify_with_all(file1); +// string buf = Marshal.PtrToStringAnsi(ptr); +// Console.WriteLine("identify_with_all res is:" + buf); +// } +// /// <summary> +// /// 1:N姣旇緝锛屼紶鍏ュ浘鐗囨枃浠惰矾寰勫拰宸插姞杞界殑鍐呭瓨涓暣涓簱姣旇緝 +// /// </summary> +// /// <param name="file1">浼犲叆鍥剧墖璺緞</param> +// /// <returns></returns> +// public string FaceIndentifyWithAll(string file1) +// { +// // 鍔犺浇鏁翠釜鏁版嵁搴撳埌鍐呭瓨涓� +// load_db_face(); +// // 1:N +// IntPtr ptr = identify_with_all(file1); +// string buf = Marshal.PtrToStringAnsi(ptr); +// Console.WriteLine("identify_with_all res is:" + buf); +// return buf; +// } - /// <summary> - /// 1:N姣旇緝锛屼紶鍏ュ浘鐗囨枃浠朵簩杩涘埗buffer鍜屽凡鍔犺浇鐨勫唴瀛樹腑鏁翠釜搴撴瘮杈� - /// </summary> - /// <param name="file_name"></param> - /// <returns></returns> - public string FaceIdentifyByBufferWithAll(byte[] file_name) - { - // 鍔犺浇鏁翠釜鏁版嵁搴撳埌鍐呭瓨涓� - load_db_face(); - // 1:N - // System.Drawing.Image img = System.Drawing.Image.FromFile(file_name); - byte[] img_bytes = file_name;// ImageUtil.img2byte(img); +// /// <summary> +// /// 1:N姣旇緝锛屼紶鍏ュ浘鐗囨枃浠朵簩杩涘埗buffer鍜屽凡鍔犺浇鐨勫唴瀛樹腑鏁翠釜搴撴瘮杈� +// /// </summary> +// /// <param name="file_name"></param> +// /// <returns></returns> +// public string FaceIdentifyByBufferWithAll(byte[] file_name) +// { +// // 鍔犺浇鏁翠釜鏁版嵁搴撳埌鍐呭瓨涓� +// load_db_face(); +// // 1:N +// // System.Drawing.Image img = System.Drawing.Image.FromFile(file_name); +// byte[] img_bytes = file_name;// ImageUtil.img2byte(img); - IntPtr ptr = identify_by_buf_with_all(img_bytes, img_bytes.Length); - string buf = Marshal.PtrToStringAnsi(ptr); - Console.WriteLine("identify_by_buf_with_all res is:" + buf); - return buf; - } +// IntPtr ptr = identify_by_buf_with_all(img_bytes, img_bytes.Length); +// string buf = Marshal.PtrToStringAnsi(ptr); +// Console.WriteLine("identify_by_buf_with_all res is:" + buf); +// return buf; +// } - } -} +// } +//} -- Gitblit v1.9.3