Ejemplo n.º 1
0
        public string Init()
        {
            uint lResult;

            // 初始化SDK
            lResult = NETSDK.SIRIUS_Init();
            if (0 != lResult)
            {
                var msg = string.Format("初始化SDK失败!错误编码:{0:d}。", lResult);
                Log.WriteLog("ERROR-FACEID:" + msg);
            }
            Console.WriteLine("初始化SDK成功!");

            // 登录服务器
            var serverInfo = this.GetServerInfo();

            NETSDK.USER_LOGIN_INFO stLoginInfo;
            stLoginInfo.szIPAddr   = serverInfo.Host;
            stLoginInfo.iPort      = serverInfo.Port;
            stLoginInfo.szUserName = serverInfo.Username;
            stLoginInfo.szPassWord = serverInfo.Password;
            lResult = NETSDK.SIRIUS_Login(ref stLoginInfo, ref UserID);
            if (0 != lResult)
            {
                var msg = string.Format("登录FaceID服务器失败!错误编码:{2:d}。"
                                        , stLoginInfo.szIPAddr
                                        , stLoginInfo.iPort
                                        , lResult
                                        );
                Log.WriteLog("ERROR-FACEID:" + msg);

                return(msg);
            }
            else
            {
                Log.WriteLog(string.Format("INFO-FACEID:登录FaceID服务器成功!", stLoginInfo.szIPAddr, stLoginInfo.iPort));
            }

            return("");
        }
Ejemplo n.º 2
0
        public int SearchByPic(string picPath)
        {
            uint lResult;

            pWaitFlag = Marshal.AllocHGlobal(sizeof(uint));//声明一个同样大小的空间
            Marshal.WriteInt32(pWaitFlag, 1);
            int iWaitFlag = Marshal.ReadInt32(pWaitFlag);

            mycall  = new NETSDK.SIRIUS_pfnMessageCallBack(this.MessageCallBack);
            lResult = NETSDK.SIRIUS_SetMessageCallBack(mycall, pWaitFlag);
            if (0 != lResult)
            {
                Console.WriteLine("注册回调函数失败!错误编码:{0:d}", lResult);
                return(-1);
            }
            Console.WriteLine("注册回调函数成功!");

            // 登录服务器
            NETSDK.USER_LOGIN_INFO stLoginInfo;
            stLoginInfo.szIPAddr   = "127.0.0.1";
            stLoginInfo.iPort      = 8612;
            stLoginInfo.szUserName = "******";
            stLoginInfo.szPassWord = "******";
            lResult = NETSDK.SIRIUS_Login(ref stLoginInfo, ref UserID);
            if (0 != lResult)
            {
                Console.WriteLine("登录服务器[{0:s}:{1:d}]失败!错误编码:{2:d}"
                                  , stLoginInfo.szIPAddr
                                  , stLoginInfo.iPort
                                  , lResult
                                  );
                return(-1);
            }
            Console.WriteLine("登录服务器[{0:s}:{1:d}]成功!", stLoginInfo.szIPAddr, stLoginInfo.iPort);

            // 条件对象
            NETSDK.SEARCH_COND stSearchCond;
            stSearchCond.Index        = 0;
            stSearchCond.PageNum      = 10;
            stSearchCond.szStartTime  = "";
            stSearchCond.szStopTime   = "";
            stSearchCond.iCameraIndex = 0;
            stSearchCond.szName       = "";
            stSearchCond.iMinSim      = 0;
            stSearchCond.iMaxSim      = 0;

            lResult = NETSDK.SIRIUS_SearchModelFaceByPic(UserID, picPath, ref stSearchCond);
            if (0 != lResult)
            {
                Console.WriteLine("以图搜图失败!错误编码:{0:d}", lResult);
                lResult = NETSDK.SIRIUS_Logout(UserID);

                Thread.Sleep(1 * 1000); // Notes:等待注销消息
                return(-1);
            }
            else
            {
                Console.WriteLine("以图搜图成功!");
            }

            int iDuration = 3000;

            while (iDuration-- > 0)
            {
                iWaitFlag = Marshal.ReadInt32(pWaitFlag);
                if (iWaitFlag == 0)
                {
                    Console.WriteLine("收到反馈消息,等待结束");
                    break;
                }
                else
                {
                    if (iDuration % 10 == 0)
                    {
                        Console.WriteLine("等待消息...");
                    }
                    Thread.Sleep(1 * 100);
                }
            }

            // 注销服务器
            lResult = NETSDK.SIRIUS_Logout(UserID);
            if (0 != lResult)
            {
                Console.WriteLine("注销服务器失败!错误编码:{2:d}", lResult);
                return(-2);
            }
            Console.WriteLine("注销服务器成功!");
            Thread.Sleep(1 * 1000); // Notes:等待注销消息

            UserID = 0;
            return(0);
        }