From 7876ac5d67b12e206a68db17c4034df52fa2f060 Mon Sep 17 00:00:00 2001 From: z8018 <1282578289@qq.com> Date: 星期五, 06 六月 2025 09:23:38 +0800 Subject: [PATCH] 1 --- project/WCS/WIDESEAWCS_Server/WIDESEAWCS_Common/FaceAI/FaceAttr.cs | 196 ++++++++++++++++++++++++------------------------ 1 files changed, 98 insertions(+), 98 deletions(-) diff --git a/project/WCS/WIDESEAWCS_Server/WIDESEAWCS_Common/FaceAI/FaceAttr.cs b/project/WCS/WIDESEAWCS_Server/WIDESEAWCS_Common/FaceAI/FaceAttr.cs index 54b6db7..8e2eb3a 100644 --- a/project/WCS/WIDESEAWCS_Server/WIDESEAWCS_Common/FaceAI/FaceAttr.cs +++ b/project/WCS/WIDESEAWCS_Server/WIDESEAWCS_Common/FaceAI/FaceAttr.cs @@ -1,109 +1,109 @@ -锘縰sing System; -using System.Runtime.InteropServices; -using OpenCvSharp; +锘�//using System; +//using System.Runtime.InteropServices; +//using OpenCvSharp; -namespace FaceAI -{ - /** - * @brief 浜鸿劯琛ㄦ儏灞炴�ф灇涓� - */ - enum BDFaceAttributeEmotionType - { - BDFACE_ATTRIBUTE_EMOTION_FROWN = 0, // 鐨辩湁 - BDFACE_ATTRIBUTE_EMOTION_SMILE = 1, // 绗� - BDFACE_ATTRIBUTE_EMOTION_CALM = 2, // 骞抽潤 - }; +//namespace FaceAI +//{ +// /** +// * @brief 浜鸿劯琛ㄦ儏灞炴�ф灇涓� +// */ +// enum BDFaceAttributeEmotionType +// { +// BDFACE_ATTRIBUTE_EMOTION_FROWN = 0, // 鐨辩湁 +// BDFACE_ATTRIBUTE_EMOTION_SMILE = 1, // 绗� +// BDFACE_ATTRIBUTE_EMOTION_CALM = 2, // 骞抽潤 +// }; - /** - * @brief 浜鸿劯绉嶆棌灞炴�ф灇涓� - */ - enum BDFaceRace - { - BDFACE_RACE_YELLOW = 0, // 榛勭浜� - BDFACE_RACE_WHITE = 1, // 鐧界浜� - BDFACE_RACE_BLACK = 2, // 榛戠浜� - BDFACE_RACE_INDIAN = 3, // 鍗扮瀹変汉 - }; +// /** +// * @brief 浜鸿劯绉嶆棌灞炴�ф灇涓� +// */ +// enum BDFaceRace +// { +// BDFACE_RACE_YELLOW = 0, // 榛勭浜� +// BDFACE_RACE_WHITE = 1, // 鐧界浜� +// BDFACE_RACE_BLACK = 2, // 榛戠浜� +// BDFACE_RACE_INDIAN = 3, // 鍗扮瀹変汉 +// }; - /** - * @brief 鐪奸暅鐘舵�佸睘鎬ф灇涓� - */ - enum BDFaceGlasses - { - BDFACE_NO_GLASSES = 0, // 鏃犵溂闀� - BDFACE_GLASSES = 1, // 鏈夌溂闀� - BDFACE_SUN_GLASSES = 2, // 澧ㄩ暅 - }; +// /** +// * @brief 鐪奸暅鐘舵�佸睘鎬ф灇涓� +// */ +// enum BDFaceGlasses +// { +// BDFACE_NO_GLASSES = 0, // 鏃犵溂闀� +// BDFACE_GLASSES = 1, // 鏈夌溂闀� +// BDFACE_SUN_GLASSES = 2, // 澧ㄩ暅 +// }; - /** - * @brief 鎬у埆灞炴�ф灇涓� - */ - enum BDFaceGender - { - BDFACE_GENDER_FEMAILE = 0, // 濂虫�� - BDFACE_GENDER_MALE = 1, // 鐢锋�� - }; +// /** +// * @brief 鎬у埆灞炴�ф灇涓� +// */ +// enum BDFaceGender +// { +// BDFACE_GENDER_FEMAILE = 0, // 濂虫�� +// BDFACE_GENDER_MALE = 1, // 鐢锋�� +// }; - /** - * @brief 浜鸿劯灞炴�х粨鏋勪綋 - */ - [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct BDFaceAttribute - { - public int age; // 骞撮緞 - public BDFaceRace race; // 绉嶆棌 - public BDFaceAttributeEmotionType emotion; // 琛ㄦ儏 - public BDFaceGlasses glasses; // 鎴寸溂闀滅姸鎬� - public BDFaceGender gender; // 鎬у埆 - }; +// /** +// * @brief 浜鸿劯灞炴�х粨鏋勪綋 +// */ +// [StructLayout(LayoutKind.Sequential, Pack = 1)] +// struct BDFaceAttribute +// { +// public int age; // 骞撮緞 +// public BDFaceRace race; // 绉嶆棌 +// public BDFaceAttributeEmotionType emotion; // 琛ㄦ儏 +// public BDFaceGlasses glasses; // 鎴寸溂闀滅姸鎬� +// public BDFaceGender gender; // 鎬у埆 +// }; - // 浜鸿劯灞炴�хず渚嬪強鎺ュ彛 - class FaceAttr - { - // 鑾峰彇浜鸿劯灞炴�� - [DllImport("BaiduFaceApi.dll", EntryPoint = "face_attr", CharSet = CharSet.Ansi - , CallingConvention = CallingConvention.Cdecl)] - public static extern int face_attr(IntPtr ptr, IntPtr mat); +// // 浜鸿劯灞炴�хず渚嬪強鎺ュ彛 +// class FaceAttr +// { +// // 鑾峰彇浜鸿劯灞炴�� +// [DllImport("BaiduFaceApi.dll", EntryPoint = "face_attr", CharSet = CharSet.Ansi +// , CallingConvention = CallingConvention.Cdecl)] +// public static extern int face_attr(IntPtr ptr, IntPtr mat); - // 娴嬭瘯鑾峰彇浜鸿劯灞炴�� - public void test_get_face_attr() - { - int max_face_num = 5; // 璁剧疆鏈�澶氭娴嬭窡韪汉鏁帮紙澶氫汉鑴告娴嬶級锛岄粯璁や负1锛屾渶澶氬彲璁句负50 +// // 娴嬭瘯鑾峰彇浜鸿劯灞炴�� +// public void test_get_face_attr() +// { +// int max_face_num = 5; // 璁剧疆鏈�澶氭娴嬭窡韪汉鏁帮紙澶氫汉鑴告娴嬶級锛岄粯璁や负1锛屾渶澶氬彲璁句负50 - BDFaceAttribute[] attr_info = new BDFaceAttribute[max_face_num]; - int size = Marshal.SizeOf(typeof(BDFaceAttribute)); - IntPtr ptT = Marshal.AllocHGlobal(size * max_face_num); - string img_path = "../images/rgb.png"; - Mat mat = Cv2.ImRead(img_path); - int faceNum = face_attr(ptT, mat.CvPtr); - Console.WriteLine("faceNum is:" + 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); - } +// BDFaceAttribute[] attr_info = new BDFaceAttribute[max_face_num]; +// int size = Marshal.SizeOf(typeof(BDFaceAttribute)); +// IntPtr ptT = Marshal.AllocHGlobal(size * max_face_num); +// string img_path = "../images/rgb.png"; +// Mat mat = Cv2.ImRead(img_path); +// int faceNum = face_attr(ptT, mat.CvPtr); +// Console.WriteLine("faceNum is:" + 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); - } +// 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); +// } - } -} +// } +//} -- Gitblit v1.9.3