コード例 #1
0
        public override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            AssetManager assets      = Activity.Assets;
            var          filesToCopy = new string[] { "runtime_data/openalpr.conf"
                                                      , "runtime_data/region/eu.xml" };

            var AndroidDataDir       = Android.App.Application.Context.DataDir.AbsolutePath;
            var runtimeFolder        = new Java.IO.File(AndroidDataDir, "/files/runtime_data");
            var renamedRuntimeFolder = new Java.IO.File(AndroidDataDir, "runtime_data");

            runtimeFolder.RenameTo(renamedRuntimeFolder);

            var list = renamedRuntimeFolder.List();

            OpenALPRConfigFile = AndroidDataDir + "/runtime_data/openalpr.conf";

            var f       = new Java.IO.File(AndroidDataDir);
            var flist   = f.List();
            var lib     = new Java.IO.File(f, "lib");
            var liblist = lib.List();

            mStateCallback          = new CameraStateListener(this);
            mSurfaceTextureListener = new Camera2BasicSurfaceTextureListener(this);
            OpenALPRInstance        = new OpenALPR(this.Activity, AndroidDataDir, OpenALPRConfigFile, "eu", "ua");

            // fill ORIENTATIONS list
            ORIENTATIONS.Append((int)SurfaceOrientation.Rotation0, 90);
            ORIENTATIONS.Append((int)SurfaceOrientation.Rotation90, 0);
            ORIENTATIONS.Append((int)SurfaceOrientation.Rotation180, 270);
            ORIENTATIONS.Append((int)SurfaceOrientation.Rotation270, 180);
        }
コード例 #2
0
        public CameraFragment(CameraPageRenderer cpr, View view, Activity activity)
        {
            mCPR = cpr;

            mStateCallback          = new CameraStateListener(this);
            mSurfaceTextureListener = new CameraSurfaceTextureListener(this);

            Activity = activity;

            // fill ORIENTATIONS list
            ORIENTATIONS.Append((int)SurfaceOrientation.Rotation0, 90);
            ORIENTATIONS.Append((int)SurfaceOrientation.Rotation90, 0);
            ORIENTATIONS.Append((int)SurfaceOrientation.Rotation180, 270);
            ORIENTATIONS.Append((int)SurfaceOrientation.Rotation270, 180);

            mTextureView = (AutoFitTextureView)view.FindViewById(Resource.Id.texture);
            view.FindViewById(Resource.Id.snap_button).SetOnClickListener(this);
            view.FindViewById(Resource.Id.gallery_button).SetOnClickListener(this);
            mFlashButton = view.FindViewById <ImageButton>(Resource.Id.flash_button);
            mFlashButton.SetOnClickListener(this);
            view.FindViewById(Resource.Id.back_button).SetOnClickListener(this);
            ImageDisplay = view.FindViewById <ImageView>(Resource.Id.img_display);
            roi          = view.FindViewById <ImageView>(Resource.Id.roiView);

            mCaptureCallback          = new CameraCaptureListener(this);
            mOnImageAvailableListener = new ImageAvailableListener(this);
            flashMenuListner          = new FlashMenuListener(this);
            mFlashMode = 0;
        }
コード例 #3
0
        public DroidCameraPreview(Context context, CameraOptions option) : base(context)
        {
            CameraOption = option;

            var path       = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal);
            var nativePath = Context.GetExternalFilesDir(Android.OS.Environment.DirectoryDocuments);

            // Camera Setup
            File                      = new Java.IO.File(path, "pic.jpg");
            CaptureCallback           = new CameraCaptureListener(this);
            mOnImageAvailableListener = new ImageAvailableListener(this);
            mStateCallback            = new CameraStateListener(this);
            mSurfaceTextureListener   = new Camera2BasicSurfaceTextureListener(this);

            mTextureView = new Camera2Basic.AutoFitTextureView(context);
            AddView(mTextureView);

            // fill ORIENTATIONS list
            ORIENTATIONS.Append((int)SurfaceOrientation.Rotation0, 90);
            ORIENTATIONS.Append((int)SurfaceOrientation.Rotation90, 0);
            ORIENTATIONS.Append((int)SurfaceOrientation.Rotation180, 270);
            ORIENTATIONS.Append((int)SurfaceOrientation.Rotation270, 180);

            State = CameraState.Stopped;
        }
