public bool Start(CameraFacing cameraId, GotchaAFrame gotchaAFrameFromCamera) { bool result = true; this.IsStopped = false; this.GotchaAFrameCallback = gotchaAFrameFromCamera; try { using (Handler handler = new Handler(Looper.MainLooper)) { handler.Post(() => { cameraPreviewCallback = new MyCameraPreviewCallback(PictureDefaultFilename, GotchaAFrameFromCamera); surfaceView = new SurfaceView(Application.Context); windowManager = Application.Context.GetSystemService(Context.WindowService).JavaCast <IWindowManager>(); WindowManagerLayoutParams parameters = new WindowManagerLayoutParams( 1, 1, WindowManagerTypes.SystemOverlay, WindowManagerFlags.WatchOutsideTouch, Android.Graphics.Format.Translucent); surfaceHolder = surfaceView.Holder; surfaceView.SetZOrderOnTop(true); surfaceHolder.SetFormat(Android.Graphics.Format.Translucent); surfaceHolderCallback = new MySurfaceHolderCallback(surfaceHolder, cameraPreviewCallback); surfaceHolderCallback.cameraId = cameraId; surfaceHolder.AddCallback(surfaceHolderCallback); windowManager.AddView(surfaceView, parameters); }); } } catch (Exception e) { Log.Error(TAG, "Error: " + e.StackTrace); result = false; } return(result); }
public MyCameraPreviewCallback(string filenameBase, GotchaAFrame gotchaAFrameCallback = null) { this.filenameBase = filenameBase; this.GotchaAFrameCallback = gotchaAFrameCallback; }