コード例 #1
0
        public void Work <TState>(CameraCaptureSession session, CaptureRequest request, CaptureResult result,
                                  ref TState captureState) where TState : class
        {
            Integer afState = (Integer)result.Get(CaptureResult.ControlAfState);

            if (afState == null)
            {
                _captureStillPhoto();
            }
            else if (afState.IntValue() == (int)ControlAFState.FocusedLocked ||
                     afState.IntValue() == (int)ControlAFState.NotFocusedLocked)
            {
                // Auto exposure can be null on some devices
                Integer aeState = (Integer)result.Get(CaptureResult.ControlAeState);
                if (aeState == null || aeState.IntValue() == (int)ControlAEState.Converged)
                {
                    captureState = (TState)CaptureStateFactory.GetCaptureState(CaptureStates.PictureTaken);
                    _captureStillPhoto();
                }
                else
                {
                    _runPrecaptureSequence();
                }
            }
        }
コード例 #2
0
        private void Process(CaptureResult result)
        {
            switch (owner.mState)
            {
            case CamRecorder.STATE_WAITING_LOCK:
            {
                Integer afState = (Integer)result.Get(CaptureResult.ControlAfState);
                if (afState == null || afState.IntValue() == (int)ControlAFState.Inactive)
                {
                    owner.mState = CamRecorder.STATE_PICTURE_TAKEN;
                    owner.CaptureStillPicture();
                }

                else if ((((int)ControlAFState.FocusedLocked) == afState.IntValue()) ||
                         (((int)ControlAFState.NotFocusedLocked) == afState.IntValue())
                         )
                {
                    // ControlAeState can be null on some devices
                    Integer aeState = (Integer)result.Get(CaptureResult.ControlAeState);
                    if (aeState == null ||
                        aeState.IntValue() == ((int)ControlAEState.Converged))
                    {
                        owner.mState = CamRecorder.STATE_PICTURE_TAKEN;
                        owner.CaptureStillPicture();
                    }
                    else
                    {
                        owner.RunPrecaptureSequence();
                    }
                }
                break;
            }

            case CamRecorder.STATE_WAITING_PRECAPTURE:
            {
                // ControlAeState can be null on some devices
                Integer aeState = (Integer)result.Get(CaptureResult.ControlAeState);
                if (aeState == null ||
                    aeState.IntValue() == ((int)ControlAEState.Precapture) ||
                    aeState.IntValue() == ((int)ControlAEState.FlashRequired))
                {
                    owner.mState = CamRecorder.STATE_WAITING_NON_PRECAPTURE;
                }
                break;
            }

            case CamRecorder.STATE_WAITING_NON_PRECAPTURE:
            {
                // ControlAeState can be null on some devices
                Integer aeState = (Integer)result.Get(CaptureResult.ControlAeState);
                if (aeState == null || aeState.IntValue() != ((int)ControlAEState.Precapture))
                {
                    owner.mState = CamRecorder.STATE_PICTURE_TAKEN;
                    owner.CaptureStillPicture();
                }
                break;
            }
            }
        }
コード例 #3
0
        public void Process(CaptureResult result)
        {
            switch (Parent.mState)
            {
            case CameraState.Preview:
                break;

            case CameraState.WaitingLock:
                // https://github.com/googlesamples/android-Camera2Basic/blob/master/Application/src/main/java/com/example/android/camera2basic/Camera2BasicFragment.java#L295
                var afState = ((Integer)result.Get(CaptureResult.ControlAfState))?.IntValue();
                if (afState == null)
                {
                    Parent.CaptureStillPicture();
                }
                else if ((int)ControlAFState.FocusedLocked == afState ||
                         (int)ControlAFState.FocusedLocked == afState)
                {
                    // CaptureResult.ControlAeState can be null on some devices
                    var aeState1 = ((Integer)result.Get(CaptureResult.ControlAeState))?.IntValue();
                    if (aeState1 == null ||
                        aeState1 == (int)ControlAEState.Converged)
                    {
                        Parent.mState = CameraState.PictureTaken;
                        Parent.CaptureStillPicture();
                    }
                    else
                    {
                        Parent.CaptureStillPicture();
                    }
                }
                break;

            case CameraState.WaitingPrecapture:
                // CaptureResult.ControlAeState can be null on some devices
                var aeState2 = ((Integer)result.Get(CaptureResult.ControlAeState))?.IntValue();
                if (aeState2 == null ||
                    aeState2 == (int)ControlAEState.Precapture ||
                    aeState2 == (int)ControlAEState.FlashRequired)
                {
                    Parent.mState = CameraState.WaitingNonPrecapture;
                }
                break;

            case CameraState.WaitingNonPrecapture:
                // CaptureResult.ControlAeState can be null on some devices
                var aeState3 = ((Integer)result.Get(CaptureResult.ControlAeState))?.IntValue();
                if (aeState3 == null || aeState3 == (int)ControlAEState.Precapture)
                {
                    Parent.mState = CameraState.PictureTaken;
                    Parent.CaptureStillPicture();
                }
                break;

            default:
                break;
            }
        }