コード例 #4
0
        public NativeCameraView(Context context) : base(context)
        {
            _context = context;

            var inflater = LayoutInflater.FromContext(context);

            if (inflater == null)
            {
                return;
            }
            var view = inflater.Inflate(Resource.Layout.CameraLayout, this);

            _cameraTexture = view.FindViewById <TextureView>(Resource.Id.cameraTexture);

            _cameraTexture.Click += (sender, args) => { TakePhoto(); };

            _cameraTexture.SurfaceTextureListener = this;

            _mStateListener = new CameraStateListener {
                Camera = this
            };

            Orientations.Append((int)SurfaceOrientation.Rotation0, 0);
            Orientations.Append((int)SurfaceOrientation.Rotation90, 90);
            Orientations.Append((int)SurfaceOrientation.Rotation180, 180);
            Orientations.Append((int)SurfaceOrientation.Rotation270, 270);
        }
コード例 #5
0
        protected async override void OnElementChanged(ElementChangedEventArgs <CameraPreview> e)
        {
            if (Xamarin.Forms.DesignMode.IsDesignModeEnabled)
            {
                return;
            }

            if (e.OldElement != null)             // Clear old element event
            {
            }

            if (e.NewElement != null)
            {
                await RequestCameraPermission.RequestPermissionsAsync();

                e.NewElement.StartRecording = (() => { TakePicture(); });
                e.NewElement.StopRecording  = (() => { CloseCamera(); });

                if (Control == null)
                {
                    Activity    = this.Context as Activity;
                    frameLayout = new FrameLayout(Context);
                    frameLayout.LayoutParameters = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.MatchParent);

                    autoFitTextureView = new AutoFitTextureView(Context);
                    autoFitTextureView.LayoutParameters = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.MatchParent);

                    frameLayout.AddView(autoFitTextureView);
                    SetNativeControl(frameLayout);
                }

                mTextureView            = Control.GetChildAt(0) as AutoFitTextureView;
                mStateCallback          = new CameraStateListener(this);
                mSurfaceTextureListener = new Camera2BasicSurfaceTextureListener(this, autoFitTextureView);


                //mFile = new File(Activity.GetExternalFilesDir(null), $"{Element.Filename}.jpg");
                //var path = System.IO.Path.Combine(
                //        System.Environment.GetFolderPath(System.Environment.SpecialFolder.MyDocuments),
                //        $"{Element.Filename}"
                //);
                string pathyo = DependencyService.Get <IMediaFolder>().Path;
                var    path   = System.IO.Path.Combine(
                    pathyo,
                    Element.Filename);

                mFile = new File(
                    path
                    );
                mCaptureCallback          = new CameraCaptureListener(this);
                mOnImageAvailableListener = new ImageAvailableListener(this, mFile);

                StartTheCamera();
            }

            base.OnElementChanged(e);
        }
コード例 #6
0
 public override void OnCreate(Bundle savedInstanceState)
 {
     base.OnCreate(savedInstanceState);
     mStateListener = new CameraStateListener()
     {
         Fragment = this
     };
     mSurfaceTextureListener = new MirrorSurfaceTextureListener(this);
 }
コード例 #7
0
 public override void OnCreate(Bundle savedInstanceState)
 {
     base.OnCreate (savedInstanceState);
     mStateListener = new CameraStateListener () { Fragment = this };
     mSurfaceTextureListener = new Camera2BasicSurfaceTextureListener (this);
     ORIENTATIONS.Append ((int)SurfaceOrientation.Rotation0, 90);
     ORIENTATIONS.Append ((int)SurfaceOrientation.Rotation90, 0);
     ORIENTATIONS.Append ((int)SurfaceOrientation.Rotation180, 270);
     ORIENTATIONS.Append ((int)SurfaceOrientation.Rotation270, 180);
 }
