protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); // Set our view from the "main" layout resource SetContentView(Resource.Layout.Main); cameraView = FindViewById <ScanbotCameraView>(Resource.Id.camera); resultView = FindViewById <ImageView>(Resource.Id.result); ContourDetectorFrameHandler contourDetectorFrameHandler = ContourDetectorFrameHandler.Attach(cameraView); PolygonView polygonView = FindViewById <PolygonView>(Resource.Id.polygonView); contourDetectorFrameHandler.AddResultHandler(polygonView); AutoSnappingController.Attach(cameraView, contourDetectorFrameHandler); cameraView.AddPictureCallback(this); FindViewById(Resource.Id.snap).Click += delegate { cameraView.TakePicture(false); }; FindViewById(Resource.Id.flash).Click += delegate { cameraView.UseFlash(!flashEnabled); flashEnabled = !flashEnabled; }; }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); // Use our example view (MyCameraView.axml) SetContentView(Resource.Layout.SnapingCameraLayout); SupportActionBar.Hide(); cameraView = FindViewById <ScanbotCameraView>(Resource.Id.scanbotCameraView); resultImageView = FindViewById <ImageView>(Resource.Id.scanbotResultImageView); userGuidanceTextView = FindViewById <TextView>(Resource.Id.userGuidanceTextView); ContourDetectorFrameHandler contourDetectorFrameHandler = ContourDetectorFrameHandler.Attach(cameraView); PolygonView polygonView = FindViewById <PolygonView>(Resource.Id.scanbotPolygonView); contourDetectorFrameHandler.AddResultHandler(polygonView); contourDetectorFrameHandler.AddResultHandler(this); //autoSnappingController = AutoSnappingController.Attach(cameraView, contourDetectorFrameHandler); //// Set the sensitivity of AutoSnappingController //// Range is from 0 to 1, where 1 is the most sensitive. The more sensitive it is the faster it shoots. //autoSnappingController.SetSensitivity(1.0f); cameraView.AddPictureCallback(this); cameraView.SetCameraOpenCallback(this); FindViewById(Resource.Id.scanbotSnapButton).Click += delegate { cameraView.TakePicture(false); }; FindViewById(Resource.Id.scanbotFlashButton).Click += delegate { cameraView.UseFlash(!flashEnabled); flashEnabled = !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); }); }