protected override void OnElementChanged(ElementChangedEventArgs <AR_Sudoku_Solver.CameraPreview> e)
        {
            base.OnElementChanged(e);

            if (Control == null)
            {
                cameraPreview = new CameraPreview(Context);
                SetNativeControl(cameraPreview);
            }

            if (e.OldElement != null)
            {
                // Unsubscribe
                cameraPreview.Click -= OnCameraPreviewClicked;
            }
            if (e.NewElement != null)
            {
                Control.Preview = Camera.Open((int)e.NewElement.Camera);
                var parameters = Control.Preview.GetParameters();
                parameters.FocusMode = Camera.Parameters.FocusModeContinuousPicture;
                Control.Preview.SetParameters(parameters);

                int numBytes = (parameters.PreviewSize.Width * parameters.PreviewSize.Height * Android.Graphics.ImageFormat.GetBitsPerPixel(parameters.PreviewFormat)) / 8;
                using (FastJavaByteArray buffer = new FastJavaByteArray(numBytes))
                {
                    // allocate new Java byte arrays for Android to use for preview frames
                    Control.Preview.AddCallbackBuffer(new FastJavaByteArray(numBytes));
                }

                Control.Preview.SetNonMarshalingPreviewCallback(new AndroidImagePreviewCallbackHandler(e.NewElement.ImageHandlerCallback, cameraPreview));
                // Subscribe
                cameraPreview.Click += OnCameraPreviewClicked;
            }
        }
        public AndroidImagePreviewCallbackHandler(iImagePreviewHandler previewHandler, CameraPreview camerapreview)
        {
            this.previewHandler = previewHandler;
            this.camerapreview  = camerapreview;
            var assembly = typeof(CameraPreviewRenderer).Assembly;
            var stream   = assembly.GetManifestResourceStream("AR_Sudoku_Solver.Droid.trainedKSVM.bin");

            byte[] trainedKSVM = new byte[stream.Length];
            for (int i = 0; i < stream.Length; i++)
            {
                trainedKSVM[i] = (byte)stream.ReadByte();
            }
            sf = new SudokuFinder(trainedKSVM);
        }