Exemple #1
0
 public static void InitFirstTimeLaunchTimestr()
 {
     if (!PreferencesUtil.HasKey(FIRST_LAUNCH_TIME))
     {
         SetFirstTimeLaunchTimestr(DateTime.Now);
     }
 }
        private void asyncIdentity(ImageFrame imageFrame, FaceInfo[] faceInfos)
        {
            if (identityStatus != IDENTITY_IDLE)
            {
                return;
            }

            es.Submit(new Runnable(() =>
            {
                if (faceInfos == null || faceInfos.Length == 0)
                {
                    return;
                }
                int liveType = PreferencesUtil.getInt(LivenessSettingActivity.TYPE_LIVENSS, LivenessSettingActivity
                                                      .TYPE_NO_LIVENSS);
                if (liveType == LivenessSettingActivity.TYPE_NO_LIVENSS)
                {
                    identity(imageFrame, faceInfos[0]);
                }
                else if (liveType == LivenessSettingActivity.TYPE_RGB_LIVENSS)
                {
                    if (rgbLiveness(imageFrame, faceInfos[0]) > FaceEnvironment.LIVENESS_RGB_THRESHOLD)
                    {
                        identity(imageFrame, faceInfos[0]);
                    }
                    else
                    {
                        // toast("rgb活体分数过低");
                    }
                }
            }));
        }
Exemple #3
0
 public static bool RemindMeLaterClicked()
 {
     if (PreferencesUtil.HasKey(REMIND_ME_LATER_CLICK))
     {
         return(PreferencesUtil.GetBoolean(REMIND_ME_LATER_CLICK));
     }
     return(false);
 }
Exemple #4
0
        public static void EventOccured(String key, int dv = 1)
        {
            int v = PreferencesUtil.GetInteger(STATUS_PREFIX + key);

            PreferencesUtil.SetInteger(STATUS_PREFIX + key, v + dv);

            Workflow.AskForRating();
        }
Exemple #5
0
 public static bool AlreadyPopup()
 {
     if (PreferencesUtil.HasKey(ALREADY_ASK_FOR_RATING) &&
         PreferencesUtil.GetBoolean(ALREADY_ASK_FOR_RATING) == true)
     {
         return(true);
     }
     return(false);
 }
Exemple #6
0
 public void show()
 {
     PreferencesUtil.initPrefs(Contexts.ApplicationContext);
     activationDialog = new Dialog(Contexts);
     activationDialog.SetTitle("设备激活");
     activationDialog.SetContentView(initView());
     activationDialog.SetCancelable(false);
     activationDialog.Show();
     addLisenter();
 }
Exemple #7
0
        public static void SetEventCriteria(String key, int v, int initCount = 0)
        {
            keys.Add(key);

            PreferencesUtil.SetInteger(CRITERIA_PREFIX + key, v);

            //initStatus
            if (!PreferencesUtil.HasKey(STATUS_PREFIX + key))
            {
                PreferencesUtil.SetInteger(STATUS_PREFIX + key, initCount);
            }
        }
Exemple #8
0
        public static void ResetCriteria()
        {
            PreferencesUtil.SetBoolean(Criteria.REMIND_ME_LATER_CLICK, false); //reset the remind me
            PreferencesUtil.SetBoolean(Criteria.ALREADY_ASK_FOR_RATING, false);

            SetFirstTimeLaunchTimestr(DateTime.Now);

            foreach (var key in keys)
            {
                ResetEventCount(key, 0);
            }
        }