コード例 #8
0
        public override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            _stateCallback           = new CameraStateListener(this);
            _mSurfaceTextureListener = new Camera2BasicSurfaceTextureListener(this);

            // fill ORIENTATIONS list
            ORIENTATIONS.Append((int)SurfaceOrientation.Rotation0, 90);
            ORIENTATIONS.Append((int)SurfaceOrientation.Rotation90, 0);
            ORIENTATIONS.Append((int)SurfaceOrientation.Rotation180, 270);
            ORIENTATIONS.Append((int)SurfaceOrientation.Rotation270, 180);
        }
コード例 #9
0
 public VideoSource()
 {
     OrientationToDegrees.Add(SurfaceOrientation.Rotation0, 90);
     OrientationToDegrees.Add(SurfaceOrientation.Rotation90, 0);
     OrientationToDegrees.Add(SurfaceOrientation.Rotation180, 270);
     OrientationToDegrees.Add(SurfaceOrientation.Rotation270, 180);
     Main          = SynchronizationContext.Current;
     context       = MainActivity.Instance;
     manager       = (CameraManager)context.GetSystemService(Context.CameraService);
     listener      = new CameraStateListener(this);
     callback      = new CameraCaptureSessionCallback(this);
     StateCallback = new CameraCaptureSessionStateCallback(this);
 }
コード例 #10
0
 public override void OnCreate(Bundle savedInstanceState)
 {
     base.OnCreate(savedInstanceState);
     mStateListener = new CameraStateListener()
     {
         Fragment = this
     };
     mSurfaceTextureListener = new Camera2BasicSurfaceTextureListener(this);
     ORIENTATIONS.Append((int)SurfaceOrientation.Rotation0, 90);
     ORIENTATIONS.Append((int)SurfaceOrientation.Rotation90, 0);
     ORIENTATIONS.Append((int)SurfaceOrientation.Rotation180, 270);
     ORIENTATIONS.Append((int)SurfaceOrientation.Rotation270, 180);
 }
コード例 #11
0
        protected override void OnElementChanged(ElementChangedEventArgs <CameraPreview> args)
        {
            if (DesignMode.IsDesignModeEnabled)
            {
                return;
            }

            if (args.OldElement != null) // Clear old element event
            {
            }

            if (args.NewElement != null)
            {
                args.NewElement.StartRecording = (() => { TakePicture(); });
                args.NewElement.StopRecording  = (() => { CloseCamera(); });

                if (Control == null)
                {
                    Activity = this.Context as Activity;
                    SetNativeControl(new AutoFitTextureView(Context));
                }

                _textureView            = Control as AutoFitTextureView;
                _stateCallback          = new CameraStateListener(this);
                _surfaceTextureListener = new Camera2SurfaceTextureListener(this);

                CaptureCallback = new CameraCaptureListener(this);

                _onImageAvailableListener = new ImageAvailableListener(this, Element.MediaOptions);

                _onImageAvailableListener.ImageAvailable += (s, e) =>
                {
                    Element.OnImageAvailable(e);
                };

                _orientationEventListener = new OrientationChangeListener(Context, (int rotation) => OnRotationChanged(rotation));
                _orientationEventListener.Enable();

                RotationChanged += (s, e) =>
                {
                    args.NewElement.OnRotationChanged(DeviceRotation);
                };

                StartTheCamera();
            }

            base.OnElementChanged(args);
        }
