public long DetectFaces(int width, int height, IntPtr imgData, out List <FaceInfo> fis) { AS_MultiFaceInfo asInfo = new AS_MultiFaceInfo(); var ret = DetectFaces(_engine, width, height, 513, imgData, ref asInfo, AS_DetectModel.DETECT_MODEL_RGB); fis = new List <FaceInfo>(); var faceRectSize = Marshal.SizeOf(typeof(AS_FaceRect)); var faceOrientSize = Marshal.SizeOf(typeof(int)); var faceIdSize = Marshal.SizeOf(typeof(int)); for (int i = 0; i < asInfo.FaceNumber; i++) { IntPtr faceRectPtr = asInfo.FaceRect + i * faceRectSize; IntPtr faceOrientPtr = asInfo.FaceOrient + i * faceOrientSize; AS_FaceRect faceRect = Marshal.PtrToStructure <AS_FaceRect>(faceRectPtr); int faceOrient = Marshal.PtrToStructure <int>(faceOrientPtr); int faceId = -1; if (asInfo.FaceID != IntPtr.Zero) { IntPtr faceIdPtr = asInfo.FaceID + i * faceIdSize; faceId = Marshal.PtrToStructure <int>(faceIdPtr); } fis.Add(new FaceInfo() { Top = faceRect.Top, Left = faceRect.Left, Right = faceRect.Right, Bottom = faceRect.Bottom, Orient = faceOrient, Id = faceId }); } return(ret); }
internal static extern long DetectFaces(IntPtr engine, int width, int height, int format, IntPtr imgData, ref AS_MultiFaceInfo asMultiFaceInfos, AS_DetectModel asDetectModel);