Exemple #9
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.activity_main);
            imageMatchBtn       = (Button)FindViewById(Resource.Id.image_match_image_btn);
            videoMatchImageBtn  = (Button)FindViewById(Resource.Id.video_match_image_btn);
            videoIdentifyBtn    = (Button)FindViewById(Resource.Id.video_identify_faces_btn);
            userGroupManagerBtn = (Button)FindViewById(Resource.Id.user_groud_manager_btn);
            livenessSettingBtn  = (Button)FindViewById(Resource.Id.liveness_setting_btn);
            deviceActivateBtn   = (Button)FindViewById(Resource.Id.device_activate_btn);
            rgbIrBtn            = (Button)FindViewById(Resource.Id.rgb_ir_btn);
            btAttrTrack         = (Button)FindViewById(Resource.Id.bt_attr_track);
            btMultiThread       = (Button)FindViewById(Resource.Id.bt_multiThread);
            featureSettingBtn   = (Button)FindViewById(Resource.Id.feature_setting_btn);

            imageMatchBtn.SetOnClickListener(this);
            videoMatchImageBtn.SetOnClickListener(this);
            videoIdentifyBtn.SetOnClickListener(this);
            userGroupManagerBtn.SetOnClickListener(this);
            livenessSettingBtn.SetOnClickListener(this);
            deviceActivateBtn.SetOnClickListener(this);
            deviceActivateBtn.SetOnClickListener(this);
            rgbIrBtn.SetOnClickListener(this);
            btAttrTrack.SetOnClickListener(this);
            btMultiThread.SetOnClickListener(this);
            featureSettingBtn.SetOnClickListener(this);


            PreferencesUtil.initPrefs(this);
            // 使用人脸1:n时使用
            DBManager.getInstance().init(this);
            livnessTypeTip();
            //        FaceEnvironment faceEnvironment = new FaceEnvironment();
            //        // 模糊度范围 (0-1) 推荐小于0.7
            //        faceEnvironment.setBlurrinessThreshold(FaceEnvironment.VALUE_BLURNESS);
            //        // 光照范围 (0-1) 推荐大于40
            //        faceEnvironment.setIlluminationThreshold(FaceEnvironment.VALUE_BLURNESS);
            //        // 人脸yaw,pitch,row 角度,范围(-45,45),推荐-15-15
            //        faceEnvironment.setPitch(FaceEnvironment.VALUE_HEAD_PITCH);
            //        faceEnvironment.setRoll(FaceEnvironment.VALUE_HEAD_ROLL);
            //        faceEnvironment.setYaw(FaceEnvironment.VALUE_HEAD_YAW);
            //        // 最小检测人脸(在图片人脸能够被检测到最小值)80-200, 越小越耗性能,推荐120-200
            //        faceEnvironment.setMinFaceSize(FaceEnvironment.VALUE_MIN_FACE_SIZE);
            //        // 人脸置信度(0-1)推荐大于0.6
            //        faceEnvironment.setNotFaceThreshold(FaceEnvironment.VALUE_NOT_FACE_THRESHOLD);
            //        // 人脸遮挡范围 (0-1) 推荐小于0.5
            //        faceEnvironment.setOcclulationThreshold(FaceEnvironment.VALUE_OCCLUSION);
            //        // 是否进行质量检测,开启会降低性能
            //        faceEnvironment.setCheckQuality(false);
            //        FaceSDKManager.getInstance().getFaceDetector().setFaceEnvironment(faceEnvironment);
            FaceSDKManager.init(this);
            FaceSDKManager.getInstance().setSdkInitListener(new SdkInitListener());
        }
Exemple #10
0
        protected void onCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.liveness_setting_layout);
            findView();

            int livenessType = PreferencesUtil.getInt(TYPE_LIVENSS, TYPE_NO_LIVENSS);
            int cameraType   = PreferencesUtil.getInt(GlobalFaceTypeModel.TYPE_CAMERA, GlobalFaceTypeModel.ORBBEC);

            defaultLiveness(livenessType);
            defaultCamera(cameraType);
        }
Exemple #11
0
        private void choiceIdentityType(String groupId)
        {
            int type = PreferencesUtil.getInt(LivenessSettingActivity.TYPE_LIVENSS, LivenessSettingActivity
                                              .TYPE_NO_LIVENSS);

            if (type == LivenessSettingActivity.TYPE_NO_LIVENSS)
            {
                Toast.MakeText(this, "当前活体策略:无活体", ToastLength.Long).Show();
                Intent intent = new Intent(this, typeof(RgbVideoIdentityActivity));
                intent.PutExtra("group_id", groupId);
                StartActivity(intent);
            }
            else if (type == LivenessSettingActivity.TYPE_RGB_LIVENSS)
            {
                Toast.MakeText(this, "当前活体策略:单目RGB活体", ToastLength.Long).Show();
                Intent intent = new Intent(this, typeof(RgbVideoIdentityActivity));
                intent.PutExtra("group_id", groupId);
                StartActivity(intent);
            }
            else if (type == LivenessSettingActivity.TYPE_RGB_IR_LIVENSS)
            {
                Toast.MakeText(this, "当前活体策略:双目RGB+IR活体", ToastLength.Long).Show();
                Intent intent = new Intent(this, typeof(RgbIrVideoIdentifyActivity));
                intent.PutExtra("group_id", groupId);
                StartActivity(intent);
            }
            else if (type == LivenessSettingActivity.TYPE_RGB_DEPTH_LIVENSS)
            {
                Toast.MakeText(this, "当前活体策略:双目RGB+Depth活体", ToastLength.Long).Show();
                int    CameraType = PreferencesUtil.getInt(GlobalFaceTypeModel.TYPE_CAMERA, GlobalFaceTypeModel.ORBBEC);
                Intent intent     = null;
                if (CameraType == GlobalFaceTypeModel.ORBBEC)
                {
                    intent = new Intent(this, typeof(OrbbecVideoIdentifyActivity));
                }
                else if (CameraType == GlobalFaceTypeModel.IMIMECT)
                {
                    intent = new Intent(this, typeof(IminectVideoIdentifyActivity));
                }
                else if (CameraType == GlobalFaceTypeModel.ORBBECPRO)
                {
                    intent = new Intent(this, typeof(OrbbecProVideoIdentifyActivity));
                }
                if (intent != null)
                {
                    intent.PutExtra("group_id", groupId);
                    StartActivity(intent);
                }
            }
        }
