Example #1
0
        protected override async void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            SetContentView(Resource.Layout.FaceIdentify);

            this.cameraPreview  = this.FindViewById <CameraSourcePreview>(Resource.Id.preview);
            this.graphicOverlay = this.FindViewById <GraphicOverlay>(Resource.Id.faceOverlay);

            var button = (ImageButton)this.FindViewById(Resource.Id.flipButton);

            button.Click += (sender, args) =>
            {
                this.isFrontFacing = !this.isFrontFacing;

                if (this.cameraSource != null)
                {
                    this.cameraSource.Release();
                    this.cameraSource = null;
                }

                this.CreateCameraSource();
                this.StartCameraSource();
            };

            if (ActivityCompat.CheckSelfPermission(this, Manifest.Permission.Camera) == Permission.Granted)
            {
                this.CreateCameraSource();
                LiveCamHelper.Init();
                LiveCamHelper.GreetingsCallback     = (s) => { this.RunOnUiThread(() => Greetings = s); };
                LiveCamHelper.FacesDetectedCallback = result => { this.RunOnUiThread(() => CognitiveFacesResult = result); };

                this.faceService = new FaceService();
                await this.faceService.Initialize();

                //using (var stream = File.OpenRead("/data/user/0/CognitiveDemo.Droid/files/CognitivveFrame.png"))
                //{
                //    await this.faceService.IdentityFace(stream);
                //}
            }
            else
            {
                this.RequestCameraPermission();
            }
        }
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.face_recognition);

            BTArduino = new BlueToothConnectionPortable();

            mPreview        = FindViewById <CameraSourcePreview>(Resource.Id.preview);
            mGraphicOverlay = FindViewById <GraphicOverlay>(Resource.Id.faceOverlay);

            if (ActivityCompat.CheckSelfPermission(this, Manifest.Permission.Camera) == Permission.Granted)
            {
                CreateCameraSource();
                LiveCamHelper.Init();
                LiveCamHelper.GreetingsCallback = (s) => { RunOnUiThread(() => GreetingsText = s); };
                //Task.Run(() => LiveCamHelper.RegisterFaces());
            }
            else
            {
                RequestCameraPermission();
            }
        }
Example #3
0
        protected async override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Main);

            mPreview        = FindViewById <CameraSourcePreview>(Resource.Id.preview);
            mGraphicOverlay = FindViewById <GraphicOverlay>(Resource.Id.faceOverlay);
            //greetingsText = FindViewById<TextView>(Resource.Id.greetingsTextView);


            if (ActivityCompat.CheckSelfPermission(this, Manifest.Permission.Camera) == Permission.Granted)
            {
                CreateCameraSource();
                LiveCamHelper.Init();
                LiveCamHelper.GreetingsCallback = (s) => { RunOnUiThread(() => GreetingsText = s); };
                //await LiveCamHelper.RegisterFaces();
            }
            else
            {
                RequestCameraPermission();
            }
        }