예제 #1
0
        public Camera2View(Activity context) : base(context)
        {
            ORIENTATIONS.Append((int)SurfaceOrientation.Rotation0, 90);
            ORIENTATIONS.Append((int)SurfaceOrientation.Rotation90, 0);
            ORIENTATIONS.Append((int)SurfaceOrientation.Rotation180, 270);
            ORIENTATIONS.Append((int)SurfaceOrientation.Rotation270, 180);

            stateCallback          = new CameraStateCallback(this);
            surfaceTextureListener = new CameraSurfaceTextureListener(this);

            textureView = new TextureView(context);
            textureView.SurfaceTextureListener = surfaceTextureListener;

            AddView(textureView);

            GetCameraIds();

            if (backCameraId != null)
            {
                GetBackSizes();
            }

            if (frontCameraId != null)
            {
                GetFrontSizes();
            }

            PrintCameraAvailabilityInfo();
        }
예제 #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 override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate (savedInstanceState);

            mStateListner = new CameraStateListner () { Fragment = this };
            mSurfaceTextureListener = new CameraSurfaceTextureListener (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);
            count = 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);
        }