示例#1
0
        void ToggleFlashButtonTapped(object sender, EventArgs e)
        {
            flashOn = !flashOn;
            if (flashOn)
            {
                if (cameraType == CameraFacing.Back)
                {
                    toggleFlashButton.SetBackgroundResource(Resource.Drawable.FlashButton);
                    cameraType = CameraFacing.Back;

                    camera.StopPreview();
                    camera.Release();
                    camera = global::Android.Hardware.Camera.Open((int)cameraType);
                    var parameters = camera.GetParameters();
                    parameters.FlashMode = global::Android.Hardware.Camera.Parameters.FlashModeTorch;
                    camera.SetParameters(parameters);
                    camera.SetPreviewTexture(surfaceTexture);
                    PrepareAndStartCamera();
                }
            }
            else
            {
                toggleFlashButton.SetBackgroundResource(Resource.Drawable.NoFlashButton);
                camera.StopPreview();
                camera.Release();

                camera = global::Android.Hardware.Camera.Open((int)cameraType);
                var parameters = camera.GetParameters();
                parameters.FlashMode = global::Android.Hardware.Camera.Parameters.FlashModeOff;
                camera.SetParameters(parameters);
                camera.SetPreviewTexture(surfaceTexture);
                PrepareAndStartCamera();
            }
        }
示例#2
0
 void ToggleFlashButtonTapped(object sender, EventArgs e)
 {
     if (cameraPreview.FlashEnabled)
     {
         cameraPreview.FlashEnabled = false;
         toggleFlashButton.SetBackgroundResource(ObjectDetectionApp.Droid.Resource.Drawable.NoFlashButton);
     }
     else
     {
         cameraPreview.FlashEnabled = true;
         toggleFlashButton.SetBackgroundResource(ObjectDetectionApp.Droid.Resource.Drawable.FlashButton);
     }
 }
示例#3
0
        void ToggleFlashButtonTapped(object sender, EventArgs e)
        {
            flashOn = !flashOn;
            if (flashOn)
            {
                if (cameraType == CameraFacing.Back)
                {
                    toggleFlashButton.SetBackgroundResource(Resource.Drawable.FlashButton);
                    cameraType = CameraFacing.Back;

                    camera.StopPreview();
                    camera.Release();
                    camera = global::Android.Hardware.Camera.Open((int)cameraType);
                    var parameters = camera.GetParameters();
                    parameters.FlashMode = global::Android.Hardware.Camera.Parameters.FlashModeTorch;
                    camera.SetParameters(parameters);
                    camera.SetPreviewTexture(surfaceTexture);

                    PrepareAndStartCamera();
                }
            }
            else
            {
                toggleFlashButton.SetBackgroundResource(Resource.Drawable.NoFlashButton);
                camera.StopPreview();
                camera.Release();

                camera = global::Android.Hardware.Camera.Open((int)cameraType);


                var infoFocusCalibration      = global::Android.Hardware.Camera2.CameraCharacteristics.LensInfoFocusDistanceCalibration;
                var infoSupportHardLevel      = global::Android.Hardware.Camera2.CameraCharacteristics.InfoSupportedHardwareLevel;
                var infoMinimumFocus          = global::Android.Hardware.Camera2.CameraCharacteristics.LensPoseRotation;
                var infoSensorActiveArraySize = global::Android.Hardware.Camera2.CameraCharacteristics.SensorInfoActiveArraySize;

                //var paramters2 = camera2.

                var parameters = camera.GetParameters();

                parameters.FlashMode = global::Android.Hardware.Camera.Parameters.FlashModeOff;
                parameters.FocusMode = global::Android.Hardware.Camera.Parameters.FocusModeAuto;

                camera.SetParameters(parameters);
                camera.SetPreviewTexture(surfaceTexture);
                camera.SetDisplayOrientation(100);
                var max = camera.GetParameters().MaxNumFocusAreas;

                PrepareAndStartCamera();
                camera.StartFaceDetection();
            }
        }