public void OnSurfaceTextureSizeChanged(SurfaceTexture surface, int width, int height) { _camera2.ConfigureTransform(width, height); }
public void OnSurfaceTextureUpdated(SurfaceTexture surface) { //throw new NotImplementedException(); }
public bool OnSurfaceTextureDestroyed(SurfaceTexture surface) { previewPage.UnderlyingService.DetectionResultAquired -= OnDetectionResultAquired; cameraPreview.PreviewTexture = null; return(true); }
public void OnSurfaceTextureAvailable(SurfaceTexture surface, int width, int height) { _camera2.OpenCamera(width, height); }
public override bool onSurfaceTextureDestroyed(SurfaceTexture surface) { return(true); }
public void OnSurfaceTextureAvailable(SurfaceTexture surface, int width, int height) { throw new NotImplementedException(); }
void TextureView.ISurfaceTextureListener.OnSurfaceTextureSizeChanged(SurfaceTexture surface, int width, int height) { }
public bool OnSurfaceTextureDestroyed(SurfaceTexture surface) { StopCamera(); return(true); }
public bool OnSurfaceTextureDestroyed(SurfaceTexture surface) { StopBackgroundThread(); return(true); }
bool TextureView.ISurfaceTextureListener.OnSurfaceTextureDestroyed(SurfaceTexture surface) { return(true); }
public bool OnSurfaceTextureDestroyed(SurfaceTexture surface) { return(true); }
public void OnSurfaceTextureAvailable(SurfaceTexture surface, int width, int height) { owner.OpenCamera(width, height); // TODO only open when the view is ready for viewing }
public void OnSurfaceTextureAvailable(SurfaceTexture surface, int width, int height) { { _surface = surface; { int cameraCount = Android.Hardware.Camera.NumberOfCameras; int cameraId = 0; Android.Hardware.Camera.CameraInfo cameraInfo = new Android.Hardware.Camera.CameraInfo(); for (int camIdx = 0; camIdx < cameraCount; camIdx++) { Android.Hardware.Camera.GetCameraInfo(camIdx, cameraInfo); if (cameraInfo.Facing == Android.Hardware.CameraFacing.Front) { camera = Android.Hardware.Camera.Open(camIdx); currentFacing = Android.Hardware.CameraFacing.Front; cameraId = camIdx; break; } } if (camera == null) { camera = Android.Hardware.Camera.Open(); } } var parameters = camera.GetParameters(); var aspect = ((decimal)height) / ((decimal)width); // Find the preview aspect ratio that is closest to the surface aspect //var previewSize = parameters.SupportedPreviewSizes // .OrderBy(s => Math.Abs(s.Width / (decimal)s.Height - aspect)) // .First(); var previewSize = parameters.SupportedPreviewSizes[2]; // mainLayout.LayoutParameters.Height = previewSize.Height; // mainLayout.LayoutParameters.Width = previewSize.Width; parameters.SetPreviewSize(previewSize.Width, previewSize.Height); camera.SetParameters(parameters); camera.SetPreviewTexture(surface); StartCamera(); //caemra page render Task.Run(() => { NetProcess.JpegStream.Clear(); DateTime chk = DateTime.Now; while (isDestroy == false) { try { if (NetProcess.JpegStream.Count == 0) { continue; } if (chk < DateTime.Now) { exitButton.Text = "exit"; chk = DateTime.Now.AddSeconds(3); } MainThread.BeginInvokeOnMainThread(() => { StreamWrapper ms; while (NetProcess.JpegStream.TryDequeue(out ms) == true) { if (ms == null) { continue; } var bitmap = BitmapFactory.DecodeByteArray(ms?.stream.ToArray(), 0, ms.stream.ToArray().Length); ImageView imageView; if (imageViewDic.TryGetValue(ms.pos, out imageView) == true) { imageView?.SetImageBitmap(bitmap); } else { AddImageView(ms.pos); if (imageViewDic.TryGetValue(ms.pos, out imageView) == true) { imageView?.SetImageBitmap(bitmap); } } //제일 하단 큰 스크린 if (ms.pos == target_pos) { ImageView imageView2; if (imageViewDic.TryGetValue(6, out imageView2) == true) { imageView2?.SetImageBitmap(bitmap); } else { AddImageView(ms.pos); if (imageViewDic.TryGetValue(6, out imageView2) == true) { imageView2?.SetImageBitmap(bitmap); } } } } }); } catch (Exception e) { } } }); //caemra page render Task.Run(() => { audiomgr?.record(); }); Task.Run(() => { while (isDestroy == false) { StreamWrapper ms; if (NetProcess.AudioStream.TryDequeue(out ms) == true) { if (ms == null) { continue; } audiomgr?.play(ms.stream.ToArray()); } } }); } }
public override void onSurfaceTextureAvailable(SurfaceTexture surface, int width, int height) { // "onSurfaceTextureAvailable" is called, which means that CameraCaptureSession is not created. // We need to configure transform for TextureView and crate CameraCaptureSession. outerInstance.configureTransform(width, height); outerInstance.createPreviewSession(); }
void TextureView.ISurfaceTextureListener.OnSurfaceTextureUpdated(SurfaceTexture surface) { }
public override bool onSurfaceTextureDestroyed(SurfaceTexture surface) { return true; }
public bool OnSurfaceTextureDestroyed(SurfaceTexture surfaceTexture) { this._owner.StopCamera(); return(true); }
public override void onSurfaceTextureSizeChanged(SurfaceTexture surface, int width, int height) { // SurfaceTexture size changed, we need to configure transform for TextureView, again. outerInstance.configureTransform(width, height); }
public void OnSurfaceTextureUpdated(SurfaceTexture surface) { this._owner.SurfaceTexture = surface; this.ProcessOnSurfaceTextureUpdate(); }
public override void onSurfaceTextureUpdated(SurfaceTexture surface) { }
Task ToggleTorchAsync(bool switchOn) { return(Task.Run(() => { lock (locker) { if (OperatingSystem.IsAndroidVersionAtLeast((int)BuildVersionCodes.M) && !AlwaysUseCameraApi) { var cameraManager = Platform.CameraManager; foreach (var id in cameraManager.GetCameraIdList()) { var hasFlash = cameraManager.GetCameraCharacteristics(id).Get(CameraCharacteristics.FlashInfoAvailable); if (Java.Lang.Boolean.True.Equals(hasFlash)) { try { cameraManager.SetTorchMode(id, switchOn); break; } catch (Exception ex) { System.Diagnostics.Debug.WriteLine($"Unable to SetTorchMode on {id}: {ex.Message}"); } } } } else { if (camera == null) { if (surface == null) { surface = new SurfaceTexture(0); } #pragma warning disable CS0618 // Camera types are deprecated in Android 10+ camera = Camera.Open(); // Nexus 5 and some devices require a preview texture camera.SetPreviewTexture(surface); } var param = camera.GetParameters(); // Deprecated in an earlier android version param.FlashMode = switchOn ? Camera.Parameters.FlashModeTorch : Camera.Parameters.FlashModeOff; camera.SetParameters(param); if (switchOn) { camera.StartPreview(); } else { camera.StopPreview(); camera.Release(); camera.Dispose(); #pragma warning restore CS0618 // Type or member is obsolete camera = null; surface.Dispose(); surface = null; } } } })); }
public bool OnSurfaceTextureDestroyed(SurfaceTexture surface) { throw new NotImplementedException(); }
public bool OnSurfaceTextureDestroyed(SurfaceTexture surface) { _camera.StopPreview(); _camera.Release(); return(true); }
//async void TakePhotoButtonTapped(object sender, EventArgs e) //{ // camera.StopPreview(); // var image = textureView.Bitmap; // try // { // var absolutePath = Android.OS.Environment.GetExternalStoragePublicDirectory(Android.OS.Environment.DirectoryDcim).AbsolutePath; // var folderPath = absolutePath + "/Camera"; // var filePath = System.IO.Path.Combine(folderPath, string.Format("photo_{0}.jpg", Guid.NewGuid())); // var fileStream = new FileStream(filePath, FileMode.Create); // await image.CompressAsync(Bitmap.CompressFormat.Jpeg, 50, fileStream); // fileStream.Close(); // image.Recycle(); // var intent = new Android.Content.Intent(Android.Content.Intent.ActionMediaScannerScanFile); // var file = new Java.IO.File(filePath); // var uri = Android.Net.Uri.FromFile(file); // intent.SetData(uri); // MainActivity.Instance.SendBroadcast(intent); // } // catch (Exception ex) // { // System.Diagnostics.Debug.WriteLine(@" ", ex.Message); // } // camera.StartPreview(); //} public void OnSurfaceTextureSizeChanged(SurfaceTexture surface, int width, int height) { }
public void OnSurfaceTextureSizeChanged(SurfaceTexture surface, int width, int height) { PrepareAndStartCamera(); }
public bool OnSurfaceTextureDestroyed(SurfaceTexture surface) { _camera2.CameraDevice?.Close(); _camera2.CameraDevice = null; return(true); }
public void OnSurfaceTextureAvailable(SurfaceTexture surface, int width, int height) { Console.WriteLine("Surface.TextureAvailable"); VideoPlayer.SetSurface(new Surface(surface)); }
public void OnSurfaceTextureSizeChanged(SurfaceTexture surface, int width, int height) { //throw new NotImplementedException(); }
public bool OnSurfaceTextureDestroyed(SurfaceTexture surface) { Console.WriteLine("Surface.TextureDestroyed"); RemoveVideo(); return(false); }
public void OnSurfaceTextureUpdated(SurfaceTexture surface) { }
public void OnSurfaceTextureSizeChanged(SurfaceTexture surface, int width, int height) { Console.WriteLine("Surface.TextureSizeChanged"); }
public void OnSurfaceTextureUpdated(SurfaceTexture surface) { Console.WriteLine("Surface.TextureUpdated"); }
public override int startCapture() { if (isCaptureStarted) { return -1; } // Set the preferred capturing size configureCaptureSize(PREFERRED_CAPTURE_WIDTH, PREFERRED_CAPTURE_HEIGHT); // Set the capture parameters Camera.Parameters parameters = mCamera.Parameters; parameters.setPreviewSize(mCaptureWidth, mCaptureHeight); parameters.PreviewFormat = PIXEL_FORMAT; parameters.PreviewFrameRate = mCaptureFPS; try { mCamera.Parameters = parameters; } catch (Exception e) { Log.e(LOGTAG, "setParameters failed", e); return -1; } // Create capture buffers PixelFormat pixelFormat = new PixelFormat(); PixelFormat.getPixelFormatInfo(PIXEL_FORMAT, pixelFormat); int bufSize = mCaptureWidth * mCaptureHeight * pixelFormat.bitsPerPixel / 8; sbyte[] buffer = null; for (int i = 0; i < mNumCaptureBuffers; i++) { buffer = new sbyte[bufSize]; mCamera.addCallbackBuffer(buffer); } try { mSurfaceTexture = new SurfaceTexture(42); mCamera.PreviewTexture = mSurfaceTexture; } catch (Exception e) { // TODO Auto-generated catch block Console.WriteLine(e.ToString()); Console.Write(e.StackTrace); } // Start preview mCamera.PreviewCallbackWithBuffer = this; mCamera.startPreview(); mPreviewBufferLock.@lock(); mExpectedFrameSize = bufSize; isCaptureRunning = true; mPreviewBufferLock.unlock(); isCaptureStarted = true; return 0; }