Exemple #12
0
        public static int GetEventCriteria(String key)
        {
            var cKey = CRITERIA_PREFIX + key;

            if (PreferencesUtil.HasKey(cKey))
            {
                return(PreferencesUtil.GetInteger(cKey));
            }

            if (defaultCriteria.ContainsKey(cKey))
            {
                return(defaultCriteria[cKey]);
            }

            return(0);
        }
Exemple #13
0
        private void offLineActive(String path)
        {
            if (FaceSDK.AuthorityStatus == AndroidLicenser.ErrorCode.Success.Ordinal())
            {
                Toast.MakeText(this, "已经激活成功", ToastLength.Long).Show();
                return;
            }

            String firstPath = path + "/" + "License.zip";

            if (fileIsExists(firstPath))
            {
                if (!TextUtils.IsEmpty(firstPath))
                {
                    ZipUtil.unzip(firstPath);
                }
                if (ZipUtil.isSuccess)
                {
                    String secondPath = path + "/" + "Win.zip";
                    if (!TextUtils.IsEmpty(secondPath))
                    {
                        ZipUtil.unzip(secondPath);
                    }
                }
                String keyPath = path + "/" + "license.key";
                String key     = readFile(keyPath, "key");
                PreferencesUtil.putString("activate_key", key);
                String liscensePaht = path + "/" + "license.ini";
                String liscense     = readFile(liscensePaht, "liscense");
                success = FileUitls.c(this, FaceSDKManager.LICENSE_NAME, list);
                if (success)
                {
                    toast("激活成功");
                    FaceSDKManager.initStatus = FaceSDKManager.SDK_UNINIT;
                    FaceSDKManager.init(this);
                }
                else
                {
                    toast("激活失败");
                }
            }
            else
            {
                toast("授权文件不存在!");
            }
        }
Exemple #14
0
        private void choiceAttrTrackType()
        {
            int type = PreferencesUtil.getInt(LivenessSettingActivity.TYPE_LIVENSS, LivenessSettingActivity
                                              .TYPE_NO_LIVENSS);

            if (type == LivenessSettingActivity.TYPE_NO_LIVENSS)
            {
                Toast.MakeText(this, "当前活体策略:无活体", ToastLength.Long).Show();
                Intent intent = new Intent(this, typeof(RgbVideoAttributeTrackActivity));
                StartActivity(intent);
            }
            else if (type == LivenessSettingActivity.TYPE_RGB_LIVENSS)
            {
                Toast.MakeText(this, "当前活体策略:单目RGB活体", ToastLength.Long).Show();
                Intent intent = new Intent(this, typeof(RgbVideoAttributeTrackActivity));
                StartActivity(intent);
            }
            else if (type == LivenessSettingActivity.TYPE_RGB_IR_LIVENSS)
            {
                Toast.MakeText(this, "当前活体策略:双目RGB+IR活体", ToastLength.Long).Show();
                Intent intent = new Intent(this, typeof(RgbIrVideoAttributeActivity));
                StartActivity(intent);
            }
            else if (type == LivenessSettingActivity.TYPE_RGB_DEPTH_LIVENSS)
            {
                Toast.MakeText(this, "当前活体策略:双目RGB+Depth活体", ToastLength.Long).Show();
                int    CameraType = PreferencesUtil.getInt(GlobalFaceTypeModel.TYPE_CAMERA, GlobalFaceTypeModel.ORBBEC);
                Intent intent     = null;
                if (CameraType == GlobalFaceTypeModel.ORBBEC)
                {
                    intent = new Intent(this, typeof(OrbbecVideoAttributeActivity));
                }
                else if (CameraType == GlobalFaceTypeModel.IMIMECT)
                {
                    intent = new Intent(this, typeof(IminectVideoAtrributeActivity));
                }
                else if (CameraType == GlobalFaceTypeModel.ORBBECPRO)
                {
                    intent = new Intent(this, typeof(OrbbecProVideoAttributeActivity));
                }
                StartActivity(intent);
            }
        }