コード例 #4
0
        private void Process(CaptureResult result)
        {
            switch (owner.State)
            {
            case CameraState.WaitingLock:
            {
                Integer afState = (Integer)result.Get(CaptureResult.ControlAfState);
                if (afState == null)
                {
                    owner.State = CameraState.PictureTaken;
                    owner.CaptureStillPicture();
                }

                else if ((((int)ControlAFState.FocusedLocked) == afState.IntValue()) ||
                         (((int)ControlAFState.NotFocusedLocked) == afState.IntValue()))
                {
                    // ControlAeState can be null on some devices
                    Integer aeState = (Integer)result.Get(CaptureResult.ControlAeState);
                    if (aeState == null || aeState.IntValue() == ((int)ControlAEState.Converged))
                    {
                        owner.State = CameraState.PictureTaken;
                        owner.CaptureStillPicture();
                    }
                    else
                    {
                        owner.RunPrecaptureSequence();
                    }
                }
                break;
            }

            case CameraState.WaitingPrecapture:
            {
                // ControlAeState can be null on some devices
                Integer aeState = (Integer)result.Get(CaptureResult.ControlAeState);
                if (aeState == null ||
                    aeState.IntValue() == ((int)ControlAEState.Precapture) ||
                    aeState.IntValue() == ((int)ControlAEState.FlashRequired))
                {
                    owner.State = CameraState.WaitingNonPrecapture;
                }
                break;
            }

            case CameraState.WaitingNonPrecapture:
            {
                // ControlAeState can be null on some devices
                Integer aeState = (Integer)result.Get(CaptureResult.ControlAeState);
                if (aeState == null || aeState.IntValue() != ((int)ControlAEState.Precapture))
                {
                    owner.State = CameraState.PictureTaken;
                    owner.CaptureStillPicture();
                }
                break;
            }
            }
        }
コード例 #5
0
        private void Process(CaptureResult result)
        {
            switch (Owner.mState)
            {
                case Camera2BasicFragment.STATE_WAITING_LOCK:
                    {
                        Integer afState = (Integer)result.Get(CaptureResult.ControlAfState);
                        if (afState == null)
                        {
                            Owner.CaptureStillPicture();
                        }

                        else if ((((int)ControlAFState.FocusedLocked) == afState.IntValue()) ||
                                   (((int)ControlAFState.NotFocusedLocked) == afState.IntValue()))
                        {
                            // ControlAeState can be null on some devices
                            Integer aeState = (Integer)result.Get(CaptureResult.ControlAeState);
                            if (aeState == null ||
                                    aeState.IntValue() == ((int)ControlAEState.Converged))
                            {
                                Owner.mState = Camera2BasicFragment.STATE_PICTURE_TAKEN;
                                Owner.CaptureStillPicture();
                            }
                            else
                            {
                                Owner.RunPrecaptureSequence();
                            }
                        }
                        break;
                    }
                case Camera2BasicFragment.STATE_WAITING_PRECAPTURE:
                    {
                        // ControlAeState can be null on some devices
                        Integer aeState = (Integer)result.Get(CaptureResult.ControlAeState);
                        if (aeState == null ||
                                aeState.IntValue() == ((int)ControlAEState.Precapture) ||
                                aeState.IntValue() == ((int)ControlAEState.FlashRequired))
                        {
                            Owner.mState = Camera2BasicFragment.STATE_WAITING_NON_PRECAPTURE;
                        }
                        break;
                    }
                case Camera2BasicFragment.STATE_WAITING_NON_PRECAPTURE:
                    {
                        // ControlAeState can be null on some devices
                        Integer aeState = (Integer)result.Get(CaptureResult.ControlAeState);
                        if (aeState == null || aeState.IntValue() != ((int)ControlAEState.Precapture))
                        {
                            Owner.mState = Camera2BasicFragment.STATE_PICTURE_TAKEN;
                            Owner.CaptureStillPicture();
                        }
                        break;
                    }
            }
        }