コード例 #12
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            // Intent intent = new Intent(MediaStore.ActionImageCapture);


            if (ContextCompat.CheckSelfPermission(this, Manifest.Permission.Camera) != (int)Permission.Granted)
            {
                ActivityCompat.RequestPermissions(this, new string[] { Manifest.Permission.Camera }, 200);
            }
            else
            {
                mStateCallback          = new CameraStateListener(this);
                mSurfaceTextureListener = new ClipperASurfaceTextureListener(this);

                // fill ORIENTATIONS list
                ORIENTATIONS.Append((int)SurfaceOrientation.Rotation0, 90);
                ORIENTATIONS.Append((int)SurfaceOrientation.Rotation90, 0);
                ORIENTATIONS.Append((int)SurfaceOrientation.Rotation180, 270);
                ORIENTATIONS.Append((int)SurfaceOrientation.Rotation270, 180);

                SetContentView(Resource.Layout.TakingPicture);

                mTextureView = (AutoFitTextureView)FindViewById(Resource.Id.texture);
                mImageView   = FindViewById <ImageView>(Resource.Id.image);


                takePictureBtn = FindViewById <ImageButton>(Resource.Id.takePictureBtn);
                flashBtn       = FindViewById <ImageButton>(Resource.Id.flashBtn);
                rotateBtn      = FindViewById <ImageButton>(Resource.Id.rotateBtn);

                acceptBtn  = FindViewById <ImageButton>(Resource.Id.doneBtn);
                discardBtn = FindViewById <ImageButton>(Resource.Id.clearBtn);

                takePictureBtn.Click += (sender, e) => TakePicture();
                rotateBtn.Click      += (sender, e) => ChangeCamera();
                flashBtn.Click       += (sender, e) => ChandeFlashMode();
                FindViewById <ImageButton>(Resource.Id.closeBtn).Click += (sender, e) => Exit();

                acceptBtn.Click  += (sender, e) => ExitWithResult();
                discardBtn.Click += (sender, e) => DiscardChanges();

                mCaptureCallback          = new CameraCaptureListener(this);
                mOnImageAvailableListener = new ImageAvailableListener(this, mre);
                mOrientationListener      = new SensorOrientationListener(this);
            }
        }
コード例 #13
0
ファイル: CameraWidget.cs プロジェクト: tro476/photo-plugin
        public CameraWidget(Context Context, ObservableCollection <File> Photos) : base(Context)
        {
            context                             = Context;
            mTextureView                        = new AutoFitTextureView(Context);
            mSurfaceTextureListener             = new Camera2BasicSurfaceTextureListener(this);
            mTextureView.SurfaceTextureListener = mSurfaceTextureListener;

            mStateCallback = new CameraStateListener(this);
            StartBackgroundThread();

            // mTextureView.SetBackgroundColor(Color.Black);

            SetBackgroundColor(Color.Black);

            mCaptureCallback          = new CameraCaptureListener(this);
            mOnImageAvailableListener = new ImageAvailableListener(this, Photos, Context);
        }
コード例 #14
0
        protected override void OnElementChanged(ElementChangedEventArgs <Views.Renderers.CameraPreview> e)
        {
            if (Xamarin.Forms.DesignMode.IsDesignModeEnabled)
            {
                return;
            }

            if (e.OldElement != null)             // Clear old element event
            {
            }

            if (e.NewElement != null)
            {
                e.NewElement.StartRecording = (() => { TakePicture(); });
                e.NewElement.StopRecording  = (() => { CloseCamera(); });

                if (Control == null)
                {
                    Activity = this.Context as Activity;
                    SetNativeControl(new AutoFitTextureView(Context));
                }

                mTextureView            = Control as AutoFitTextureView;
                mStateCallback          = new CameraStateListener(this);
                mSurfaceTextureListener = new Camera2BasicSurfaceTextureListener(this);

                //mFile = new File(Activity.GetExternalFilesDir(null), $"{Element.Filename}.jpg");
                //var path = System.IO.Path.Combine(
                //        System.Environment.GetFolderPath(System.Environment.SpecialFolder.MyDocuments),
                //        $"{Element.Filename}"
                //);
                var path = System.IO.Path.Combine(
                    DependencyService.Get <IMediaFolder>().Path,
                    Element.Filename);
                mFile = new File(
                    path
                    );
                mCaptureCallback          = new CameraCaptureListener(this);
                mOnImageAvailableListener = new ImageAvailableListener(this, mFile);

                StartTheCamera();
            }

            base.OnElementChanged(e);
        }