Exemple #15
0
        /**
         * FaceSDK 初始化,用户可以根据自己的需求实例化FaceTracker 和 FaceRecognize
         *
         * @param context
         */
        public static void init(Context context)
        {
            Context = context;
            if (!check())
            {
                initStatus = SDK_UNACTIVATION;
                return;
            }
            PreferencesUtil.initPrefs(context.ApplicationContext);
            // final String key = "faceexample-face-android";
            string key = PreferencesUtil.getString("activate_key", "");

            if (Android.Text.TextUtils.IsEmpty(key))
            {
                Toast.MakeText(context, "激活序列号为空, 请先激活", ToastLength.Short).Show();
                return;
            }

            initStatus = SDK_INITING;
            Task.Run(() => { run(key); });
        }
        private void identity(ImageFrame imageFrame, FaceInfo faceInfo)
        {
            float raw   = Java.Lang.Math.Abs(faceInfo.HeadPose[0]);
            float patch = Java.Lang.Math.Abs(faceInfo.HeadPose[1]);
            float roll  = Java.Lang.Math.Abs(faceInfo.HeadPose[2]);

            // 人脸的三个角度大于20不进行识别
            if (raw > 20 || patch > 20 || roll > 20)
            {
                return;
            }

            identityStatus = IDENTITYING;

            long starttime = DateTime.Now.Millisecond;

            int[] argb = imageFrame.getArgb();
            int   rows = imageFrame.getHeight();
            int   cols = imageFrame.getWidth();

            int[] landmarks = faceInfo.Landmarks.ToArray();

            int         type        = PreferencesUtil.getInt(GlobalFaceTypeModel.TYPE_MODEL, GlobalFaceTypeModel.RECOGNIZE_LIVE);
            IdentifyRet identifyRet = null;

            if (type == GlobalFaceTypeModel.RECOGNIZE_LIVE)
            {
                identifyRet = FaceApi.getInstance().identity(argb, rows, cols, landmarks, groupId);
            }
            else if (type == GlobalFaceTypeModel.RECOGNIZE_ID_PHOTO)
            {
                identifyRet = FaceApi.getInstance().identityForIDPhoto(argb, rows, cols, landmarks, groupId);
            }
            if (identifyRet != null)
            {
                displayUserOfMaxScore(identifyRet.getUserId(), identifyRet.getScore());
            }
            identityStatus = IDENTITY_IDLE;
            displayTip("特征抽取对比耗时:" + (DateTime.Now.Millisecond - starttime), featureDurationTv);
        }
Exemple #17
0
        private void livnessTypeTip()
        {
            int type = PreferencesUtil.getInt(LivenessSettingActivity.TYPE_LIVENSS, LivenessSettingActivity
                                              .TYPE_NO_LIVENSS);

            if (type == LivenessSettingActivity.TYPE_NO_LIVENSS)
            {
                Toast.MakeText(this, "当前活体策略:无活体, 请选用普通USB摄像头", ToastLength.Long).Show();
            }
            else if (type == LivenessSettingActivity.TYPE_RGB_LIVENSS)
            {
                Toast.MakeText(this, "当前活体策略:单目RGB活体, 请选用普通USB摄像头", ToastLength.Long).Show();
            }
            else if (type == LivenessSettingActivity.TYPE_RGB_IR_LIVENSS)
            {
                Toast.MakeText(this, "当前活体策略:双目RGB+IR活体, 请选用RGB+IR摄像头",
                               ToastLength.Long).Show();
            }
            else if (type == LivenessSettingActivity.TYPE_RGB_DEPTH_LIVENSS)
            {
                Toast.MakeText(this, "当前活体策略:双目RGB+Depth活体,请选用RGB+Depth摄像头", ToastLength.Long).Show();
            }
        }
