public ASF_MultiFaceInfo DetectMultipleFace(IntPtr pEngine, ImageInfo imageInfo)
        {
            ASF_MultiFaceInfo multiFaceInfo  = new ASF_MultiFaceInfo();
            IntPtr            pMultiFaceInfo = Marshal.AllocHGlobal(Marshal.SizeOf <ASF_MultiFaceInfo>());

            try
            {
                int retCode = ASFDetectFaces(pEngine, imageInfo.width, imageInfo.height, imageInfo.format, imageInfo.imgData, pMultiFaceInfo, ASF_DetectModel.ASF_DETECT_MODEL_RGB);
                multiFaceInfo = Marshal.PtrToStructure <ASF_MultiFaceInfo>(pMultiFaceInfo);
                return(multiFaceInfo);
            }
            catch
            {
                return(multiFaceInfo);
            }
            finally
            {
                Marshal.FreeHGlobal(pMultiFaceInfo);
            }
        }
Exemplo n.º 2
0
 public static List <byte[]> ExtractAllFeatures(IntPtr pEngine, ImageInfo imageInfo, ASF_MultiFaceInfo multiFaceInfo)
 {
     try
     {
         ASF_SingleFaceInfo singleFaceInfo = new ASF_SingleFaceInfo();
         List <byte[]>      results        = new List <byte[]>();
         for (int index = 0; index < multiFaceInfo.faceNum; index++)
         {
             singleFaceInfo.faceRect   = Marshal.PtrToStructure <MRECT>(multiFaceInfo.faceRects + Marshal.SizeOf <MRECT>() * index);
             singleFaceInfo.faceOrient = Marshal.PtrToStructure <int>(multiFaceInfo.faceOrients + Marshal.SizeOf <int>() * index);
             byte[] singleFaceFeature = ExtractSingleFaceFeature(pEngine, imageInfo, singleFaceInfo.faceRect, singleFaceInfo.faceOrient);
             if (singleFaceFeature != null)
             {
                 results.Add(singleFaceFeature);
             }
         }
         return(results);
     }
     catch (Exception ex)
     {
         throw new Exception("Arcsoft_Face_Action-->ExtractAllFeatures exception " + ex);
     }
     finally
     {
         Marshal.FreeHGlobal(imageInfo.imgData);
     }
 }