//this should ultimately be user driven like google photos can recycle code below later to find out hardware capabilites when giving users options private void SetVideoSize(CameraFacing camface) //determines cameras supported sizes and sets frame sizes for video as best as possible { CameraManager manager = (CameraManager)GetSystemService(Context.CameraService); var cams = manager.GetCameraIdList(); LensFacing lensface = camface == CameraFacing.Back ? LensFacing.Back : LensFacing.Front; foreach (var camid in cams) { var camprops = manager.GetCameraCharacteristics(camid); if ((int)camprops.Get(CameraCharacteristics.LensFacing) == (int)lensface) { var map = (StreamConfigurationMap)camprops.Get(CameraCharacteristics.ScalerStreamConfigurationMap); Size[] sizes = map.GetOutputSizes((int)ImageFormatType.Jpeg); if (sizes.ToList().Any(s => s.Width == 1280 && s.Height == 720)) //if this format is supported then always use it, this is 16:9 aspect HD { pFramewidth = 1280; pFrameHeight = 720; } else //if (sizes.ToList().Any(s => s.Width == 640 && s.Height == 480)) //if HD is not supported use this default {//if HD is not supported use this default pFramewidth = 640; pFrameHeight = 480; } } } }
void SwitchCameraButtonTapped(object sender, EventArgs e) { if (isLoading) { return; } if (cameraType == CameraFacing.Front) { cameraType = CameraFacing.Back; camera.StopPreview(); camera.Release(); camera = global::Android.Hardware.Camera.Open((int)cameraType); camera.SetPreviewTexture(surfaceTexture); PrepareAndStartCamera(); } else { cameraType = CameraFacing.Front; camera.StopPreview(); camera.Release(); camera = global::Android.Hardware.Camera.Open((int)cameraType); camera.SetPreviewTexture(surfaceTexture); PrepareAndStartCamera(); } }
protected override void OnElementChanged(ElementChangedEventArgs <Page> e) { base.OnElementChanged(e); if (e.OldElement != null || Element == null) { return; } try { activity = this.Context as Activity; view = activity.LayoutInflater.Inflate(Resource.Layout.CameraLayout, this, false); cameraType = CameraFacing.Back; textureView = view.FindViewById <TextureView> (Resource.Id.textureView); textureView.SurfaceTextureListener = this; takePhotoButton = view.FindViewById <global::Android.Widget.Button> (Resource.Id.takePhotoButton); takePhotoButton.Click += TakePhotoButtonTapped; switchCameraButton = view.FindViewById <global::Android.Widget.Button> (Resource.Id.switchCameraButton); switchCameraButton.Click += SwitchCameraButtonTapped; toggleFlashButton = view.FindViewById <global::Android.Widget.Button> (Resource.Id.toggleFlashButton); toggleFlashButton.Click += ToggleFlashButtonTapped; AddView(view); } catch (Exception ex) { //Xamarin.Insights.Report (ex); } }
//switches between front and back cameras when button is clicked void SwitchCameraButtonTapped(object sender, EventArgs e) { //if camera isn't started if (!_isCameraStarted) { return; } if (cameraType == CameraFacing.Front) { cameraType = CameraFacing.Back; camera.StopPreview(); camera.Release(); camera = Android.Hardware.Camera.Open((int)cameraType); camera.SetPreviewTexture(surfaceTexture); PrepareAndStartCamera(); } else { cameraType = CameraFacing.Front; camera.StopPreview(); camera.Release(); camera = Android.Hardware.Camera.Open((int)cameraType); camera.SetPreviewTexture(surfaceTexture); PrepareAndStartCamera(); } }
/** * Creates and starts the camera. Note that this uses a higher resolution in comparison * to other detection examples to enable the barcode detector to detect small barcodes * at long distances. */ private void CreateCameraSource(CameraFacing direction) { var context = Application.Context; FaceDetector detector = new FaceDetector.Builder(context) .SetClassificationType(ClassificationType.All) .Build(); detector.SetProcessor( new MultiProcessor.Builder(this) .Build()); if (!detector.IsOperational) { // Note: The first time that an app using face API is installed on a device, GMS will // download a native library to the device in order to do detection. Usually this // completes before the app is run for the first time. But if that download has not yet // completed, then the above call will not detect any faces. // // isOperational() can be used to check if the required native library is currently // available. The detector will automatically become operational once the library // download completes on device. Log.Warn(TAG, "Face detector dependencies are not yet available."); } _mCameraSource = new CameraSource.Builder(context, detector) .SetRequestedPreviewSize(640, 480) .SetFacing(direction) .SetRequestedFps(30.0f) .Build(); }
//public void RefreshCamera() //{ // if (_holder == null) return; // ApplyCameraSettings(); // try // { // Camera.SetPreviewDisplay(_holder); // Camera.StartPreview(); // } // catch (Exception ex) // { // Android.Util.Log.Debug(nameof(CameraController), ex.ToString()); // } //} public void SetupCamera(CameraFacing facing) { if (Camera != null) { return; } PermissionsHandler.CheckCameraPermissions(_context); OpenCamera(facing); if (Camera == null) { return; } ApplyCameraSettings(); try { Camera.SetPreviewDisplay(_holder); //var previewParameters = Camera.GetParameters(); //var previewSize = previewParameters.PreviewSize; //var bitsPerPixel = ImageFormat.GetBitsPerPixel(previewParameters.PreviewFormat); //int bufferSize = (previewSize.Width * previewSize.Height * bitsPerPixel) / 8; //const int NUM_PREVIEW_BUFFERS = 5; //for (uint i = 0; i < NUM_PREVIEW_BUFFERS; ++i) //{ // using (var buffer = new FastJavaByteArray(bufferSize)) // Camera.AddCallbackBuffer(buffer); //} Camera.StartPreview(); // Camera.SetNonMarshalingPreviewCallback(_cameraEventListener); } catch (Exception ex) { Android.Util.Log.Debug(nameof(CameraController), ex.ToString()); return; } // Docs suggest if Auto or Macro modes, we should invoke AutoFocus at least once var currentFocusMode = Camera.GetParameters().FocusMode; if (currentFocusMode == Camera.Parameters.FocusModeAuto || currentFocusMode == Camera.Parameters.FocusModeMacro) { AutoFocus(); } }
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(); } }
public void Convert(Entity entity, EntityManager dstManager, GameObjectConversionSystem conversionSystem) { var data = new CameraFacing { }; dstManager.AddComponentData(entity, data); }
protected override void OnElementChanged (ElementChangedEventArgs<Page> e) { base.OnElementChanged (e); if (e.OldElement != null || Element == null) return; try { activity = this.Context as Activity; view = activity.LayoutInflater.Inflate(Resource.Layout.CameraLayout, this, false); cameraType = CameraFacing.Back; textureView = view.FindViewById<TextureView> (Resource.Id.textureView); textureView.SurfaceTextureListener = this; takePhotoButton = view.FindViewById<global::Android.Widget.Button> (Resource.Id.takePhotoButton); takePhotoButton.Click += TakePhotoButtonTapped; switchCameraButton = view.FindViewById<global::Android.Widget.Button> (Resource.Id.switchCameraButton); switchCameraButton.Click += SwitchCameraButtonTapped; toggleFlashButton = view.FindViewById<global::Android.Widget.Button> (Resource.Id.toggleFlashButton); toggleFlashButton.Click += ToggleFlashButtonTapped; AddView (view); } catch (Exception ex) { //Xamarin.Insights.Report (ex); } }
/// <summary> /// Sets the camera attributes for size and facing direction, which informs how to transform image coordinates later. /// </summary> /// <param name="previewWidth"></param> /// <param name="previewHeight"></param> /// <param name="facing"></param> public void SetCameraInfo(int previewWidth, int previewHeight, CameraFacing facing) { lock (mLock) { PreviewWidth = previewWidth; PreviewHeight = previewHeight; CameraFacing = facing; } PostInvalidate(); }
void SetupUserInterface () { activity = this.Context as Activity; view = activity.LayoutInflater.Inflate (Resource.Layout.CameraLayout, this, false); cameraType = CameraFacing.Back; textureView = view.FindViewById<TextureView> (Resource.Id.textureView); textureView.SurfaceTextureListener = this; }
private void SetDiyParams(Context context, IAttributeSet attrs) { var a = context.ObtainStyledAttributes(attrs, Resource.Styleable.YsCameraX); CaptureImageSize_Width = a.GetInt(Resource.Styleable.YsCameraX_CapturePictureSize_Width, 1280); CaptureImageSize_Height = a.GetInt(Resource.Styleable.YsCameraX_CapturePictureSize_Height, 720); CameraFacing = (CameraFacing)a.GetInt(Resource.Styleable.YsCameraX_Camera_Facing, 0); a.Recycle(); }
private int SwitchCamera() { int cameraId = 1;//NextCameraId(); _camera = Camera.Open(cameraId); _currentCameraFacing = _cameraInfo.GetCameraFacing(cameraId); return(cameraId); }
void SetupUserInterface() { activity = this.Context as Activity; view = activity.LayoutInflater.Inflate(Resource.Layout.CameraLayout, this, false); cameraType = CameraFacing.Back; textureView = view.FindViewById <TextureView>(Resource.Id.textureView); textureView.SurfaceTextureListener = this; }
/** * Sets the height and width of the camera */ public void SetInformationFromCamera(int previewWidth, int previewHeight, CameraFacing cameraFacing) { lock (isBlocked) { pixelsX = previewWidth; pixelsY = previewHeight; this.cameraFacing = cameraFacing; } PostInvalidate(); }
private void SetupUserInterface() { _activity = Context as Activity; _view = _activity.LayoutInflater.Inflate(Resource.Layout.CameraLayout, this, false); _cameraType = CameraFacing.Back; _textureView = _view.FindViewById <TextureView>(Resource.Id.textureView); _textureView.SurfaceTextureListener = this; _textureView.SetOnTouchListener(this); }
public void SetCameraInfo(int previewWidth, int previewHeight, CameraFacing facing) { lock (_lockObj) { _previewWidth = previewWidth; _previewHeight = previewHeight; _facing = facing; } base.PostInvalidate(); }
private void SwitchCameraButtonTapped(object sender, EventArgs e) { cameraType = cameraType == CameraFacing.Front ? CameraFacing.Back : CameraFacing.Front; camera.StopPreview(); camera.Release(); camera = global::Android.Hardware.Camera.Open((int)cameraType); camera.SetPreviewTexture(surfaceTexture); PrepareAndStartCamera(); }
private int SwitchCamera() { try { int cameraId = int.Parse(MainValues.front_back);//NextCameraId(); _camera = Camera.Open(cameraId); _currentCameraFacing = _cameraInfo.GetCameraFacing(cameraId); return(cameraId); } catch (Exception) { return(5); } }
public CameraPage() { activity = this.Context as MainActivity; view = activity.LayoutInflater.Inflate(Resource.Layout.CameraLayoutOld, this, false); cameraType = CameraFacing.Back; textureView = view.FindViewById <TextureView>(Resource.Id.textureView); textureView.SurfaceTextureListener = this; previousPhoto = view.FindViewById <ImageView>(Resource.Id.previousPhoto); }
void Awake() { meshFilter = GetComponent <MeshFilter>(); cameraFacing = GetComponent <CameraFacing>(); vertices = new List <Vector3>(); colors = new List <Color>(); uvs = new List <Vector2>(); triangles = new List <int>(); mesh = meshFilter.mesh; }
void Awake() { meshFilter = GetComponent<MeshFilter>(); cameraFacing = GetComponent<CameraFacing>(); vertices = new List<Vector3>(); colors = new List<Color>(); uvs = new List<Vector2>(); triangles = new List<int>(); mesh = meshFilter.mesh; }
private void SwitchCameraButton_Click(object sender, EventArgs e) { if (Android.OS.Build.VERSION.SdkInt >= Android.OS.BuildVersionCodes.Lollipop) { string[] camPermissions = { Android.Manifest.Permission.Camera }; // Make sure we can use the camera if ((int)Android.OS.Build.VERSION.SdkInt >= 23 && Activity.CheckSelfPermission(camPermissions[0]) != (Permission.Granted)) { Toast.MakeText(Activity, AppResources.Camera_permissionNeeded, ToastLength.Long).Show(); Activity.RequestPermissions(camPermissions, CamPermReqId); return; } mCameraDevice.Close(); int newCamIndex = backCam ? 1 : 0; backCam = !backCam; try { OpenCamera(newCamIndex); } catch (System.Exception ex) { System.Console.WriteLine(ex); } } else { if (cameraType == CameraFacing.Front) { cameraType = CameraFacing.Back; camera.StopPreview(); camera.Release(); camera = Android.Hardware.Camera.Open((int)cameraType); camera.SetPreviewTexture(surfaceTexture); PrepareAndStartCamera1(); } else { cameraType = CameraFacing.Front; camera.StopPreview(); camera.Release(); camera = Android.Hardware.Camera.Open((int)cameraType); camera.SetPreviewTexture(surfaceTexture); PrepareAndStartCamera1(); } } }
private void ToggleCamface() { if (camface == CameraFacing.Front) { camface = CameraFacing.Back; ReleaseRestartResources(false); } else { camface = CameraFacing.Front; ReleaseRestartResources(false); } }
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(); } }
private void SetupUserInterface() { activity = Context as Activity; view = activity.LayoutInflater.Inflate(Resource.Layout.CameraLayout, this, false); cameraType = CameraFacing.Back; textureView = view.FindViewById <TextureView>(Resource.Id.textureView); textureView.SurfaceTextureListener = this; takePhotoButton = view.FindViewById <Button>(Resource.Id.takePhotoButton); switchCameraButton = view.FindViewById <Button>(Resource.Id.switchCameraButton); toggleFlashButton = view.FindViewById <Button>(Resource.Id.toggleFlashButton); cancelButton = view.FindViewById <Button>(Resource.Id.cancelButton); }
private void OpenCamera(CameraFacing whichCamera) { try { var version = Build.VERSION.SdkInt; if (version >= BuildVersionCodes.Gingerbread) { var numCameras = Camera.NumberOfCameras; var camInfo = new Camera.CameraInfo(); var found = false; for (var i = 0; i < numCameras; i++) { Camera.GetCameraInfo(i, camInfo); if (camInfo.Facing == whichCamera) { Camera = Camera.Open(i); _cameraId = i; found = true; break; } } if (!found) { Camera = Camera.Open(0); _cameraId = 0; } } else { Camera = Camera.Open(); } //if (Camera != null) // Camera.SetPreviewCallback(_cameraEventListener); //else // MobileBarcodeScanner.LogWarn(MobileBarcodeScanner.TAG, "Camera is null :("); } catch (Exception ex) { ShutdownCamera(); // MobileBarcodeScanner.LogError("Setup Error: {0}", ex); } }
private void ActivateCamera(CameraFacing facing) { if (!initialized) { return; } // Any spray compositing that happens while the camera is initializing should spray pitch black. activeTexture = Texture2D.blackTexture; staleFramesReceived = 0; var device = (facing == CameraFacing.Front) ? DeviceCamera.FrontCamera : DeviceCamera.RearCamera; if (device != null) { // We can't change the resolution while the preview is playing. if (NatCam.IsPlaying) { NatCam.Pause(); } NatCam.ActiveCamera = device; NatCam.OnPreviewStart += OnPreviewStart; NatCam.OnPreviewUpdate += OnPreviewUpdate; NatCam.ActiveCamera.SetFramerate(deviceCameraFramerate); NatCam.ActiveCamera.SetResolution(deviceCameraResolution); // The exposure and focus modes are only available on the native interface. if (NatCam.Interface == NatCamInterface.NativeInterface) { NatCam.ActiveCamera.FocusMode = deviceCameraFocusMode; NatCam.ActiveCamera.ExposureMode = deviceCameraExposureMode; } NatCam.Play(); if (FacingChanged != null) { FacingChanged(facing); } } else if (Debug.isDebugBuild) { Debug.LogError("CameraCapture: no camera for this orientation"); } }
public void CreateCameraSource(CameraFacing cameraFacing) { FaceDetector detector = new FaceDetector.Builder(this).Build(); detector.SetProcessor(new MultiProcessor.Builder(this).Build()); if (!detector.IsOperational) { Log.Warn(TAG, "Face detector isn't configured yet"); } cameraSource = new CameraSource.Builder(this, detector) .SetRequestedPreviewSize(640, 480) .SetFacing(cameraFacing) .SetAutoFocusEnabled(true) .SetRequestedFps(30.0f) .Build(); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); var b = savedInstanceState ?? Intent.Extras; id = b.GetInt(ExtraId); front = b.GetInt(ExtraFront); SetContentView(Resource.Layout.CameraLayout); cameraType = (CameraFacing)front; takePhotoButton = FindViewById <Button>(Resource.Id.takePhotoButton); takePhotoButton.Click += TakePhotoButtonTapped; textureView = FindViewById <TextureView>(Resource.Id.textureView); textureView.SurfaceTextureListener = this; }
private void BtnSwitchCamera_Click(object sender, EventArgs e) { switch (_cameraFacing) { case CameraFacing.Back: _cameraFacing = CameraFacing.Front; break; case CameraFacing.Front: _cameraFacing = CameraFacing.Back; break; default: return; } ReleaseCamera(); InitializeCamera(); }
public void SetupUserInterface(int height, int width) { _activity = this.Context as Activity; if ((_view = _activity?.LayoutInflater.Inflate(Resource.Layout.CameraLayout, this, false)) == null) { return; } var cameraView = _view.FindViewById <FrameLayout>(Resource.Id.cameraView); var parameters = cameraView.LayoutParameters; parameters.Height = height; parameters.Height = width; _cameraType = CameraFacing.Front; this.AddView(_view); _textureView = _view.FindViewById <TextureView>(Resource.Id.textureView); _textureView.SurfaceTextureListener = this; }
void SetupUserInterface() { activity = this.Context as Activity; view = activity.LayoutInflater.Inflate(Resource.Layout.CameraLayout, this, false); cameraType = CameraFacing.Back; textureView = view.FindViewById <TextureView>(Resource.Id.textureView); textureView.SurfaceTextureListener = this; OCR_textView = view.FindViewById <TextView>(Resource.Id.myOCR_TextView); OCR_Rectangle = view.FindViewById <ImageView>(Resource.Id.btn_capture_photo); OCR_Top_Left = view.FindViewById <ImageView>(Resource.Id.Top_Left_photo); OCR_Top_Right = view.FindViewById <ImageView>(Resource.Id.Top_Right_photo); OCR_Bottom_Left = view.FindViewById <ImageView>(Resource.Id.Bottom_Left_photo); OCR_Bottom_Right = view.FindViewById <ImageView>(Resource.Id.Bottom_Right_photo); Canvas canvas = textureView.LockCanvas(); Paint paint; paint = new Paint(); paint.Color = Android.Graphics.Color.Red; paint.SetStyle(Paint.Style.Stroke); paint.StrokeWidth = 2f; Rect r = new Rect((int)100, (int)100, (int)200, (int)200); // canvas.DrawRect(r, paint); var absolutePath = Android.OS.Environment.GetExternalStoragePublicDirectory(Android.OS.Environment.DirectoryDcim).AbsolutePath; if (!Directory.Exists(absolutePath + "/tessdata")) { Directory.CreateDirectory(absolutePath + "/tessdata"); } if (!File.Exists(absolutePath + "/tessdata/eng.traineddata")) { string destPath = absolutePath + "/tessdata/eng.traineddata"; using (var source = activity.Assets.Open("eng.traineddata")) using (var dest = File.OpenWrite(destPath)) source.CopyTo(dest); } }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); if (this.Intent != null) { var receiverID = this.Intent.GetStringExtra(KEY_RECEIVER_ID); if(receiverID != null) _receiverID = new Guid(receiverID); } this.SetContentView(Resource.Layout.activity_camera); try { cameraType = CameraFacing.Back; textureView = this.FindViewById<TextureView>(Resource.Id.textureView); textureView.SurfaceTextureListener = this; takePhotoButton = this.FindViewById<global::Android.Widget.Button>(Resource.Id.takePhotoButton); takePhotoButton.Click += TakePhotoButtonTapped; switchCameraButton = this.FindViewById<global::Android.Widget.Button>(Resource.Id.switchCameraButton); switchCameraButton.Click += SwitchCameraButtonTapped; toggleFlashButton = this.FindViewById<global::Android.Widget.Button>(Resource.Id.toggleFlashButton); toggleFlashButton.Click += ToggleFlashButtonTapped; } catch (Exception ex) { Xamarin.Insights.Report(ex); } }
protected override void OnElementChanged(ElementChangedEventArgs<Page> e) { base.OnElementChanged(e); if (e.OldElement != null || Element == null) return; try { var activity = this.Context as Activity; activity.RequestedOrientation = ScreenOrientation.Landscape; view = activity.LayoutInflater.Inflate(Resource.Layout.CameraLayout, this, false); _textureView = view.FindViewById<TextureView>(Resource.Id.textureView); _textureView.SurfaceTextureListener = this; cameraType = CameraFacing.Back; AddView(view); } catch (Exception ex) { Console.WriteLine("Roland error...." + ex.Message); } }
private 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(); } }
private void SwitchCameraButtonTapped(object sender, EventArgs e) { if (cameraType == CameraFacing.Front) { cameraType = CameraFacing.Back; camera.StopPreview(); camera.Release(); camera = global::Android.Hardware.Camera.Open((int)cameraType); camera.SetPreviewTexture(surfaceTexture); PrepareAndStartCamera(); } else { cameraType = CameraFacing.Front; camera.StopPreview(); camera.Release(); camera = global::Android.Hardware.Camera.Open((int)cameraType); camera.SetPreviewTexture(surfaceTexture); PrepareAndStartCamera(); } }