コード例 #6
0
        private void ProcessImageCapture(CaptureResult result)
        {
            switch (state)
            {
            case MediaCaptorState.WaitingLock:
            {
                var afState = (int?)result.Get(CaptureResult.ControlAfState);
                if (afState == null)
                {
                    CaptureStillPicture();
                }
                else if ((((int)ControlAFState.FocusedLocked) == afState.Value) ||
                         (((int)ControlAFState.NotFocusedLocked) == afState.Value))
                {
                    // ControlAeState can be null on some devices
                    var aeState = (int?)result.Get(CaptureResult.ControlAeState);
                    if (aeState == null || aeState.Value == ((int)ControlAEState.Converged))
                    {
                        state = MediaCaptorState.PictureTaken;
                        CaptureStillPicture();
                    }
                    else
                    {
                        RunPrecaptureSequence();
                    }
                }
                break;
            }

            case MediaCaptorState.WaitingPrecapture:
            {
                // ControlAeState can be null on some devices
                var aeState = (int?)result.Get(CaptureResult.ControlAeState);
                if (aeState == null ||
                    aeState.Value == ((int)ControlAEState.Precapture) ||
                    aeState.Value == ((int)ControlAEState.FlashRequired))
                {
                    state = MediaCaptorState.WaitingNonPrecapture;
                }
                break;
            }

            case MediaCaptorState.WaitingNonPrecapture:
            {
                // ControlAeState can be null on some devices
                var aeState = (int?)result.Get(CaptureResult.ControlAeState);
                if (aeState == null || aeState.Value != ((int)ControlAEState.Precapture))
                {
                    state = MediaCaptorState.PictureTaken;
                    CaptureStillPicture();
                }
                break;
            }
            }
        }
コード例 #7
0
        private void Process(CaptureResult result)
        {
            switch (_controller.State)
            {
                case CameraState.WaitingLock:

                    var afState = result.Get(CaptureResult.ControlAfState) as Integer;
                    if (afState == null)
                    {
                        _controller.CaptureStillPicture();
                    }
                    else if ((int)ControlAFState.FocusedLocked == (int)afState || (int)ControlAFState.NotFocusedLocked == (int)afState)
                    {
                        // CONTROL_AE_STATE can be null on some devices
                        var ae = result.Get(CaptureResult.ControlAeState) as Integer;
                        if (ae == null || ae.IntValue() == (int)ControlAEState.Converged)
                        {
                            _controller.State = CameraState.PictureTaken;
                            _controller.CaptureStillPicture();
                        }
                        else
                        {
                            _controller.RunPrecaptureSequence();
                        }
                    }
                    break;
                case CameraState.WaitingPrecapture:
                    // CONTROL_AE_STATE can be null on some devices
                    var state = result.Get(CaptureResult.ControlAeState) as Integer;
                    if (state == null || state.IntValue() == (int)ControlAEState.Precapture || state.IntValue() == (int)ControlAEState.FlashRequired)
                    {
                        _controller.State = CameraState.WaitingNonPrecapture;
                    }
                    break;
                case CameraState.WaitingNonPrecapture:
                    // CONTROL_AE_STATE can be null on some devices
                    var aeState = result.Get(CaptureResult.ControlAeState) as Integer;
                    if (aeState == null || aeState.IntValue() == (int)ControlAEState.Precapture)
                    {
                        _controller.State = CameraState.PictureTaken;
                        _controller.CaptureStillPicture();
                    }
                    break;
            }
        }
