Esempio n. 1
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);

            contourDetectorFrameHandler = ContourDetectorFrameHandler.Attach(cameraView);
            polygonView = FindViewById <PolygonView>(Resource.Id.scanbotPolygonView);
            polygonView.SetStrokeColor(Color.Red);
            polygonView.SetStrokeColorOK(Color.Green);
            contourDetectorFrameHandler.AddResultHandler(polygonView);
            contourDetectorFrameHandler.AddResultHandler(this);

            // 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);
            });
        }