Exemple #18
0
        private static void parse(JSONObject json, string key)
        {
            bool       success = false;
            JSONObject result  = json.OptJSONObject("result");

            if (result != null)
            {
                string license = result.OptString("license");
                if (!TextUtils.IsEmpty(license))
                {
                    string[] licenses = license.Split(',');
                    if (licenses != null && licenses.Length == 2)
                    {
                        PreferencesUtil.putString("activate_key", key);
                        Java.Util.ArrayList list = new Java.Util.ArrayList();
                        list.Add(licenses[0]);
                        list.Add(licenses[1]);
                        success = FileUitls.c(Contexts, FaceSDKManager.LICENSE_NAME, list);
                    }
                }
            }

            if (success)
            {
                toast("激活成功");
                if (activationCallback != null)
                {
                    activationCallback.callback(true);
                    activationDialog.Dismiss();
                }
            }
            else
            {
                toast("激活失败");
            }
        }
Exemple #19
0
        public static bool EnoughTimeAfterFirstLaunch()
        {
            //check how long after first launch
            DateTime now = DateTime.Now;
            string   firstLaunchTimeStr = PreferencesUtil.GetString(FIRST_LAUNCH_TIME);
            DateTime firstLaunchTime    = new DateTime();

            try
            {
                firstLaunchTime = Convert.ToDateTime(firstLaunchTimeStr);
            }
            catch (Exception e)
            {
                SetFirstTimeLaunchTimestr(DateTime.Now);
                return(false);
            }

            if ((now - firstLaunchTime).TotalDays < GetEventCriteria(KEY_MIN_DAY_AFTER_FIRST_LAUNCH))
            {
                return(false);
            }

            return(true);
        }
Exemple #20
0
        public static void SetFirstTimeLaunchTimestr(DateTime tm)
        {
            string firstLaunchTimeStr = tm.ToString();

            PreferencesUtil.SetString(FIRST_LAUNCH_TIME, firstLaunchTimeStr);
        }
Exemple #21
0
 public static string GetFirstTimeLaunchTimestr()
 {
     return(PreferencesUtil.GetString(FIRST_LAUNCH_TIME));
 }
Exemple #22
0
 public static int GetEventCount(String key)
 {
     return(PreferencesUtil.GetInteger(STATUS_PREFIX + key));
 }
