コード例 #1
0
ファイル: IDCardUtil.cs プロジェクト: Yxy1026/WPFDemo
 public static ASF_MultiFaceInfo DetectFace(IntPtr pEngine, Image image)
 {
     lock (locks)
     {
         ASF_MultiFaceInfo multiFaceInfo = new ASF_MultiFaceInfo();
         if (image != null)
         {
             if (image == null)
             {
                 return(multiFaceInfo);
             }
             ImageInfo imageInfo = ReadBMP(image);
             if (imageInfo == null)
             {
                 return(multiFaceInfo);
             }
             multiFaceInfo = DetectFace(pEngine, imageInfo);
             MemoryUtil.Free(imageInfo.imgData);
             return(multiFaceInfo);
         }
         else
         {
             return(multiFaceInfo);
         }
     }
 }
コード例 #2
0
ファイル: IDCardUtil.cs プロジェクト: Yxy1026/WPFDemo
        public static ASF_SingleFaceInfo2 GetMaxFace(ASF_MultiFaceInfo multiFaceInfo)
        {
            ASF_SingleFaceInfo2 singleFaceInfo = new ASF_SingleFaceInfo2();

            singleFaceInfo.faceRect   = new MRECT();
            singleFaceInfo.faceOrient = 1;

            int maxArea = 0;
            int index   = -1;

            for (int i = 0; i < multiFaceInfo.faceNum; i++)
            {
                try
                {
                    MRECT rect = MemoryUtil.PtrToStructure <MRECT>(multiFaceInfo.faceRects + MemoryUtil.SizeOf <MRECT>() * i);
                    int   area = (rect.right - rect.left) * (rect.bottom - rect.top);
                    if (maxArea <= area)
                    {
                        maxArea = area;
                        index   = i;
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }
            }
            if (index != -1)
            {
                singleFaceInfo.faceRect   = MemoryUtil.PtrToStructure <MRECT>(multiFaceInfo.faceRects + MemoryUtil.SizeOf <MRECT>() * index);
                singleFaceInfo.faceOrient = MemoryUtil.PtrToStructure <int>(multiFaceInfo.faceOrients + MemoryUtil.SizeOf <int>() * index);
            }
            return(singleFaceInfo);
        }
コード例 #3
0
        /// <summary>
        /// 获取激活文件信息接口
        /// </summary>
        /// <param name="activeFileInfo"></param>
        /// <returns>接口返回码,返回0表示正常,返回其他值请在开发者中心-帮助中心查询</returns>
        public int ArcSoft_FIC_GetActiveFileInfo(out ActiveFileInfo activeFileInfo)
        {
            int retCode = -1;

            activeFileInfo = new ActiveFileInfo();
            IntPtr pActiveFileInfo = MemoryUtil.Malloc(MemoryUtil.SizeOf <AFIC_FSDK_ActiveFileInfo>());

            //获取激活文件信息接口
            retCode = FICFunctions.ArcSoft_FIC_GetActiveFileInfo(pActiveFileInfo);
            if (!retCode.Equals(0))
            {
                MemoryUtil.Free(pActiveFileInfo);
                return(retCode);
            }
            AFIC_FSDK_ActiveFileInfo sActiveFileInfo = MemoryUtil.PtrToStruct <AFIC_FSDK_ActiveFileInfo>(pActiveFileInfo);

            MemoryUtil.Free(pActiveFileInfo);
            #region 指针转化字符串
            activeFileInfo.startTime   = Marshal.PtrToStringAnsi(sActiveFileInfo.startTime);
            activeFileInfo.endTime     = Marshal.PtrToStringAnsi(sActiveFileInfo.endTime);
            activeFileInfo.activeKey   = Marshal.PtrToStringAnsi(sActiveFileInfo.activeKey);
            activeFileInfo.platform    = Marshal.PtrToStringAnsi(sActiveFileInfo.platform);
            activeFileInfo.sdkType     = Marshal.PtrToStringAnsi(sActiveFileInfo.sdkType);
            activeFileInfo.appId       = Marshal.PtrToStringAnsi(sActiveFileInfo.appId);
            activeFileInfo.sdkKey      = Marshal.PtrToStringAnsi(sActiveFileInfo.sdkKey);
            activeFileInfo.sdkVersion  = Marshal.PtrToStringAnsi(sActiveFileInfo.sdkVersion);
            activeFileInfo.fileVersion = Marshal.PtrToStringAnsi(sActiveFileInfo.fileVersion);
            #endregion
            return(retCode);
        }
コード例 #4
0
        static void Main(string[] args)
        {
            int processPtr = ProcessUtil.OpenProcess("Game");

            //var query = SteinsEncoding.Encode("ねぇねぇ");
            var query = Encoding.UTF8.Encode("右耳に当て");

            //var query = SteinsEncoding.Encode("を受けて");
            //var query = SteinsEncoding.Encode("ぽたりと");
            //var query = SteinsEncoding.Encode("オカリン?");
            //" ねぇってばー");
            //var query = SteinsEncoding.Encode("誰かと電話中?");
            //var query = SteinsEncoding.Encode("うなずいてから、");
            //var query = SteinsEncoding.Encode("電話の向こうから");

            //var query = new byte[] { 0x0D, 0x00, 0x00, 0x00, 0x0e };

            Console.WriteLine("Target is: " + MemoryUtil.Search(processPtr, query));



            uint memoryPtr = 33771968; //21123520;//MemoryUtil.Search(processPtr, query);

            MemoryUtil.DumpSection("found.txt", processPtr, memoryPtr - 512, 1024);
            Console.WriteLine(memoryPtr);

            var buffer = new byte[512];

            MemoryUtil.Fill(processPtr, buffer, memoryPtr - 10);

            Console.WriteLine(SteinsText.ExtractText(buffer, 10));
        }
コード例 #5
0
ファイル: ImageHelper.cs プロジェクト: yumaster/FaceTracking
        /// <summary>
        /// 从Image图片中提取特征
        /// </summary>
        /// <param name="img"></param>
        /// <returns></returns>
        public static IntPtr GetFeatureFromImage(IntPtr pEngine, Image img)
        {
            Image image = img;

            if (image.Width % 4 != 0)
            {
                image = ImageUtil.ScaleImage(image, image.Width - (image.Width % 4), image.Height);
            }
            ASF_MultiFaceInfo multiFaceInfo = FaceUtil.DetectFace(pEngine, image);

            if (multiFaceInfo.faceNum > 0)
            {
                //裁剪照片到识别人脸的框的大小
                MRECT rect = MemoryUtil.PtrToStructure <MRECT>(multiFaceInfo.faceRects);
                image = ImageUtil.CutImage(image, rect.left, rect.top, rect.right, rect.bottom);
            }
            //提取人脸特征
            ASF_SingleFaceInfo singleFaceInfo = new ASF_SingleFaceInfo();
            IntPtr             feature        = FaceUtil.ExtractFeature(pEngine, image, out singleFaceInfo);

            if (!(singleFaceInfo.faceRect.left == 0 && singleFaceInfo.faceRect.right == 0))
            {
                return(feature);//成功提取到的图像特征值
            }
            return(IntPtr.Zero);
        }
コード例 #6
0
        /// <summary>
        /// 人脸特征提取
        /// </summary>
        /// <param name="image">人脸图像</param>
        /// <param name="faceRes">人脸信息检测结果</param>
        /// <returns>接口返回码,返回0表示正常,返回其他值请在开发者中心-帮助中心查询</returns>
        public int ArcSoft_FIC_FaceDataFeatureExtraction(Image image, ref FaceRes faceRes)
        {
            faceRes = new FaceRes();
            IntPtr        pFaceRes       = MemoryUtil.Malloc(MemoryUtil.SizeOf <AFICFSDKFACERES>());
            ASVLOFFSCREEN imagetemp      = ImageUtil.ReadBmp(image, false);
            IntPtr        pInputFaceData = MemoryUtil.Malloc(MemoryUtil.SizeOf <ASVLOFFSCREEN>());

            MemoryUtil.StructToPtr(imagetemp, pInputFaceData);
            //调用SDK的人脸特征提取接口
            int retCode = FICFunctions.ArcSoft_FIC_FaceDataFeatureExtraction(pEngine, mode, pInputFaceData, pFaceRes);

            if (!retCode.Equals(0))
            {
                MemoryUtil.Free(pFaceRes);
                MemoryUtil.Free(pInputFaceData);
                MemoryUtil.Free(imagetemp.ppu8Plane[0]);
                return(retCode);
            }
            AFICFSDKFACERES faceResStruct = MemoryUtil.PtrToStruct <AFICFSDKFACERES>(pFaceRes);

            faceRes.nFace  = faceResStruct.nFace;
            faceRes.rcFace = faceResStruct.rcFace;
            MemoryUtil.Free(pFaceRes);
            MemoryUtil.Free(pInputFaceData);
            MemoryUtil.Free(imagetemp.ppu8Plane[0]);
            return(retCode);
        }
コード例 #7
0
ファイル: ImageCover.cs プロジェクト: JimMa0312/ARCFaceApp
        public Image <Bgr, byte> Yv12_2_BGR(ref IntPtr pBuf, int nSize, int height, int width)
        {
            if (yuvs == null)
            {
                yuvs = new byte[nSize];
            }
            if (image == null)
            {
                image = new Image <Bgr, byte>(width, height);
            }

            MemoryUtil.Copy(pBuf, yuvs, 0, nSize);

            GCHandle handle = GCHandle.Alloc(yuvs, GCHandleType.Pinned);

            using (Image <Gray, byte> yv12p = new Image <Gray, byte>(width, (height >> 1) * 3, width, handle.AddrOfPinnedObject()))
            {
                CvInvoke.CvtColor(yv12p, image, Emgu.CV.CvEnum.ColorConversion.Yuv420P2Bgr);
            }

            if (handle.IsAllocated)
            {
                handle.Free();
            }

            return(image);
        }
コード例 #8
0
        /// <summary>
        /// 获取IR活体结果
        /// </summary>
        /// <param name="livenessInfo">IR活体结果</param>
        /// <returns>返回0表示正常;返回负数请根据ErrorCodeUtil类注释查看;其他值请在官网-帮助中心查询</returns>
        public int ASFGetLivenessScore_IR(out LivenessInfo livenessInfo)
        {
            int retCode = -1;

            livenessInfo = new LivenessInfo();
            IntPtr pLiveness = MemoryUtil.Malloc(MemoryUtil.SizeOf <ASF_LivenessInfo>());

            //调用SDK接口
            retCode = ASFFunctions.ASFGetLivenessScore_IR(pEngine, pLiveness);
            if (retCode != 0)
            {
                MemoryUtil.Free(pLiveness);
                return(retCode);
            }
            //转化结果
            ASF_LivenessInfo asfLivenessInfo = new ASF_LivenessInfo();

            asfLivenessInfo  = MemoryUtil.PtrToStructure <ASF_LivenessInfo>(pLiveness);
            livenessInfo.num = asfLivenessInfo.num;
            if (asfLivenessInfo.num > 0)
            {
                livenessInfo.isLive = new int[asfLivenessInfo.num];
                Marshal.Copy(asfLivenessInfo.isLive, livenessInfo.isLive, 0, asfLivenessInfo.num);
            }
            MemoryUtil.FreeArray(pLiveness);
            return(retCode);
        }
コード例 #9
0
        private void CalculatePointers()
        {
            var bytesToFind = new byte[] { 0x4c, 0x8b, 0x35,
                                           0x90, 0x90, 0x90, 0x90,// = 0x55, 0xfa, 0x0c, 0x00 WILDCARDS
                                           0x4c, 0x69, 0xf8,
                                           0x90, 0x90, 0x90, 0x90,
                                           0x4c, 0x89, 0xf0,
                                           0x4c, 0x01, 0xf8 };

            var results = MemoryUtil.FindMemoryWithWildcards(GetGameHandle(), GetEntryPoint(), (uint)this.GameProcess.MainModule.ModuleMemorySize, bytesToFind);

            if (results.Count != 1)
            {
                throw new AmbiguousMatchException($"{results.Count} memory locations matched, which is not 1!");
            }

            var result        = results.First();
            var resultAddress = result.Key;
            var resultBytes   = result.Value;

            var chessboardPointerLocation = IntPtr.Add(resultAddress, BitConverter.ToInt32(resultBytes, 3) + 7);

            this.MemLocChessArrayPointer    = new MemoryLocation <IntPtr>(GetGameHandle(), chessboardPointerLocation);
            this.MemLocChessArraySize       = new MemoryLocation <int>(GetGameHandle(), chessboardPointerLocation, -8);
            this.MemLocChessBoardSizeWidth  = new MemoryLocation <int>(GetGameHandle(), chessboardPointerLocation, 0xA8 + 0x4);
            this.MemLocChessBoardSizeHeight = new MemoryLocation <int>(GetGameHandle(), chessboardPointerLocation, 0xA8);
            this.MemLocCurrentPlayersTurn   = new MemoryLocation <int>(GetGameHandle(), chessboardPointerLocation, 0x110);
            this.MemLocGameEndedWinner      = new MemoryLocation <int>(GetGameHandle(), chessboardPointerLocation, 0xCC);
            this.MemLocGameState            = new MemoryLocation <int>(GetGameHandle(), chessboardPointerLocation, 0xD0);
        }
コード例 #10
0
ファイル: Program.cs プロジェクト: haru-same/GameTextHook
        static void FindAll(Tuple <Process, int> process, byte[] query, HashSet <string> strings)
        {
            uint startIndex = firstFound;
            uint max        = 0x2F000000;

            //uint.MaxValue;
            while (true)
            {
                //max = (uint)Math.Min(max, firstFound + process.Item1.PeakWorkingSet64);

                startIndex = MemoryUtil.Search(process.Item2, query, startIndex: startIndex + 2, max: max);
                //Console.WriteLine("start: " + startIndex.ToString("X4"));

                if (firstFound == 0)
                {
                    firstFound = startIndex;
                }

                if (startIndex == 0)
                {
                    break;
                }

                MemoryUtil.Fill(process.Item2, bytes, startIndex);

                var extractedString = bytes.GetString(0);
                strings.Add(ClearBrackets(extractedString));

                //System.Threading.Thread.Sleep(1);
            }
        }
コード例 #11
0
        public static void DumpDictionary()
        {
            var fileBytes = File.ReadAllBytes("Game.exe");
            var query     = new byte[] { 0xC0, 0x00, 0xC1, 0x00, 0xC2, 0x00, 0xC3, 0x00, 0xC4, 0x00, 0xC5, 0x00, 0xC6, 0x00, 0xC7, 0x00, };

            for (var i = 0; i < fileBytes.Length - query.Length; i++)
            {
                if (MemoryUtil.ByteCompare(query, fileBytes, (uint)i))
                {
                    var outBuffer = new List <byte>();
                    var j         = i;
                    while (j - i < 14000)
                    {
                        outBuffer.Add(fileBytes[j]);
                        j++;
                    }
                    while (!(fileBytes[j] == 0 && fileBytes[j + 1] == 0))
                    {
                        outBuffer.Add(fileBytes[j]);
                        j++;
                    }
                    File.WriteAllBytes("encoding_dict.txt", outBuffer.ToArray());
                    return;
                }
            }
        }
コード例 #12
0
        public List <FaceInfo> ScanFaces(Bitmap bitmap)
        {
            List <FaceInfo> singleFaces = new List <FaceInfo>();

            if (bitmap == null)
            {
                return(null);
            }

            //从视频帧中获取 多个人脸的矩形框位置
            ASF_MultiFaceInfo multiFaceInfo = FaceUtil.DetectFace(pVideoEngine, bitmap);

            //将MultiFaceInfo结构体中的数据提取成单人脸数据并放入结构体中
            for (int i = 0; i < multiFaceInfo.faceNum; i++)
            {
                FaceInfo faceInfo = new FaceInfo();

                faceInfo.faceId = MemoryUtil.PtrToStructure <int>(multiFaceInfo.faceID + MemoryUtil.SizeOf <int>() * i);

                faceInfo.singleFaceInfo.faceRect   = MemoryUtil.PtrToStructure <MRECT>(multiFaceInfo.faceRects + MemoryUtil.SizeOf <MRECT>() * i);
                faceInfo.singleFaceInfo.faceOrient = MemoryUtil.PtrToStructure <int>(multiFaceInfo.faceOrients + MemoryUtil.SizeOf <int>() * i);

                singleFaces.Add(faceInfo);
            }

            return(singleFaces);
        }
コード例 #13
0
        /// <summary>
        /// 从Image图片中提取特征
        /// </summary>
        /// <param name="img"></param>
        /// <returns></returns>
        private IntPtr GetFeatureFromImage(Image img)
        {
            Image image = img;

            if (image.Width % 4 != 0)
            {
                image = ImageUtil.ScaleImage(image, image.Width - (image.Width % 4), image.Height);
            }
            ASF_MultiFaceInfo multiFaceInfo = FaceUtil.DetectFace(pImageEngine, image);

            if (multiFaceInfo.faceNum > 0)
            {
                //裁剪照片到识别人脸的框的大小
                MRECT rect = MemoryUtil.PtrToStructure <MRECT>(multiFaceInfo.faceRects);
                image = ImageUtil.CutImage(image, rect.left, rect.top, rect.right, rect.bottom);
            }
            //提取人脸特征
            ASF_SingleFaceInfo singleFaceInfo = new ASF_SingleFaceInfo();
            IntPtr             feature        = FaceUtil.ExtractFeature(pImageEngine, image, out singleFaceInfo);

            if (singleFaceInfo.faceRect.left == 0 && singleFaceInfo.faceRect.right == 0)
            {
                //messageBox.AppendText("无法提取身份证件照特征...\n");
                //无法提取身份证件照特征..
            }
            else
            {
                //成功提取到的图像特征值
                return(feature);
            }
            return(IntPtr.Zero);
        }
コード例 #14
0
        /// <summary>
        /// 年龄检测
        /// </summary>
        /// <param name="pEngine">引擎Handle</param>
        /// <returns>年龄检测结构体</returns>
        private static ASF_AgeInfo AgeEstimation(IntPtr pEngine)
        {
            IntPtr pInfo   = MemoryUtil.Malloc(MemoryUtil.SizeOf <ASF_AgeInfo>());
            int    retCode = -1;

#if NET5_0
            if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
            {
#endif
            if (
#if NET5_0
                RuntimeInformation.ProcessArchitecture == Architecture.X64
#else
                Environment.Is64BitProcess
#endif
                )
            {
                retCode = ASFFunctions_Pro_x64.ASFGetAge(pEngine, pInfo);
            }
            else
#if NET5_0
            if (RuntimeInformation.ProcessArchitecture == Architecture.X86)
#endif
            {
                retCode = ASFFunctions_Pro_x86.ASFGetAge(pEngine, pInfo);
            }
#if NET5_0
            else
            {
                throw new NotSupportedException("Only supported Windows x86 x64 and Linux x64");
            }
        }
コード例 #15
0
ファイル: Camera.cs プロジェクト: JimMa0312/ARCFaceApp
        /// <summary>
        /// 人脸比对
        /// </summary>
        /// <param name="faceInfo"></param>
        /// <returns></returns>
        private bool compareFeature(FaceInfo faceInfo)
        {
            float similarity = 0;

            //把提取以后的特征值结构体的指针赋给pFaceFeature
            IntPtr pFaceFeature = MemoryUtil.Malloc(MemoryUtil.SizeOf <ASF_FaceFeature> ());

            //复制给faceInfo的faceFaceFeature中
            MemoryUtil.StructureToPtr <ASF_FaceFeature>(faceInfo.faceFeature, pFaceFeature);

            //内存里缓冲的人脸特征数据库
            foreach (var item in FaceFeatureLib.faceFeatures)
            {
                //调用api进行比对,得到相似度similarity
                faceVideoRecognizer.CompareFeature(pFaceFeature, item.pFaceFeature, ref similarity);

                //相似度比较阈值
                if (similarity >= threshold)
                {
                    faceInfo.isFacePass = true;
                    faceInfo.studentId  = item.studentId;

                    MemoryUtil.Free(pFaceFeature);
                    return(true);
                }
            }
            MemoryUtil.Free(pFaceFeature);
            return(false);
        }
コード例 #16
0
        /// <summary>
        /// 获取性别结果
        /// </summary>
        /// <param name="pEngine">引擎handle</param>
        /// <param name="genderInfo">out 性别结果</param>
        /// <returns>返回0表示正常;返回负数请根据ErrorCodeUtil类注释查看;其他值请在官网-帮助中心查询</returns>
        public int ASFGetGender(out GenderInfo genderInfo)
        {
            int retCode = -1;

            genderInfo = new GenderInfo();
            IntPtr pGenderInfo = MemoryUtil.Malloc(MemoryUtil.SizeOf <ASF_GenderInfo>());

            //调用SDK接口
            retCode = ASFFunctions.ASFGetGender(pEngine, pGenderInfo);
            if (retCode != 0)
            {
                MemoryUtil.Free(pGenderInfo);
                return(retCode);
            }
            //转化结果
            ASF_GenderInfo asfGenderInfo = new ASF_GenderInfo();

            asfGenderInfo  = MemoryUtil.PtrToStructure <ASF_GenderInfo>(pGenderInfo);
            genderInfo.num = asfGenderInfo.num;
            if (genderInfo.num > 0)
            {
                genderInfo.genderArray = new int[genderInfo.num];
                Marshal.Copy(asfGenderInfo.genderArray, genderInfo.genderArray, 0, genderInfo.num);
            }
            MemoryUtil.FreeArray(pGenderInfo);
            return(retCode);
        }
コード例 #17
0
        /// <summary>
        /// 获取年龄结果
        /// </summary>
        /// <param name="pEngine">引擎handle</param>
        /// <param name="ageInfo">out 年龄结果</param>
        /// <returns>返回0表示正常;返回负数请根据ErrorCodeUtil类注释查看;其他值请在官网-帮助中心查询</returns>
        public int ASFGetAge(out AgeInfo ageInfo)
        {
            int retCode = -1;

            ageInfo = new AgeInfo();
            IntPtr pAgeInfo = MemoryUtil.Malloc(MemoryUtil.SizeOf <ASF_AgeInfo>());

            //调用SDK接口
            retCode = ASFFunctions.ASFGetAge(pEngine, pAgeInfo);
            if (retCode != 0)
            {
                MemoryUtil.Free(pAgeInfo);
                return(retCode);
            }
            //转化结果
            ASF_AgeInfo asfAgeInfo = new ASF_AgeInfo();

            asfAgeInfo  = MemoryUtil.PtrToStructure <ASF_AgeInfo>(pAgeInfo);
            ageInfo.num = asfAgeInfo.num;
            if (ageInfo.num > 0)
            {
                ageInfo.ageArray = new int[ageInfo.num];
                Marshal.Copy(asfAgeInfo.ageArray, ageInfo.ageArray, 0, ageInfo.num);
            }
            MemoryUtil.FreeArray(pAgeInfo);
            return(retCode);
        }
コード例 #18
0
ファイル: BR2FileOps.cs プロジェクト: deliverator23/CivNexus6
        public unsafe static void doAppendMeshBinding(IGrannyFile inputFile, IGrannyFile appendFile, Int32 currentModelIndex)
        {
            // Get wrappers
            IGrannyModel       inputModel        = inputFile.Models[currentModelIndex];
            GrannyModelWrapper inputModelWrapper = new GrannyModelWrapper(inputModel);

            IGrannyModel       appendModel        = appendFile.Models[0];
            GrannyModelWrapper appendModelWrapper = new GrannyModelWrapper(appendModel);

            // Update model
            inputModel.MeshBindings.Add(appendFile.Meshes[0]);

            int meshCountInput       = inputModelWrapper.getNumMeshBindings();
            int newMeshBindingsCount = meshCountInput + 1;

            inputModelWrapper.setNumMeshBindings(newMeshBindingsCount);

            // Update model mesh bindings
            int oldMeshBindingsPtr = *(int *)inputModelWrapper.getMeshBindingsPtr();

            *(int *)inputModelWrapper.getMeshBindingsPtr() = (int)Marshal.AllocHGlobal(newMeshBindingsCount * 8);
            int newMeshBindingsPtr = *(int *)inputModelWrapper.getMeshBindingsPtr();

            int modelMeshBindingsPtrAppend = *(int *)appendModelWrapper.getMeshBindingsPtr();

            if (meshCountInput > 0)
            {
                MemoryUtil.MemCpy((void *)newMeshBindingsPtr, (void *)oldMeshBindingsPtr, (uint)(meshCountInput * 8));
            }
            MemoryUtil.MemCpy((void *)(newMeshBindingsPtr + meshCountInput * 8), (void *)modelMeshBindingsPtrAppend, 8);
        }
コード例 #19
0
        /// <summary>
        /// 释放特征值指针
        /// </summary>
        /// <param name="featureIntPtr"></param>
        public static void FreeFeatureIntPtr(IntPtr featureIntPtr)
        {
            var faceFeature = MemoryUtil.PtrToStructure <ASF_FaceFeature>(featureIntPtr);

            MemoryUtil.Free(ref faceFeature.Feature);
            MemoryUtil.Free(ref featureIntPtr);
        }
コード例 #20
0
        /// <summary>
        /// 获取3D角度信息
        /// </summary>
        /// <param name="pEngine">引擎handle</param>
        /// <param name="faceAngle">3D角度信息结果</param>
        /// <returns>返回0表示正常;返回负数请根据ErrorCodeUtil类注释查看;其他值请在官网-帮助中心查询</returns>
        public int ASFGetFace3DAngle(out Face3DAngle faceAngle)
        {
            faceAngle = new Face3DAngle();
            IntPtr pFaceAngle = MemoryUtil.Malloc(MemoryUtil.SizeOf <ASF_Face3DAngle>());
            //调用SDK接口
            int retCode = ASFFunctions.ASFGetFace3DAngle(pEngine, pFaceAngle);

            if (retCode != 0)
            {
                MemoryUtil.Free(pFaceAngle);
                return(retCode);
            }
            //转化结果
            ASF_Face3DAngle asfFaceAngle = MemoryUtil.PtrToStructure <ASF_Face3DAngle>(pFaceAngle);

            faceAngle.num = asfFaceAngle.num;
            if (faceAngle.num > 0)
            {
                faceAngle.pitch = new float[faceAngle.num];
                Marshal.Copy(asfFaceAngle.pitch, faceAngle.pitch, 0, faceAngle.num);
                faceAngle.roll = new float[faceAngle.num];
                Marshal.Copy(asfFaceAngle.roll, faceAngle.roll, 0, faceAngle.num);
                faceAngle.yaw = new float[faceAngle.num];
                Marshal.Copy(asfFaceAngle.yaw, faceAngle.yaw, 0, faceAngle.num);
                faceAngle.status = new int[faceAngle.num];
                Marshal.Copy(asfFaceAngle.status, faceAngle.status, 0, faceAngle.num);
            }
            MemoryUtil.FreeArray(pFaceAngle);
            return(retCode);
        }
コード例 #21
0
        /// <summary>
        /// 获取激活文件信息
        /// </summary>
        /// <param name="activeFileInfo">激活文件信息</param>
        /// <returns>返回0表示正常;返回负数请根据ErrorCodeUtil类注释查看;其他值请在官网-帮助中心查询</returns>
        public int ASFGetActiveFileInfo(out ActiveFileInfo activeFileInfo)
        {
            activeFileInfo = new ActiveFileInfo();
            IntPtr pASFActiveFileInfo = MemoryUtil.Malloc(MemoryUtil.SizeOf <ASF_ActiveFileInfo>());
            //调用SDK接口
            int retCode = ASFFunctions.ASFGetActiveFileInfo(pASFActiveFileInfo);

            if (retCode != 0)
            {
                MemoryUtil.Free(pASFActiveFileInfo);
                return(retCode);
            }
            //转化结果
            ASF_ActiveFileInfo asfActiveFileInfo = MemoryUtil.PtrToStructure <ASF_ActiveFileInfo>(pASFActiveFileInfo);

            activeFileInfo.startTime   = Marshal.PtrToStringAnsi(asfActiveFileInfo.startTime);
            activeFileInfo.endTime     = Marshal.PtrToStringAnsi(asfActiveFileInfo.endTime);
            activeFileInfo.platform    = Marshal.PtrToStringAnsi(asfActiveFileInfo.platform);
            activeFileInfo.sdkType     = Marshal.PtrToStringAnsi(asfActiveFileInfo.sdkType);
            activeFileInfo.appId       = Marshal.PtrToStringAnsi(asfActiveFileInfo.appId);
            activeFileInfo.sdkKey      = Marshal.PtrToStringAnsi(asfActiveFileInfo.sdkKey);
            activeFileInfo.sdkVersion  = Marshal.PtrToStringAnsi(asfActiveFileInfo.sdkVersion);
            activeFileInfo.fileVersion = Marshal.PtrToStringAnsi(asfActiveFileInfo.fileVersion);
            MemoryUtil.Free(pASFActiveFileInfo);
            return(retCode);
        }
コード例 #22
0
ファイル: MainFrm.cs プロジェクト: l12087544/simno
        public void AddQuickChanelButton(string controllerName, IMainController controller, EventHandler eventHandler, int imageIndex, string deptid, string moduleid)
        {
            BarLargeButtonItem item = new BarLargeButtonItem(this.barManager, controllerName)
            {
                Tag = controller
            };

            if (!this._quickChanelDictionary.ContainsKey(moduleid))
            {
                this._quickChanelDictionary.Add(moduleid, item);
            }
            item.ItemClick += delegate(object sender, ItemClickEventArgs e) {
                if (eventHandler != null)
                {
                    this._currentEventHandler = eventHandler;
                    _currentDeptId            = this.GenerateCurrentWstationDeptId(deptid);
                    this._moduleid            = moduleid;
                    UserContextManager.userContext.currentWorkstationModule = this.GenerateSystemModule(moduleid);
                    eventHandler(e.Item.Tag, e);
                    this._currentController = controller;
                }
            };
            this.barItem_quickChanel.ItemLinks.Add(item);
            MemoryUtil.FlushMemory();
        }
コード例 #23
0
        /// <summary>
        /// 人脸特征比对
        /// </summary>
        /// <param name="faceFeature1">特征1</param>
        /// <param name="faceFeature2">特征2</param>
        /// <param name="similarity">相似度</param>
        /// <param name="compareModel">ASF_LIFE_PHOTO:用于生活照之间的特征比对;ASF_ID_PHOTO:用于证件照或证件照和生活照之间的特征比对</param>
        /// <returns>返回0表示正常;返回负数请根据ErrorCodeUtil类注释查看;其他值请在官网-帮助中心查询</returns>
        public int ASFFaceFeatureCompare(FaceFeature faceFeature1, FaceFeature faceFeature2, out float similarity, ASF_CompareModel compareModel = ASF_CompareModel.ASF_LIFE_PHOTO)
        {
            similarity = 0f;
            if (faceFeature1 == null || faceFeature2 == null)
            {
                return(ErrorCodeUtil.FEATURE_IS_NULL);
            }
            #region 将特征对象转化为特征结构体,再转化为非托管内存
            ASF_FaceFeature asfFeatureStruct1 = new ASF_FaceFeature();
            asfFeatureStruct1.featureSize = faceFeature1.featureSize;
            asfFeatureStruct1.feature     = MemoryUtil.Malloc(asfFeatureStruct1.featureSize);
            MemoryUtil.Copy(faceFeature1.feature, 0, asfFeatureStruct1.feature, asfFeatureStruct1.featureSize);
            IntPtr pFeature1 = MemoryUtil.Malloc(MemoryUtil.SizeOf <ASF_FaceFeature>());
            MemoryUtil.StructureToPtr(asfFeatureStruct1, pFeature1);

            ASF_FaceFeature asfFeatureStruct2 = new ASF_FaceFeature();
            asfFeatureStruct2.featureSize = faceFeature2.featureSize;
            asfFeatureStruct2.feature     = MemoryUtil.Malloc(asfFeatureStruct2.featureSize);
            MemoryUtil.Copy(faceFeature2.feature, 0, asfFeatureStruct2.feature, asfFeatureStruct2.featureSize);
            IntPtr pFeature2 = MemoryUtil.Malloc(MemoryUtil.SizeOf <ASF_FaceFeature>());
            MemoryUtil.StructureToPtr(asfFeatureStruct2, pFeature2);
            #endregion
            //调用SDK接口
            int retCode = ASFFunctions.ASFFaceFeatureCompare(pEngine, pFeature1, pFeature2, ref similarity, compareModel);
            MemoryUtil.FreeArray(pFeature1, pFeature2, asfFeatureStruct1.feature, asfFeatureStruct2.feature);

            return(retCode);
        }
コード例 #24
0
ファイル: RunPlugin.cs プロジェクト: xuanximoming/key
        private void OnPluginFormClosed(object sender, FormClosedEventArgs e)
        {
            if (sender == null)
            {
                throw new ArgumentNullException("sender", "未传入插件窗口");
            }

            Form f = sender as Form;

            if (f == null)
            {
                return;
            }
            //在关闭窗口时候释放一下系统内存
            MemoryUtil.FlushMemory();
            //if (_parentMdiChildrenHandles.IndexOf(f.Handle) >= 0)
            //{
            //   _parentMdiChildrenHandles.Remove(f.Handle);
            //}
            for (int i = 0; i < this.PluginsLoaded.Count; i++)
            {
                IPlugIn plugin = (IPlugIn)((IPlugIn)this.PluginsLoaded[i] as PlugIn).Clone();
                if (plugin.MainForm == sender)
                {
                    this.ClosePlugin(plugin);
                    this.PluginsLoaded.Remove(plugin);
                    return;
                }
            }
        }
コード例 #25
0
ファイル: MainFrm.cs プロジェクト: l12087544/simno
        public void AddQuickChanelButton(SystemModuleData moduleData, IMainController controller, EventHandler eventHandler)
        {
            BarLargeButtonItem item;

            if (!string.IsNullOrEmpty(moduleData.moduleType))
            {
                if (this.moduleTypeList.ContainsKey(moduleData.moduleType))
                {
                    item = this.SetBarLargeButtonItem(moduleData, controller, eventHandler);
                    this.moduleTypeList[moduleData.moduleType].ItemLinks.Add(item);
                }
                else
                {
                    BarSubItem item2 = new BarSubItem
                    {
                        Caption = moduleData.moduleType
                    };
                    this.moduleTypeList.Add(moduleData.moduleType, item2);
                    item = this.SetBarLargeButtonItem(moduleData, controller, eventHandler);
                    this.moduleTypeList[moduleData.moduleType].ItemLinks.Add(item);
                    this.barItem_quickChanel.ItemLinks.Add(item2);
                }
            }
            else
            {
                item = this.SetBarLargeButtonItem(moduleData, controller, eventHandler);
                this.barItem_quickChanel.ItemLinks.Add(item);
            }
            MemoryUtil.FlushMemory();
        }
コード例 #26
0
        internal void InitMacroBlockD(ref MacroBlockD xd, ArrayPtr <int> dqcoeff)
        {
            int i;

            for (i = 0; i < Constants.MaxMbPlane; ++i)
            {
                xd.Plane[i].DqCoeff = dqcoeff;
                xd.AboveContext[i]  = AboveContext.Slice(i * 2 * TileInfo.MiColsAlignedToSb(MiCols));

                if (i == 0)
                {
                    MemoryUtil.Copy(ref xd.Plane[i].SegDequant, ref YDequant);
                }
                else
                {
                    MemoryUtil.Copy(ref xd.Plane[i].SegDequant, ref UvDequant);
                }
                xd.Fc = new Ptr <Vp9EntropyProbs>(ref Fc.Value);
            }

            xd.AboveSegContext = AboveSegContext;
            xd.MiStride        = MiStride;
            xd.ErrorInfo       = new Ptr <InternalErrorInfo>(ref Error);

            SetPartitionProbs(ref xd);
        }
コード例 #27
0
 public unsafe void InitContextBuffers()
 {
     DecSetupMi();
     if (!LastFrameSegMap.IsNull)
     {
         MemoryUtil.Fill(LastFrameSegMap.ToPointer(), (byte)0, MiRows * MiCols);
     }
 }
コード例 #28
0
        public static NativeArray <uint> SimpleArray(int count)
        {
            var array = MemoryUtil.TempJobArray <uint>(count);

            new SimpleArrayJob {
                Output = array, Count = count
            }.Run();
            return(array);
        }
コード例 #29
0
ファイル: RunPlugin.cs プロジェクト: xuanximoming/key
 public void RunPlugin(IPlugIn plugin)
 {
     this.m_PluginsLoaded.Add(plugin);
     this._activePlugIn = plugin;
     //加载启动窗体
     this.LoadPluginMainForm(plugin);
     //内存回收
     MemoryUtil.FlushMemory();
 }
コード例 #30
0
        static string GetContent(int processPointer, uint start)
        {
            MemoryUtil.DumpSection(start.ToString("X4") + ".bytes", processPointer, start + ContentOffset, 1000);
            MemoryUtil.Fill(processPointer, buffer, start + ContentOffset);
            var stringLength = ByteUtil.Search(buffer, StringTerminator);
            var content      = Encoding.GetEncoding("UTF-16").GetString(buffer.SubArray(0, (int)stringLength));

            return(content);
        }