public CameraFragment(CameraPageRenderer cpr, View view, Activity activity) { mCPR = cpr; mStateCallback = new CameraStateListener(this); mSurfaceTextureListener = new CameraSurfaceTextureListener(this); Activity = activity; // fill ORIENTATIONS list ORIENTATIONS.Append((int)SurfaceOrientation.Rotation0, 90); ORIENTATIONS.Append((int)SurfaceOrientation.Rotation90, 0); ORIENTATIONS.Append((int)SurfaceOrientation.Rotation180, 270); ORIENTATIONS.Append((int)SurfaceOrientation.Rotation270, 180); mTextureView = (AutoFitTextureView)view.FindViewById(Resource.Id.texture); view.FindViewById(Resource.Id.snap_button).SetOnClickListener(this); view.FindViewById(Resource.Id.gallery_button).SetOnClickListener(this); mFlashButton = view.FindViewById <ImageButton>(Resource.Id.flash_button); mFlashButton.SetOnClickListener(this); view.FindViewById(Resource.Id.back_button).SetOnClickListener(this); ImageDisplay = view.FindViewById <ImageView>(Resource.Id.img_display); roi = view.FindViewById <ImageView>(Resource.Id.roiView); mCaptureCallback = new CameraCaptureListener(this); mOnImageAvailableListener = new ImageAvailableListener(this); flashMenuListner = new FlashMenuListener(this); mFlashMode = 0; }
public CamRecorder(Context context) : base(context) { _context = context; var inflater = LayoutInflater.FromContext(context); if (inflater is null) { return; } var view = inflater.Inflate(Resource.Layout.CameraLayout, this); mTextureView = view.FindViewById <AutoFitTextureView>(Resource.Id.CameraTexture); //1- opens camera when surface is available, also resized the view mTextureView.SurfaceTextureListener = new Camera2BasicSurfaceTextureListener(this); //2- listens for when camera is opened -> calls CreateCameraPreviewSession mStateCallback = new CameraStateListener(this); // mSurfaceTextureListener = mTextureView.SurfaceTextureListener;//new Camera2BasicSurfaceTextureListener(this); // fill ORIENTATIONS list ORIENTATIONS.Append((int)SurfaceOrientation.Rotation0, 90); ORIENTATIONS.Append((int)SurfaceOrientation.Rotation90, 0); ORIENTATIONS.Append((int)SurfaceOrientation.Rotation180, 270); ORIENTATIONS.Append((int)SurfaceOrientation.Rotation270, 180); mCaptureCallback = new CameraCaptureListener(this); mOnImageAvailableListener = new ImageAvailableListener(); mOnImageAvailableListener.Photo += (object sender, byte[] e) => { Device.BeginInvokeOnMainThread(() => { Photo?.Invoke(this, e); }); }; }
static CameraPageRenderer() { Orientations.Append((int)SurfaceOrientation.Rotation0, 90); Orientations.Append((int)SurfaceOrientation.Rotation90, 0); Orientations.Append((int)SurfaceOrientation.Rotation180, 270); Orientations.Append((int)SurfaceOrientation.Rotation270, 180); }
public void Init(CameraSurfaceView view) { mTextureView = view; // fill ORIENTATIONS list ORIENTATIONS.Append((int)SurfaceOrientation.Rotation0, 90); ORIENTATIONS.Append((int)SurfaceOrientation.Rotation90, 0); ORIENTATIONS.Append((int)SurfaceOrientation.Rotation180, 270); ORIENTATIONS.Append((int)SurfaceOrientation.Rotation270, 180); switch (MainActivity.SavedDataStore.SelectedResolution) { case Classes.SaveData.CaptureResolution.Res480p: MAX_PREVIEW_WIDTH = 720; MAX_PREVIEW_HEIGHT = 480; break; case Classes.SaveData.CaptureResolution.Res720p: MAX_PREVIEW_WIDTH = 1280; MAX_PREVIEW_HEIGHT = 720; break; case Classes.SaveData.CaptureResolution.Res1080p: MAX_PREVIEW_WIDTH = 1920; MAX_PREVIEW_HEIGHT = 1080; break; case Classes.SaveData.CaptureResolution.Res2160p: MAX_PREVIEW_WIDTH = 3840; MAX_PREVIEW_HEIGHT = 2160; break; } StartBackgroundThread(); }
/// <summary> /// Initializes a new instance of the <see cref="Android_Shared.Controls.CameraDroid"/> class. /// </summary> /// <param name="context">Context.</param> public CameraDroid(Context context) : base(context) { _context = context; _mediaSoundLoaded = LoadShutterSound(); var inflater = LayoutInflater.FromContext(context); if (inflater != null) { var view = inflater.Inflate(Resource.Layout.CameraLayout, this); _cameraTexture = view.FindViewById <AutoFitTextureView>(Resource.Id.CameraTexture); _cameraTexture.SurfaceTextureListener = this; _stateListener = new CameraStateListener() { Camera = this }; ORIENTATIONS.Append((int)SurfaceOrientation.Rotation0, 90); ORIENTATIONS.Append((int)SurfaceOrientation.Rotation90, 0); ORIENTATIONS.Append((int)SurfaceOrientation.Rotation180, 270); ORIENTATIONS.Append((int)SurfaceOrientation.Rotation270, 180); } }
public CameraDroid(Context context) : base(context) { _context = context; var inflater = LayoutInflater.FromContext(context); if (inflater == null) { return; } //var view = inflater.Inflate(Resource.Layout.CameraLayout, this); //_cameraTexture = view.FindViewById<TextureView>(Resource.Id.cameraTexture); _cameraTexture = new TextureView(context); _cameraTexture.SurfaceTextureListener = this; _cameraStateListener = new CameraStateListener { Camera = this }; _cameraCaptureListener = new CameraCaptureListener(this); _orientations.Append((int)SurfaceOrientation.Rotation0, 90); _orientations.Append((int)SurfaceOrientation.Rotation90, 0); _orientations.Append((int)SurfaceOrientation.Rotation180, 270); _orientations.Append((int)SurfaceOrientation.Rotation270, 180); AddView(_cameraTexture); }
public CameraPreviewRenderer(Context context) : base(context) { ORIENTATIONS.Append((int)SurfaceOrientation.Rotation0, 90); ORIENTATIONS.Append((int)SurfaceOrientation.Rotation90, 0); ORIENTATIONS.Append((int)SurfaceOrientation.Rotation180, 270); ORIENTATIONS.Append((int)SurfaceOrientation.Rotation270, 180); }
public CameraDroid(Context context) : base(context) { _context = context; var inflater = LayoutInflater.FromContext(context); if (inflater == null) { return; } var view = inflater.Inflate(Resource.Layout.CameraLayout, this); _cameraTexture = view.FindViewById <TextureView>(Resource.Id.cameraTexture); _cameraTexture.Click += (sender, args) => { TakePhoto(); }; _cameraTexture.SurfaceTextureListener = this; _mStateListener = new CameraStateListener { Camera = this }; Orientations.Append((int)SurfaceOrientation.Rotation0, 0); Orientations.Append((int)SurfaceOrientation.Rotation90, 90); Orientations.Append((int)SurfaceOrientation.Rotation180, 180); Orientations.Append((int)SurfaceOrientation.Rotation270, 270); }
public override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); AssetManager assets = Activity.Assets; var filesToCopy = new string[] { "runtime_data/openalpr.conf" , "runtime_data/region/eu.xml" }; var AndroidDataDir = Android.App.Application.Context.DataDir.AbsolutePath; var runtimeFolder = new Java.IO.File(AndroidDataDir, "/files/runtime_data"); var renamedRuntimeFolder = new Java.IO.File(AndroidDataDir, "runtime_data"); runtimeFolder.RenameTo(renamedRuntimeFolder); var list = renamedRuntimeFolder.List(); OpenALPRConfigFile = AndroidDataDir + "/runtime_data/openalpr.conf"; var f = new Java.IO.File(AndroidDataDir); var flist = f.List(); var lib = new Java.IO.File(f, "lib"); var liblist = lib.List(); mStateCallback = new CameraStateListener(this); mSurfaceTextureListener = new Camera2BasicSurfaceTextureListener(this); OpenALPRInstance = new OpenALPR(this.Activity, AndroidDataDir, OpenALPRConfigFile, "eu", "ua"); // fill ORIENTATIONS list ORIENTATIONS.Append((int)SurfaceOrientation.Rotation0, 90); ORIENTATIONS.Append((int)SurfaceOrientation.Rotation90, 0); ORIENTATIONS.Append((int)SurfaceOrientation.Rotation180, 270); ORIENTATIONS.Append((int)SurfaceOrientation.Rotation270, 180); }
static Utils() { // fill ORIENTATIONS list Orientations.Append((int)SurfaceOrientation.Rotation0, 90); Orientations.Append((int)SurfaceOrientation.Rotation90, 0); Orientations.Append((int)SurfaceOrientation.Rotation180, 270); Orientations.Append((int)SurfaceOrientation.Rotation270, 180); }
public Camera2VideoFragment() { ORIENTATIONS.Append((int)SurfaceOrientation.Rotation0, 90); ORIENTATIONS.Append((int)SurfaceOrientation.Rotation90, 0); ORIENTATIONS.Append((int)SurfaceOrientation.Rotation180, 270); ORIENTATIONS.Append((int)SurfaceOrientation.Rotation270, 180); surface_texture_listener = new MySurfaceTextureListener(this); state_listener = new MyCameraStateListener(this); }
public DroidCameraPreview2(Context context) : base(context) { this._context = context; ORIENTATIONS.Append((int)SurfaceOrientation.Rotation0, 90); ORIENTATIONS.Append((int)SurfaceOrientation.Rotation90, 0); ORIENTATIONS.Append((int)SurfaceOrientation.Rotation180, 270); ORIENTATIONS.Append((int)SurfaceOrientation.Rotation270, 180); Initialize(); }
public override void OnCreate(Bundle savedInstanceState) { Instance = this; base.OnCreate(savedInstanceState); // fill ORIENTATIONS list ORIENTATIONS.Append((int)SurfaceOrientation.Rotation0, 90); ORIENTATIONS.Append((int)SurfaceOrientation.Rotation90, 0); ORIENTATIONS.Append((int)SurfaceOrientation.Rotation180, 270); ORIENTATIONS.Append((int)SurfaceOrientation.Rotation270, 180); }
public override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); _stateCallback = new CameraStateListener(this); _mSurfaceTextureListener = new Camera2BasicSurfaceTextureListener(this); // fill ORIENTATIONS list ORIENTATIONS.Append((int)SurfaceOrientation.Rotation0, 90); ORIENTATIONS.Append((int)SurfaceOrientation.Rotation90, 0); ORIENTATIONS.Append((int)SurfaceOrientation.Rotation180, 270); ORIENTATIONS.Append((int)SurfaceOrientation.Rotation270, 180); }
public override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); mStateListener = new CameraStateListener() { Fragment = this }; mSurfaceTextureListener = new Camera2BasicSurfaceTextureListener(this); ORIENTATIONS.Append((int)SurfaceOrientation.Rotation0, 90); ORIENTATIONS.Append((int)SurfaceOrientation.Rotation90, 0); ORIENTATIONS.Append((int)SurfaceOrientation.Rotation180, 270); ORIENTATIONS.Append((int)SurfaceOrientation.Rotation270, 180); }
public override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); mStateCallback = new StateListener(this); mSurfaceTextureListener = new SurfaceTextureListener(this); // fill ORIENTATIONS list ORIENTATIONS.Append((int)SurfaceOrientation.Rotation0, 90); ORIENTATIONS.Append((int)SurfaceOrientation.Rotation90, 0); ORIENTATIONS.Append((int)SurfaceOrientation.Rotation180, 270); ORIENTATIONS.Append((int)SurfaceOrientation.Rotation270, 180); tensorflow = new ImageClassifier(); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); // Intent intent = new Intent(MediaStore.ActionImageCapture); if (ContextCompat.CheckSelfPermission(this, Manifest.Permission.Camera) != (int)Permission.Granted) { ActivityCompat.RequestPermissions(this, new string[] { Manifest.Permission.Camera }, 200); } else { mStateCallback = new CameraStateListener(this); mSurfaceTextureListener = new ClipperASurfaceTextureListener(this); // fill ORIENTATIONS list ORIENTATIONS.Append((int)SurfaceOrientation.Rotation0, 90); ORIENTATIONS.Append((int)SurfaceOrientation.Rotation90, 0); ORIENTATIONS.Append((int)SurfaceOrientation.Rotation180, 270); ORIENTATIONS.Append((int)SurfaceOrientation.Rotation270, 180); SetContentView(Resource.Layout.TakingPicture); mTextureView = (AutoFitTextureView)FindViewById(Resource.Id.texture); mImageView = FindViewById <ImageView>(Resource.Id.image); takePictureBtn = FindViewById <ImageButton>(Resource.Id.takePictureBtn); flashBtn = FindViewById <ImageButton>(Resource.Id.flashBtn); rotateBtn = FindViewById <ImageButton>(Resource.Id.rotateBtn); acceptBtn = FindViewById <ImageButton>(Resource.Id.doneBtn); discardBtn = FindViewById <ImageButton>(Resource.Id.clearBtn); takePictureBtn.Click += (sender, e) => TakePicture(); rotateBtn.Click += (sender, e) => ChangeCamera(); flashBtn.Click += (sender, e) => ChandeFlashMode(); FindViewById <ImageButton>(Resource.Id.closeBtn).Click += (sender, e) => Exit(); acceptBtn.Click += (sender, e) => ExitWithResult(); discardBtn.Click += (sender, e) => DiscardChanges(); mCaptureCallback = new CameraCaptureListener(this); mOnImageAvailableListener = new ImageAvailableListener(this, mre); mOrientationListener = new SensorOrientationListener(this); } }
public RecordResponseManager(VideoRecorderActivitiy act, UserResponse _userResponse) { activity = act; ORIENTATIONS.Append((int)SurfaceOrientation.Rotation0, 90); ORIENTATIONS.Append((int)SurfaceOrientation.Rotation90, 0); ORIENTATIONS.Append((int)SurfaceOrientation.Rotation180, 270); ORIENTATIONS.Append((int)SurfaceOrientation.Rotation270, 180); userResponse = _userResponse; if (_userResponse == UserResponse.Video) { surfaceTextureListener = new MySurfaceTextureListener(this); stateListener = new MyCameraStateCallback(act, this); } else if (_userResponse == UserResponse.Audio) { SetUpRecoder(); } }
public XCameraCaptureView(Context context, CameraOptions option) : base(context) { cameraOption = option; // TODO Move to Initialize mStateCallback = new CameraStateListener(this); mSurfaceTextureListener = new Camera2BasicSurfaceTextureListener(this); // fill ORIENTATIONS list ORIENTATIONS.Append((int)SurfaceOrientation.Rotation0, 90); ORIENTATIONS.Append((int)SurfaceOrientation.Rotation90, 0); ORIENTATIONS.Append((int)SurfaceOrientation.Rotation180, 270); ORIENTATIONS.Append((int)SurfaceOrientation.Rotation270, 180); mTextureView = new AutoFitTextureView(context); AddView(mTextureView); var path = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal); File = new File(path, "pic.jpg"); CaptureCallback = new CameraCaptureListener(this); mOnImageAvailableListener = new ImageAvailableListener(this); }
public override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); mStateCallback = new CameraStateListener() { owner = this }; mSurfaceTextureListener = new Camera2BasicSurfaceTextureListener(this); // fill ORIENTATIONS list ORIENTATIONS.Append((int)SurfaceOrientation.Rotation0, 90); ORIENTATIONS.Append((int)SurfaceOrientation.Rotation90, 0); ORIENTATIONS.Append((int)SurfaceOrientation.Rotation180, 270); ORIENTATIONS.Append((int)SurfaceOrientation.Rotation270, 180); var file = new File(Activity.GetExternalFilesDir(null), "pic.jpg"); this.mOnImageAvailableListener = new ImageAvailableListener(scanModule) { Owner = this, File = file }; //this.mCaptureCallback = new CameraCaptureListener() { Owner = this, File = file}; }
public Camera2Page() { Activity = this.Context as MainActivity; Activity.CamPage = this; if (Build.VERSION.SdkInt >= BuildVersionCodes.Lollipop) { view = Activity.LayoutInflater.Inflate(Resource.Layout.CameraLayout, this, false); } else { view = Activity.LayoutInflater.Inflate(Resource.Layout.CameraLayoutOld, this, false); } previousPhoto = view.FindViewById <ImageViewAsync>(Resource.Id.previousPhoto); OverlaySeekbar = view.FindViewById <SeekBar>(Resource.Id.overlaySeekbar); OverlaySeekbar.SetOnSeekBarChangeListener(this); if (App.SelectedCondition.Photos != null && App.SelectedCondition.Photos.Count > 0) { ShowHidePreviousPhoto(App.SelectedCondition.Photos[App.SelectedCondition.Photos.Count - 1]); } OverlaySeekbar.Visibility = (App.SelectedCondition.Photos.Count > 0) ? ViewStates.Visible : ViewStates.Gone; takePhotoButton = view.FindViewById <global::Android.Widget.Button>(Resource.Id.takePhotoButton); takePhotoButton.Click += TakePictureTapped; takePhotoButton.Enabled = false; switchCameraButton = view.FindViewById <global::Android.Widget.Button>(Resource.Id.switchCameraButton); switchCameraButton.Click += SwitchCameraButton_Click; switchCameraButton.Enabled = false; switchCameraButton.Visibility = ViewStates.Gone; spinner = view.FindViewById <Android.Widget.ProgressBar>(Resource.Id.progressBar1); spinner.Indeterminate = true; spinner.Visibility = ViewStates.Gone; if (Android.OS.Build.VERSION.SdkInt >= Android.OS.BuildVersionCodes.Lollipop) { mStateListener = new CameraStateListener() { Page = this }; mSurfaceTextureListener = new CameraSurfaceTextureListener(this); ORIENTATIONS.Append((int)SurfaceOrientation.Rotation0, 90); ORIENTATIONS.Append((int)SurfaceOrientation.Rotation90, 0); ORIENTATIONS.Append((int)SurfaceOrientation.Rotation180, 270); ORIENTATIONS.Append((int)SurfaceOrientation.Rotation270, 180); textureView = view.FindViewById <AutoFitTextureView>(Resource.Id.textureView); textureView.SurfaceTextureListener = mSurfaceTextureListener; string[] camPermissions = { Android.Manifest.Permission.Camera }; // Make sure we can use the camera if ((int)Android.OS.Build.VERSION.SdkInt >= 23 && Activity.CheckSelfPermission(camPermissions[0]) != (Permission.Granted)) { Toast.MakeText(Activity, AppResources.Camera_permissionNeeded, ToastLength.Long).Show(); Activity.RequestPermissions(camPermissions, CamPermReqId); } else { OpenCamera(); } } else { cameraType = CameraFacing.Back; textureView1 = view.FindViewById <TextureView>(Resource.Id.textureView); textureView1.SurfaceTextureListener = this; } AddView(view); }
protected override Java.Lang.Object DoInBackground(params Java.Lang.Object[] native_parms) { // Go over all the pages and write only the requested ones. // Create an adapter with the stats and an inflater // to load resources for the printer density. var adapter = new MotoGpStatAdapter(items, (LayoutInflater)self.mPrintContext.GetSystemService( Context.LayoutInflaterService)); int currentPage = -1; int pageContentHeight = 0; int viewType = -1; View view = null; Android.Graphics.Pdf.PdfDocument.Page page = null; var dummyParent = new LinearLayout(self.mPrintContext); dummyParent.Orientation = Android.Widget.Orientation.Vertical; // The content is laid out and rendered in screen pixels with // the width and height of the paper size times the print // density but the PDF canvas size is in points which are 1/72", // so we will scale down the content. float scale = System.Math.Min( (float)mPdfDocument.PageContentRect.Width() / self.mRenderPageWidth, (float)mPdfDocument.PageContentRect.Height() / self.mRenderPageHeight); int itemCount = adapter.Count; for (int i = 0; i < itemCount; i++) { // Be nice and respond to cancellation. if (IsCancelled) { return(null); } // Get the next view. int nextViewType = adapter.GetItemViewType(i); if (viewType == nextViewType) { view = adapter.GetView(i, view, dummyParent); } else { view = adapter.GetView(i, null, dummyParent); } viewType = nextViewType; // Measure the next view self.MeasureView(view); // Add the height but if the view crosses the page // boundary we will put it to the next one. pageContentHeight += view.MeasuredHeight; if (currentPage < 0 || pageContentHeight > self.mRenderPageHeight) { pageContentHeight = view.MeasuredHeight; currentPage++; // Done with the current page - finish it. if (page != null) { mPdfDocument.FinishPage(page); } // If the page is requested, render it. if (self.ContainsPage(pages, currentPage)) { page = mPdfDocument.StartPage(currentPage); page.Canvas.Scale(scale, scale); // Keep track which pages are written. mWrittenPages.Append(mWrittenPages.Size(), currentPage); } else { page = null; } } // If the current view is on a requested page, render it. if (page != null) { // Layout an render the content. view.Layout(0, 0, view.MeasuredWidth, view.MeasuredHeight); view.Draw(page.Canvas); // Move the canvas for the next view. page.Canvas.Translate(0, view.Height); } } // Done with the last page. if (page != null) { mPdfDocument.FinishPage(page); } // Write the data and return success or failure. try { var fos = new Java.IO.FileOutputStream(destination.FileDescriptor); mPdfDocument.WriteTo(new OutputStreamInvoker(fos)); // Compute which page ranges were written based on // the bookkeeping we maintained. var pageRanges = self.ComputeWrittenPageRanges(mWrittenPages); callback.OnWriteFinished(pageRanges); } catch (IOException) { callback.OnWriteFailed((string)null); } finally { mPdfDocument.Close(); } return(null); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.cam_activity); if (ActionBar != null) { ActionBar.Hide(); } autoFitTextureView = FindViewById <AutoFitTextureView>(Resource.Id.CameraTexture); bttBack = FindViewById <ImageButton>(Resource.Id.bttBack); bttFlash = FindViewById <ImageButton>(Resource.Id.bttFlash); bttSwitch = FindViewById <ImageButton>(Resource.Id.bttSwitchCamera); bttCapture = FindViewById <ImageButton>(Resource.Id.bttCapture); progressBar = FindViewById <Android.Widget.ProgressBar>(Resource.Id.progressBar_cyclic); bttBack.Click += (object sender, EventArgs e) => { Finish(); }; bttFlash.Click += (object sender, EventArgs e) => { try { if (FlashSupported) { FlashOn = !FlashOn; if (FlashOn) { bttFlash.SetImageResource(Resource.Drawable.flash_on); captureRequestBuilder.Set(CaptureRequest.FlashMode, (int)FlashMode.Torch); } else { bttFlash.SetImageResource(Resource.Drawable.flash_off); captureRequestBuilder.Set(CaptureRequest.FlashMode, (int)FlashMode.Off); } UpdatePreview(); } else { ShowToastMessage("Your camera not support flash!"); } } catch (System.Exception error) { ShowToastMessage("Failed to switch flash on/off"); DebugMessage("ErrorMessage: \n" + error.Message + "\n" + "Stacktrace: \n " + error.StackTrace); } }; bttSwitch.Click += (object sender, EventArgs e) => { if (IsBusy) { return; } else { IsBusy = true; } SwitchCamera(); }; bttCapture.Click += (object sender, EventArgs e) => { if (IsBusy) { return; } else { IsBusy = true; } TakePhoto(); }; autoFitTextureView.SurfaceTextureListener = this; cameraStateListener = new CameraStateListener() { Camera = this }; ORIENTATIONS.Append((int)SurfaceOrientation.Rotation0, 90); ORIENTATIONS.Append((int)SurfaceOrientation.Rotation90, 0); ORIENTATIONS.Append((int)SurfaceOrientation.Rotation180, 270); ORIENTATIONS.Append((int)SurfaceOrientation.Rotation270, 180); OpenCamera(false); }