protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            SetContentView(Resource.Layout.CroppingImageDemo);

            SupportActionBar.SetDisplayShowHomeEnabled(false);
            SupportActionBar.SetDisplayShowTitleEnabled(false);
            SupportActionBar.SetDisplayShowCustomEnabled(true);
            SupportActionBar.SetDisplayHomeAsUpEnabled(false);
            SupportActionBar.SetCustomView(Resource.Layout.CroppingActionBarView);

            editPolygonImageView    = FindViewById <EditPolygonImageView>(Resource.Id.scanbotEditImageView);
            scanbotMagnifierView    = FindViewById <MagnifierView>(Resource.Id.scanbotMagnifierView);
            processImageProgressBar = FindViewById <ProgressBar>(Resource.Id.processImageProgressBar);

            cancelBtn        = FindViewById <View>(Resource.Id.cancelButton);
            cancelBtn.Click += delegate
            {
                Finish();
            };

            doneBtn        = FindViewById <View>(Resource.Id.doneButton);
            doneBtn.Click += delegate
            {
                cancelBtn.Enabled      = false;
                doneBtn.Enabled        = false;
                rotateCWButton.Enabled = false;
                CropAndSaveImage();
            };

            rotateCWButton        = FindViewById <View>(Resource.Id.rotateCWButton);
            rotateCWButton.Click += delegate
            {
                if ((Java.Lang.JavaSystem.CurrentTimeMillis() - lastRotationEventTs) < 350)
                {
                    return;
                }
                rotationDegrees += 90;
                editPolygonImageView.RotateClockwise();
                lastRotationEventTs = Java.Lang.JavaSystem.CurrentTimeMillis();
            };

            string imageFileUri = Intent.Extras.GetString(EXTRAS_ARG_IMAGE_FILE_URI);

            imageUri = AndroidNetUri.Parse(imageFileUri);
            InitImageView();

            SDK = new IO.Scanbot.Sdk.ScanbotSDK(this);
        }
Пример #2
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.BusinessCardsLayout);

            cameraView = FindViewById <ScanbotCameraView>(Resource.Id.camera);

            pictureCallbackDelegate = new PictureCallbackDelegate();
            pictureCallbackDelegate.OnPictureTakenHandler += ProcessTakenPicture;
            cameraView.AddPictureCallback(pictureCallbackDelegate);

            cameraView.SetCameraOpenCallback(this);
            cameraView.SetAutoFocusSound(false);

            progress = FindViewById <ProgressBar>(Resource.Id.progressView);

            shutterButton        = FindViewById <ShutterButton>(Resource.Id.snap);
            shutterButton.Click += delegate
            {
                cameraView.TakePicture(false);
            };
            shutterButton.Post(delegate
            {
                shutterButton.ShowAutoButton();
            });

            sdk = new IO.Scanbot.Sdk.ScanbotSDK(this);
            var detector = sdk.MultipleObjectsDetector();

            if (modParams != null)
            {
                detector.SetParams(modParams);
            }

            var handler = MultipleObjectsFrameHandler.Attach(cameraView, detector);

            var polygon = FindViewById <MultiplePolygonsView>(Resource.Id.polygonView);

            handler.AddResultHandler(new MultipleObjectsCallback());

            FindViewById(Resource.Id.flash).Click += delegate
            {
                flashEnabled = !flashEnabled;
                cameraView.UseFlash(flashEnabled);
            };
        }
        protected override void OnCreate(Bundle savedInstanceState)
        {
            SupportRequestWindowFeature(WindowCompat.FeatureActionBarOverlay);
            base.OnCreate(savedInstanceState);

            SetContentView(Resource.Layout.CameraViewDemo);

            SupportActionBar.Hide();

            cameraView = FindViewById <ScanbotCameraView>(Resource.Id.scanbotCameraView);

            // In this example we demonstrate how to lock the orientation of the UI (Activity)
            // as well as the orientation of the taken picture to portrait.
            cameraView.LockToPortrait(true);

            // Uncomment to disable AutoFocus by manually touching the camera view:
            //cameraView.SetAutoFocusOnTouch(false);

            // Preview Mode: See https://github.com/doo/Scanbot-SDK-Examples/wiki/Using-ScanbotCameraView#preview-mode
            //cameraView.SetPreviewMode(CameraPreviewMode.FitIn);

            userGuidanceTextView = FindViewById <TextView>(Resource.Id.userGuidanceTextView);

            imageProcessingProgress = FindViewById <ProgressBar>(Resource.Id.imageProcessingProgress);

            var detector = new IO.Scanbot.Sdk.ScanbotSDK(this).ContourDetector();

            contourDetectorFrameHandler = ContourDetectorFrameHandler.Attach(cameraView, detector);

            polygonView = FindViewById <PolygonView>(Resource.Id.scanbotPolygonView);
            polygonView.SetStrokeColor(Color.Red);
            polygonView.SetStrokeColorOK(Color.Green);

            // Attach the default polygon result handler, to draw the default polygon
            contourDetectorFrameHandler.AddResultHandler(polygonView.ContourDetectorResultHandler);
            // Add an additional custom contour detector to add user guidance text
            contourDetectorDelegate = new ContourDetectorDelegate();
            contourDetectorFrameHandler.AddResultHandler(contourDetectorDelegate);
            contourDetectorDelegate.ContourDetected += ShowUserGuidance;

            // See https://github.com/doo/Scanbot-SDK-Examples/wiki/Detecting-and-drawing-contours#contour-detection-parameters
            contourDetectorFrameHandler.SetAcceptedAngleScore(60);
            contourDetectorFrameHandler.SetAcceptedSizeScore(70);

            autoSnappingController = AutoSnappingController.Attach(cameraView, contourDetectorFrameHandler);
            autoSnappingController.SetIgnoreBadAspectRatio(ignoreBadAspectRatio);

            cameraView.AddPictureCallback(this);
            cameraView.SetCameraOpenCallback(this);

            shutterButton        = FindViewById <ShutterButton>(Resource.Id.shutterButton);
            shutterButton.Click += delegate
            {
                cameraView.TakePicture(false);
            };
            shutterButton.Visibility = ViewStates.Visible;

            FindViewById(Resource.Id.scanbotFlashButton).Click += delegate
            {
                cameraView.UseFlash(!flashEnabled);
                flashEnabled = !flashEnabled;
            };

            autoSnappingToggleButton        = FindViewById <Button>(Resource.Id.autoSnappingToggleButton);
            autoSnappingToggleButton.Click += delegate
            {
                autoSnappingEnabled = !autoSnappingEnabled;
                SetAutoSnapEnabled(autoSnappingEnabled);
            };

            shutterButton.Post(() =>
            {
                SetAutoSnapEnabled(autoSnappingEnabled);
            });
        }
        public static Android.Net.Uri GetPath(Context context, string pageId, PageFileStorage.PageFileType type)
        {
            var sdk = new IO.Scanbot.Sdk.ScanbotSDK(context);

            return(sdk.PageFileStorage.GetPreviewImageURI(pageId, type));
        }