Exemple #23
0
        private LinearLayout initView()
        {
            device = AndroidLicenser.Get_device_id(Contexts.ApplicationContext);
            LinearLayout root = new LinearLayout(Contexts);

            root.Orientation = Android.Widget.Orientation.Vertical;
            LinearLayout.LayoutParams rootParams = new LinearLayout.LayoutParams(
                ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.MatchParent);
            rootParams.Gravity = GravityFlags.Center;
            root.SetBackgroundColor(Android.Graphics.Color.White);
            root.Focusable            = true;
            root.FocusableInTouchMode = true;

            TextView titleTv = new TextView(Contexts);

            titleTv.Text     = "设备激活";
            titleTv.TextSize = dip2px(15);
            titleTv.SetTextColor(Contexts.Resources.GetColor(Android.Resource.Color.Black));

            LinearLayout.LayoutParams titleParams = new LinearLayout.LayoutParams(
                LinearLayout.LayoutParams.WrapContent,
                LinearLayout.LayoutParams.WrapContent);
            titleParams.Gravity     = GravityFlags.Center;
            titleParams.TopMargin   = dip2px(10);
            titleParams.RightMargin = dip2px(30);
            titleParams.LeftMargin  = dip2px(30);

            deviceIdTv = new TextView(Contexts);
            deviceIdTv.SetTextIsSelectable(true);
            deviceIdTv.Text     = "设备指纹:" + device;
            deviceIdTv.TextSize = dip2px(12);
            deviceIdTv.SetTextColor(Contexts.Resources.GetColor(Android.Resource.Color.Black));

            LinearLayout.LayoutParams deviceIdParams = new LinearLayout.LayoutParams(
                LinearLayout.LayoutParams.WrapContent,
                LinearLayout.LayoutParams.WrapContent);
            deviceIdParams.Gravity     = GravityFlags.Center;
            deviceIdParams.TopMargin   = dip2px(40);
            deviceIdParams.RightMargin = dip2px(30);
            deviceIdParams.LeftMargin  = dip2px(30);

            KeyEt      = new EditText(Contexts);
            KeyEt.Hint = "输入序列号";
            KeyEt.Text = PreferencesUtil.getString("activate_key", "");
            // keyEt.setText("VMVY-PLkd-OsJN-veIc");

            LinearLayout.LayoutParams keyParams = new LinearLayout.LayoutParams(
                LinearLayout.LayoutParams.WrapContent, LinearLayout.LayoutParams.WrapContent);
            keyParams.Gravity          = GravityFlags.Center;
            keyParams.TopMargin        = dip2px(40);
            keyParams.RightMargin      = dip2px(30);
            keyParams.LeftMargin       = dip2px(30);
            KeyEt.TransformationMethod = new AllCapTransformationMethod(true);
            KeyEt.SetWidth(dip2px(260));

            LinearLayout.LayoutParams activateParams = new LinearLayout.LayoutParams(dip2px(180), dip2px(40));
            activateParams.Gravity     = GravityFlags.Center;
            activateParams.TopMargin   = dip2px(40);
            activateParams.RightMargin = dip2px(40);
            activateParams.LeftMargin  = dip2px(40);
            activateBtn = new Button(Contexts);
            // activateBtn.setId(100);
            activateBtn.Text     = "在线激活";
            activateBtn.TextSize = dip2px(12);
            activateBtn.SetTextColor(Contexts.Resources.GetColor(Android.Resource.Color.White));
            activateBtn.SetBackgroundColor(Contexts.Resources.GetColor(Resource.Color.material_blue_grey_800));

            LinearLayout.LayoutParams activateParamsone = new LinearLayout.LayoutParams(dip2px(360), dip2px(48));
            activateParamsone.Gravity     = GravityFlags.Center;
            activateParamsone.TopMargin   = dip2px(8);
            activateParamsone.RightMargin = dip2px(20);
            activateParamsone.LeftMargin  = dip2px(60);
            tvOnLineText          = new TextView(Contexts);
            tvOnLineText.Text     = "在线激活:输入序列号,保持设备联网,SDK会自动进行激活";
            tvOnLineText.TextSize = dip2px(8);
            tvOnLineText.SetTextColor(Contexts.Resources.GetColor(Android.Resource.Color.White));

            LinearLayout.LayoutParams activateParamsoffLine = new LinearLayout.LayoutParams(dip2px(180), dip2px(40));
            activateParamsoffLine.Gravity     = GravityFlags.Center;
            activateParamsoffLine.TopMargin   = dip2px(5);
            activateParamsoffLine.RightMargin = dip2px(40);
            activateParamsoffLine.LeftMargin  = dip2px(40);
            btOffLineActive = new Button(Contexts);
            // activateBtn.setId(100);
            activateBtn.Text     = "离线激活";
            activateBtn.TextSize = dip2px(12);
            activateBtn.SetTextColor(Contexts.Resources.GetColor(Android.Resource.Color.White));
            activateBtn.SetBackgroundColor(Contexts.Resources.GetColor(Resource.Color.material_blue_grey_800));


            LinearLayout.LayoutParams tvOffLineParams = new LinearLayout.LayoutParams(dip2px(380), dip2px(48));
            tvOffLineParams.Gravity     = GravityFlags.Center;
            tvOffLineParams.TopMargin   = dip2px(8);
            tvOffLineParams.RightMargin = dip2px(20);
            tvOffLineParams.LeftMargin  = dip2px(20);
            tvOffLineText          = new TextView(Contexts);
            tvOffLineText.Text     = "离线激活:将激活文件置于SD卡根目录(/storage/emulated/0)中,SDK会自动进行激活";
            tvOffLineText.TextSize = dip2px(8);
            tvOffLineText.SetTextColor(Contexts.Resources.GetColor(Android.Resource.Color.White));

            LinearLayout.LayoutParams backParams = new LinearLayout.LayoutParams(dip2px(180), dip2px(40));
            backParams.Gravity      = GravityFlags.Center;
            backParams.TopMargin    = dip2px(5);
            backParams.BottomMargin = dip2px(20);
            backParams.RightMargin  = dip2px(40);
            backParams.LeftMargin   = dip2px(40);
            backBtn = new Button(Contexts);
            // activateBtn.setId(100);
            backBtn.Text = "返      回";
            backBtn.SetTextColor(Contexts.Resources.GetColor(Android.Resource.Color.White));
            backBtn.SetBackgroundColor(Contexts.Resources.GetColor(Resource.Color.material_blue_grey_800));
            backBtn.TextSize = dip2px(12);

            root.AddView(titleTv, titleParams);
            root.AddView(deviceIdTv, deviceIdParams);
            root.AddView(KeyEt, keyParams);
            root.AddView(activateBtn, activateParams);
            root.AddView(tvOnLineText, activateParamsone);
            root.AddView(btOffLineActive, activateParamsoffLine);
            root.AddView(tvOffLineText, tvOffLineParams);
            root.AddView(backBtn, backParams);
            return(root);
        }