コード例 #15
0
        public override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            Bundle b = (savedInstanceState ?? this.Activity.Intent.Extras);

            this.requestId = b.GetInt(ExtraId, 0);

            var targetFilenameString = b.GetString(ExtraFilename);

            if (!string.IsNullOrEmpty(targetFilenameString))
            {
                this.targetFilename = targetFilenameString;
            }
            else
            {
                this.targetFilename = "_____ccuiphoto.jpg";
            }
            this.tracer.Debug("OnCreate: this.targetFilename={0}", this.targetFilename);

            var pathString = b.GetString(ExtraPath);

            if (!string.IsNullOrEmpty(pathString))
            {
                this.path = pathString;
            }
            else
            {
                this.path = null;
            }
            this.tracer.Debug("OnCreate: this.path={0}", this.path);

            this.facing = new Integer(b.GetInt(ExtraCameraFacingDirection));
            this.tracer.Debug("OnCreate: this.facing={0} (Integer)", this.facing.ToString());

            this.cameraStateListener = new CameraStateListener {
                Fragment = this
            };
            this.mSurfaceTextureListener = new Camera2BasicSurfaceTextureListener(this);

            Orientations.Append((int)SurfaceOrientation.Rotation0, 90);
            Orientations.Append((int)SurfaceOrientation.Rotation90, 0);
            Orientations.Append((int)SurfaceOrientation.Rotation180, 270);
            Orientations.Append((int)SurfaceOrientation.Rotation270, 180);
        }
コード例 #16
0
        protected override void OnElementChanged(ElementChangedEventArgs <CameraPreview> e)
        {
            if (Xamarin.Forms.DesignMode.IsDesignModeEnabled)
            {
                return;
            }

            if (e.OldElement != null) //// Clear old element event
            {
            }

            this.element = e.NewElement;
            if (element == null)
            {
                return;
            }

            element.TakePicture = () => { return(TakePictureAsync()); };

            if (Control == null)
            {
                Activity = this.Context as Activity;
                SetNativeControl(new FrameLayout(Context));
            }

            mFrameLayout = Control as FrameLayout;
            mTextureView = new AutoFitTextureView(Context);

            mFrameLayout.AddView(mTextureView);
            mStateCallback            = new CameraStateListener(this);
            mSurfaceTextureListener   = new CameraSurfaceTextureListener(this);
            mOnImageAvailableListener = new ImageAvailableListener(this);

            if (element.EnableTensorflowAnalysis)
            {
                mOnImageAvailableListener.EnableTensorflowAnalysis();
            }

            StartTheCamera();

            base.OnElementChanged(e);
        }
コード例 #17
0
        public DroidCameraPreview(Context context, CameraOptions option) : base(context)
        {
            CameraOption = option;

            // Camera Setup
            File                      = new Java.IO.File(Context.GetExternalFilesDir(null), "pic.jpg");
            CaptureCallback           = new CameraCaptureListener(this);
            mOnImageAvailableListener = new ImageAvailableListener(this, File);
            mStateCallback            = new CameraStateListener(this);
            mSurfaceTextureListener   = new Camera2BasicSurfaceTextureListener(this);

            mTextureView = new Camera2Basic.AutoFitTextureView(context);
            AddView(mTextureView);

            // fill ORIENTATIONS list
            ORIENTATIONS.Append((int)SurfaceOrientation.Rotation0, 90);
            ORIENTATIONS.Append((int)SurfaceOrientation.Rotation90, 0);
            ORIENTATIONS.Append((int)SurfaceOrientation.Rotation180, 270);
            ORIENTATIONS.Append((int)SurfaceOrientation.Rotation270, 180);
        }
コード例 #18
0
    //public static CameraHandler getInstance() => InstanceHolder.camera;

    public void InitializeCamera(Context context, Handler backgroundHandler, IOnImageAvailableListener imageAvailableListener)
    {
        //  Discover the camera instance
        CameraManager manager = ((CameraManager)(context.GetSystemService(Context.CameraService)));

        string[] camIds = new string[0];
        try
        {
            camIds = manager.GetCameraIdList();
        }
        catch (CameraAccessException e)
        {
            Log.Debug(TAG, "Cam access exception getting IDs", e);
        }

        if ((camIds.Length < 1))
        {
            Log.Debug(TAG, "No cameras found");
            return;
        }

        string id = camIds[0];

        Log.Debug(TAG, ("Using camera id " + id));
        //  Initialize the image processor
        this.mImageReader = ImageReader.NewInstance(IMAGE_WIDTH, IMAGE_HEIGHT, Android.Graphics.ImageFormatType.Jpeg, MAX_IMAGES);
        this.mImageReader.SetOnImageAvailableListener(imageAvailableListener, backgroundHandler);
        //  Open the camera resource
        try
        {
            var mStateCallback = new CameraStateListener()
            {
                CameraHandler = this
            };
            manager.OpenCamera(id, mStateCallback, backgroundHandler);
        }
        catch (CameraAccessException cae)
        {
            Log.Debug(TAG, "Camera access exception", cae);
        }
    }