コード例 #8
0
        public void Work <TState>(CameraCaptureSession session, CaptureRequest request, CaptureResult result,
                                  ref TState captureState) where TState : class
        {
            Integer aeState = (Integer)result.Get(CaptureResult.ControlAeState);

            if (aeState == null || aeState.IntValue() == (int)ControlAEState.Precapture ||
                aeState.IntValue() == (int)ControlAEState.FlashRequired)
            {
                captureState = (TState)CaptureStateFactory.GetCaptureState(CaptureStates.WaitingNonPrecapture);
            }
        }
コード例 #9
0
        public void Work <TState>(CameraCaptureSession session, CaptureRequest request, CaptureResult result,
                                  ref TState captureState) where TState : class
        {
            Integer aeState = (Integer)result.Get(CaptureResult.ControlAeState);

            if (aeState == null || aeState.IntValue() != (int)ControlAEState.Precapture)
            {
                captureState = (TState)CaptureStateFactory.GetCaptureState(CaptureStates.PictureTaken);
                _captureStillPhoto();
            }
        }
コード例 #10
0
        private void Process(CaptureResult result)
        {
            switch (_camera2.State)
            {
            case Camera2State.WaitingLock:
            {
                var autoFocusState = (Java.Lang.Integer)result.Get(CaptureResult.ControlAfState);
                if (autoFocusState == null)
                {
                    _camera2.State = Camera2State.PictureTaken;
                    _camera2.CaptureStillPicture();
                    return;
                }

                // ControlAeState can be null on some devices
                var autoExposureState = (Java.Lang.Integer)result.Get(CaptureResult.ControlAeState);
                if (autoExposureState == null || autoExposureState.IntValue() != ((int)ControlAEState.FlashRequired))
                {
                    _camera2.State = Camera2State.PictureTaken;
                    _camera2.CaptureStillPicture();
                    return;
                }

                if (autoFocusState.IntValue() == ((int)ControlAFState.Inactive) ||
                    autoFocusState.IntValue() == ((int)ControlAFState.FocusedLocked) ||
                    autoFocusState.IntValue() == ((int)ControlAFState.NotFocusedLocked))
                {
                    if (autoExposureState.IntValue() == ((int)ControlAEState.Converged))
                    {
                        _camera2.State = Camera2State.PictureTaken;
                        _camera2.CaptureStillPicture();
                        return;
                    }
                    else
                    {
                        _camera2.RunPrecaptureSequence();
                    }
                }
                break;
            }

            case Camera2State.WaitingPrecapture:
            {
                // ControlAeState can be null on some devices
                var autoExposureState = (Java.Lang.Integer)result.Get(CaptureResult.ControlAeState);
                if (autoExposureState == null || autoExposureState.IntValue() == ((int)ControlAEState.Precapture) ||
                    autoExposureState.IntValue() == ((int)ControlAEState.FlashRequired))
                {
                    _camera2.State = Camera2State.WaitingNonPrecapture;
                }

                break;
            }

            case Camera2State.WaitingNonPrecapture:
            {
                // ControlAeState can be null on some devices
                var autoExposureState = (Java.Lang.Integer)result.Get(CaptureResult.ControlAeState);
                if (autoExposureState == null || autoExposureState.IntValue() != ((int)ControlAEState.Precapture))
                {
                    _camera2.State = Camera2State.PictureTaken;
                    _camera2.CaptureStillPicture();
                }

                break;
            }

            case Camera2State.PictureTaken:
            {
                System.Diagnostics.Debug.WriteLine("STATE_PICTURE_TAKEN");
                break;
            }
            }
        }