Exemple #24
0
        public static bool SatisfyCriteria()
        {
            //We only pop up the rating when user is online
            if (!AppServices.IsConnectedToInternet())
            {
                return(false);
            }

            //Check whether it is enough time after first launch
            if (!EnoughTimeAfterFirstLaunch())
            {
                return(false);
            }

            if (AlreadyPopup())
            {
                if (!RemindMeLaterClicked())
                {
                    //if not in reminder me status
                    return(false);
                }

                //if and only if the customer clicked remind_me_later, we can pop up
                DateTime now = DateTime.Now;
                string   remindMeLaterTimeStr = PreferencesUtil.GetString(REMIND_ME_LATER_CLICK_TIME);
                DateTime remindMeLaterTime    = new DateTime();

                try
                {
                    remindMeLaterTime = Convert.ToDateTime(remindMeLaterTimeStr);
                }
                catch (Exception e)
                {
                    remindMeLaterTimeStr = DateTime.Now.ToString();
                    remindMeLaterTime    = DateTime.Now;

                    PreferencesUtil.SetString(REMIND_ME_LATER_CLICK_TIME, remindMeLaterTimeStr);
                }

                //if it is less than 5 day after user click reminder me later, we cannot pop up
                if ((now - remindMeLaterTime).TotalDays < GetEventCriteria(KEY_TIME_GAP_BETWEEN_REMINDER_ME))
                {
                    return(false);
                }

                //continue to see whether it satisfy other conditions
            }

            Dictionary <int, bool> groupSatisfy = new Dictionary <int, bool>();

            foreach (var item in keyGroup)
            {
                if (!groupSatisfy.ContainsKey(item.Value))
                {
                    groupSatisfy.Add(item.Value, false);
                }
            }

            //iterate all other criteria
            foreach (var key in keys)
            {
                if (key == CRITERIA_PREFIX + KEY_TIME_GAP_BETWEEN_REMINDER_ME)
                {
                    //already iterated
                    continue;
                }

                if (GetEventCount(key) < GetEventCriteria(key))
                {
                    if (!keyGroup.ContainsKey(key))
                    {
                        return(false);
                    }
                }
                else
                {
                    if (keyGroup.ContainsKey(key))
                    {
                        groupSatisfy[keyGroup[key]] = true;
                    }
                }
            }

            //check whether all criteria group has satisfy the condition
            foreach (var item in groupSatisfy)
            {
                if (!item.Value)
                {
                    return(false);
                }
            }


            return(true);
        }
Exemple #25
0
 public void OnClick(View v)
 {
     if (v == autoDetectBtn)
     {
         if (ActivityCompat.CheckSelfPermission(this, Manifest.Permission.WriteExternalStorage)
             != Permission.Granted || ActivityCompat.CheckSelfPermission(this, Manifest
                                                                         .Permission.Camera) != Permission.Granted)
         {
             ActivityCompat.RequestPermissions(this, new String[] { Manifest.Permission.WriteExternalStorage,
                                                                    Manifest.Permission.Camera }, 100);
             return;
         }
         avatarIv.SetImageResource(Resource.Drawable.avatar);
         faceImagePath = null;
         int type = PreferencesUtil.getInt(LivenessSettingActivity.TYPE_LIVENSS, LivenessSettingActivity
                                           .TYPE_NO_LIVENSS);
         if (type == LivenessSettingActivity.TYPE_NO_LIVENSS || type == LivenessSettingActivity.TYPE_RGB_LIVENSS)
         {
             Intent intent = new Intent(this, typeof(RgbDetectActivity));
             intent.PutExtra("source", SOURCE_REG);
             StartActivityForResult(intent, REQUEST_CODE_AUTO_DETECT);
         }
         else if (type == LivenessSettingActivity.TYPE_RGB_IR_LIVENSS)
         {
             Intent intent = new Intent(this, typeof(RgbIrLivenessActivity));
             intent.PutExtra("source", SOURCE_REG);
             StartActivityForResult(intent, REQUEST_CODE_AUTO_DETECT);
         }
         //else if (type == LivenessSettingActivity.TYPE_RGB_DEPTH_LIVENSS)
         //{
         //    int cameraType = PreferencesUtil.getInt(GlobalFaceTypeModel.TYPE_CAMERA, GlobalFaceTypeModel.ORBBEC);
         //    Intent intent3 = null;
         //    if (cameraType == GlobalFaceTypeModel.ORBBEC)
         //    {
         //        intent3 = new Intent(this, typeof(OrbbecLivenessDetectActivity));
         //    }
         //    else if (cameraType == GlobalFaceTypeModel.IMIMECT)
         //    {
         //        intent3 = new Intent(this, typeof(IminectLivenessDetectActivity));
         //    }
         //    else if (cameraType == GlobalFaceTypeModel.ORBBECPRO)
         //    {
         //        intent3 = new Intent(this, typeof(OrbbecProLivenessDetectActivity));
         //    }
         //    if (intent3 != null)
         //    {
         //        intent3.PutExtra("source", SOURCE_REG);
         //        StartActivityForResult(intent3, REQUEST_CODE_AUTO_DETECT);
         //    }
         //}
     }
     else if (v == fromAlbumButton)
     {
         if (ActivityCompat.CheckSelfPermission(this, Manifest.Permission.ReadExternalStorage)
             != Permission.Granted)
         {
             //ActivityCompat.requestPermissions(this, new String[] { Manifest.permission.READ_EXTERNAL_STORAGE }, 100);
             return;
         }
         avatarIv.SetImageResource(Resource.Drawable.avatar);
         faceImagePath = null;
         Intent intent = new Intent(Intent.ActionPick);
         intent.SetType("image/*");
         StartActivityForResult(intent, REQUEST_CODE_PICK_IMAGE);
     }
     else if (v == submitButton)
     {
         register(faceImagePath);
     }
 }