コード例 #19
0
        public AndroidCameraManager(int?preferredPreviewSize = null)
        {
            if (!SetUpCameraOutputs(preferredPreviewSize))
            {
                return;
            }

            this._onYuvImageAvailableListener.OnImageProcessed += (sender, mat) =>
            {
                this.OnImageCaptured(sender, mat);
            };

            //var activity = this;
            CameraManager manager =
                (CameraManager)Android.App.Application.Context.GetSystemService(Context.CameraService);

            _stateCallback = new CameraStateListener();
            try
            {
                Handler backgroundHandler;

                var list     = manager.GetCameraIdList();
                var cameraId = list[0];
                backgroundHandler = _backgroundHandler;

                // Attempt to open the camera. mStateCallback will be called on the background handler's
                // thread when this succeeds or fails.
                manager.OpenCamera(cameraId, _stateCallback, backgroundHandler);
            }
            catch (CameraAccessException e)
            {
                e.PrintStackTrace();
            }
            catch (Java.Lang.InterruptedException e)
            {
                throw new Java.Lang.RuntimeException("Interrupted while trying to lock camera opening.", e);
            }
        }
コード例 #20
0
        public XCameraCaptureView(Context context, CameraOptions option) : base(context)
        {
            cameraOption = option;

            // TODO Move to Initialize
            mStateCallback          = new CameraStateListener(this);
            mSurfaceTextureListener = new Camera2BasicSurfaceTextureListener(this);

            // fill ORIENTATIONS list
            ORIENTATIONS.Append((int)SurfaceOrientation.Rotation0, 90);
            ORIENTATIONS.Append((int)SurfaceOrientation.Rotation90, 0);
            ORIENTATIONS.Append((int)SurfaceOrientation.Rotation180, 270);
            ORIENTATIONS.Append((int)SurfaceOrientation.Rotation270, 180);

            mTextureView = new AutoFitTextureView(context);
            AddView(mTextureView);

            var path = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal);

            File                      = new File(path, "pic.jpg");
            CaptureCallback           = new CameraCaptureListener(this);
            mOnImageAvailableListener = new ImageAvailableListener(this);
        }
        public override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            mStateCallback = new CameraStateListener()
            {
                owner = this
            };
            mSurfaceTextureListener = new Camera2BasicSurfaceTextureListener(this);


            // fill ORIENTATIONS list
            ORIENTATIONS.Append((int)SurfaceOrientation.Rotation0, 90);
            ORIENTATIONS.Append((int)SurfaceOrientation.Rotation90, 0);
            ORIENTATIONS.Append((int)SurfaceOrientation.Rotation180, 270);
            ORIENTATIONS.Append((int)SurfaceOrientation.Rotation270, 180);

            var file = new File(Activity.GetExternalFilesDir(null), "pic.jpg");

            this.mOnImageAvailableListener = new ImageAvailableListener(scanModule)
            {
                Owner = this, File = file
            };
            //this.mCaptureCallback = new CameraCaptureListener() { Owner = this, File = file};
        }
コード例 #22
0
 public override void OnCreate(Bundle savedInstanceState)
 {
     base.OnCreate(savedInstanceState);
     mStateCallback          = new CameraStateListener(this);
     mSurfaceTextureListener = new Camera2BasicSurfaceTextureListener(this);
 }