コード例 #11
0
        private void Process(CaptureResult result)
        {
            switch (Owner.mState)
            {
            case TakePhotoActivity3.STATE_PREVIEW:
            {
                //Owner.CapturePreviewShot();
                Log.Error(TAG, "STATE_PREVIEW");
                break;
            }

            case TakePhotoActivity3.STATE_WAITING_LOCK:
            {
                Log.Error(TAG, "STATE_WAITING_LOCK");

                Integer afState = (Integer)result.Get(CaptureResult.ControlAfState);
                if (afState == null)
                {
                    Owner.CaptureStillPicture();
                }

                else if ((((int)ControlAFState.FocusedLocked) == afState.IntValue()) ||
                         (((int)ControlAFState.NotFocusedLocked) == afState.IntValue()))
                {
                    // ControlAeState can be null on some devices
                    Integer aeState = (Integer)result.Get(CaptureResult.ControlAeState);
                    if (aeState == null ||
                        aeState.IntValue() == ((int)ControlAEState.Converged))
                    {
                        Owner.mState = TakePhotoActivity3.STATE_PICTURE_TAKEN;
                        Owner.CaptureStillPicture();
                    }
                    else
                    {
                        Owner.RunPrecaptureSequence();
                    }
                }
                break;
            }

            case TakePhotoActivity3.STATE_WAITING_PRECAPTURE:
            {
                Log.Error(TAG, "STATE_WAITING_PRECAPTURE");

                // ControlAeState can be null on some devices
                Integer aeState = (Integer)result.Get(CaptureResult.ControlAeState);
                if (aeState == null ||
                    aeState.IntValue() == ((int)ControlAEState.Precapture) ||
                    aeState.IntValue() == ((int)ControlAEState.FlashRequired))
                {
                    Owner.mState = TakePhotoActivity3.STATE_WAITING_NON_PRECAPTURE;
                }
                break;
            }

            case TakePhotoActivity3.STATE_WAITING_NON_PRECAPTURE:
            {
                Log.Error(TAG, "STATE_WAITING_NON_PRECAPTURE");

                // ControlAeState can be null on some devices
                Integer aeState = (Integer)result.Get(CaptureResult.ControlAeState);
                if (aeState == null || aeState.IntValue() != ((int)ControlAEState.Precapture))
                {
                    Owner.mState = TakePhotoActivity3.STATE_PICTURE_TAKEN;
                    Owner.CaptureStillPicture();
                }
                break;
            }
            }
        }
コード例 #12
0
        private void CaptureListenerOnCaptureResultAvailable(object sender, CaptureResult result)
        {
            switch (State)
            {
            case CaptureState.WaitingLock:
            {
                var afState = (Integer)result.Get(CaptureResult.ControlAfState);
                if (afState == null)
                {
                    CaptureStillPicture();
                }

                else if ((int)ControlAFState.FocusedLocked == afState.IntValue() ||
                         (int)ControlAFState.NotFocusedLocked == afState.IntValue())
                {
                    // ControlAeState can be null on some devices
                    var aeState = (Integer)result.Get(CaptureResult.ControlAeState);
                    if (aeState == null ||
                        aeState.IntValue() == (int)ControlAEState.Converged)
                    {
                        State = CaptureState.PictureTaken;
                        CaptureStillPicture();
                    }
                    else
                    {
                        RunPrecaptureSequence();
                    }
                }

                break;
            }

            case CaptureState.WaitingPrecapture:
            {
                // ControlAeState can be null on some devices
                var aeState = (Integer)result.Get(CaptureResult.ControlAeState);
                if (aeState == null ||
                    aeState.IntValue() == (int)ControlAEState.Precapture ||
                    aeState.IntValue() == (int)ControlAEState.FlashRequired)
                {
                    State = CaptureState.WaitingNonPrecapture;
                }

                break;
            }

            case CaptureState.WaitingNonPrecapture:
            {
                // ControlAeState can be null on some devices
                var aeState = (Integer)result.Get(CaptureResult.ControlAeState);
                if (aeState == null || aeState.IntValue() != (int)ControlAEState.Precapture)
                {
                    State = CaptureState.PictureTaken;
                    CaptureStillPicture();
                }

                break;
            }

            case CaptureState.Preview:
                break;

            case CaptureState.PictureTaken:
                break;

            default:
                throw new NotSupportedException("This camera state is not supported.");
            }
        }