Exemple #26
0
        public static void ClickReminderMe()
        {
            PreferencesUtil.SetBoolean(REMIND_ME_LATER_CLICK, true);

            PreferencesUtil.SetString(REMIND_ME_LATER_CLICK_TIME, DateTime.Now.ToString());
        }
Exemple #27
0
        private String filter(FaceInfo faceInfo, ImageFrame imageFrame)
        {
            String tip = "";

            if (faceInfo.MConf < 0.6)
            {
                tip = "人脸置信度太低";
                return(tip);
            }

            float[] headPose = faceInfo.HeadPose.ToArray();
            if (Math.Abs(headPose[0]) > 20 || Math.Abs(headPose[1]) > 20 || Math.Abs(headPose[2]) > 20)
            {
                tip = "人脸置角度太大,请正对屏幕";
                return(tip);
            }

            int width  = imageFrame.getWidth();
            int height = imageFrame.getHeight();
            // 判断人脸大小,若人脸超过屏幕二分一,则提示文案“人脸离手机太近,请调整与手机的距离”;
            // 若人脸小于屏幕三分一,则提示“人脸离手机太远,请调整与手机的距离”
            float ratio = (float)faceInfo.MWidth / (float)height;

            Log.Info("liveness_ratio", "ratio=" + ratio);
            if (ratio > 0.6)
            {
                tip = "人脸离屏幕太近,请调整与屏幕的距离";
                return(tip);
            }
            else if (ratio < 0.2)
            {
                tip = "人脸离屏幕太远,请调整与屏幕的距离";
                return(tip);
            }
            else if (faceInfo.MCenterX > width * 3 / 4)
            {
                tip = "人脸在屏幕中太靠右";
                return(tip);
            }
            else if (faceInfo.MCenterX < width / 4)
            {
                tip = "人脸在屏幕中太靠左";
                return(tip);
            }
            else if (faceInfo.MCenterY > height * 3 / 4)
            {
                tip = "人脸在屏幕中太靠下";
                return(tip);
            }
            else if (faceInfo.MCenterX < height / 4)
            {
                tip = "人脸在屏幕中太靠上";
                return(tip);
            }

            int liveType = PreferencesUtil.getInt(LivenessSettingActivity.TYPE_LIVENSS, LivenessSettingActivity
                                                  .TYPE_NO_LIVENSS);

            if (liveType == LivenessSettingActivity.TYPE_NO_LIVENSS)
            {
                saveFace(faceInfo, imageFrame);
            }
            else if (liveType == LivenessSettingActivity.TYPE_RGB_LIVENSS)
            {
                if (rgbLiveness(imageFrame, faceInfo) > 0.9)
                {
                    saveFace(faceInfo, imageFrame);
                }
                else
                {
                    toast("rgb活体分数过低");
                }
            }


            return(tip);
        }
Exemple #28
0
 public static void PopUpEnjoyment()
 {
     PreferencesUtil.SetBoolean(Criteria.REMIND_ME_LATER_CLICK, false); //reset the remind me
     PreferencesUtil.SetBoolean(Criteria.ALREADY_ASK_FOR_RATING, true);
 }
Exemple #29
0
 public static void ResetEventCount(String key, int v = 0)
 {
     PreferencesUtil.SetInteger(STATUS_PREFIX + key, v);
 }