コード例 #23
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            AppPreference appPreference = new AppPreference();

            CvInvoke.UseOpenCL = false;  //appPreference.UseOpenCL;
            string oclDeviceName = appPreference.OpenClDeviceName;

            if (!string.IsNullOrEmpty(oclDeviceName))
            {
                CvInvoke.OclSetDefaultDevice(oclDeviceName);
                Log.Error(TAG, "\t\t --OclSetDefaultDevice: " + oclDeviceName);
            }

            mFile = new Java.IO.File(GetExternalFilesDir(null), "derp.jpg");

            ISharedPreferences preference = PreferenceManager.GetDefaultSharedPreferences(ApplicationContext);
            string             appVersion = PackageManager.GetPackageInfo(PackageName, Android.Content.PM.PackageInfoFlags.Activities).VersionName;

            if (!preference.Contains("cascade-data-version") || !preference.GetString("cascade-data-version", null).Equals(appVersion) ||
                !(preference.Contains("cascade-eye-data-path") || preference.Contains("cascade-face-data-path")))
            {
                AndroidFileAsset.OverwriteMethod overwriteMethod = AndroidFileAsset.OverwriteMethod.AlwaysOverwrite;

                FileInfo eyeFile  = AndroidFileAsset.WritePermanantFileAsset(this, "haarcascade_eye.xml", "cascade", overwriteMethod);
                FileInfo faceFile = AndroidFileAsset.WritePermanantFileAsset(this, "haarcascade_frontalface_alt_tree.xml", "cascade", overwriteMethod);

                Log.Error(TAG, "\t\t --eyeFile.FullName: " + eyeFile.FullName);
                Log.Error(TAG, "\t\t --faceFile.FullName: " + faceFile.FullName);

                //save tesseract data path
                ISharedPreferencesEditor editor = preference.Edit();
                editor.PutString("cascade-data-version", appVersion);
                editor.PutString("cascade-eye-data-path", eyeFile.FullName);
                editor.PutString("cascade-face-data-path", faceFile.FullName);
                editor.Commit();
            }

            eyeXml  = preference.GetString("cascade-eye-data-path", null);
            faceXml = preference.GetString("cascade-face-data-path", null);

            Log.Error(TAG, "\t\t --eyeXml: " + eyeXml);
            Log.Error(TAG, "\t\t --faceXml: " + faceXml);

            //face = new CascadeClassifier(faceXml);
            //eye = new CascadeClassifier(eyeXml);

            // Hide the window title and go fullscreen.
            RequestWindowFeature(WindowFeatures.NoTitle);
            Window.AddFlags(WindowManagerFlags.Fullscreen);

            SetContentView(Resource.Layout.take_photo_surface_view);
            mTextureView     = (AutoFitTextureView)FindViewById(Resource.Id.CameraView);
            mTransparentView = (SurfaceView)FindViewById(Resource.Id.TransparentView);

            mTransparentView.SetZOrderOnTop(true);
            mTransparentView.BringToFront();

            mTransparentView.Holder.SetFormat(Android.Graphics.Format.Transparent);
            mTransparentView.Holder.AddCallback(this);

            var manager = GetSystemService(Context.WindowService).JavaCast <IWindowManager>();
            var size    = new Android.Graphics.Point();

            manager.DefaultDisplay.GetSize(size);

            screenX = size.X / 2;
            screenY = size.Y / 2;

            L = screenX - 200;
            T = screenY - 200;
            R = screenX + 200;
            B = screenY + 200;

            mStateCallback = new CameraStateListener()
            {
                owner = this
            };
            mSurfaceTextureListener   = new Camera2BasicSurfaceTextureListener(this);
            mOnImageAvailableListener = new ImageAvailableListener()
            {
                Owner = this
            };

            // fill ORIENTATIONS list
            ORIENTATIONS.Append((int)SurfaceOrientation.Rotation0, 90);
            ORIENTATIONS.Append((int)SurfaceOrientation.Rotation90, 0);
            ORIENTATIONS.Append((int)SurfaceOrientation.Rotation180, 270);
            ORIENTATIONS.Append((int)SurfaceOrientation.Rotation270, 180);
        }
コード例 #24
0
 public CameraController2()
 {
     mStateCallback          = new CameraStateListener(this);
     mSurfaceTextureListener = new Camera2BasicSurfaceTextureListener(this);
 }
コード例 #25
0
 private void InitializeAll()
 {
     stateListener = new CameraStateListener(this);
     sessionPath   = MainActivity.RootPath + "/ses_" + Intent.GetStringExtra(MainActivity.ExtraSessionName) + "/";
     InitializeUI();
 }