android-camerax

CameraX Multiple Back Cameras

人走茶凉 提交于 2021-02-11 12:38:05
问题 I'm trying to implement a custom camera app using CameraX. Seeing as a lot of new devices have multiple back cameras now, I also want to include that. So basically, the user can select which camera to use. I've tried the following using the addCameraFilter option: val cameraSelector = CameraSelector.Builder() .requireLensFacing(when (camera.cameraSettings?.lensFacing?.let { LensFacing.valueOf(it) }) { LensFacing.Back -> CameraSelector.LENS_FACING_BACK else -> CameraSelector.LENS_FACING_FRONT

Mirroring in cameraX

南笙酒味 提交于 2021-02-10 17:50:31
问题 How to show mirror image on both front and back facing camera mode. I know that this bitmap can be mirrored like below BitmapDrawable flip(BitmapDrawable d) { Matrix m = new Matrix(); m.preScale(-1, 1); Bitmap src = d.getBitmap(); Bitmap dst = Bitmap.createBitmap(src, 0, 0, src.getWidth(), src.getHeight(), m, false); dst.setDensity(DisplayMetrics.DENSITY_DEFAULT); return new BitmapDrawable(dst); } But how to use it to implement mirroring for camera X 来源: https://stackoverflow.com/questions

Mirroring in cameraX

妖精的绣舞 提交于 2021-02-10 17:48:18
问题 How to show mirror image on both front and back facing camera mode. I know that this bitmap can be mirrored like below BitmapDrawable flip(BitmapDrawable d) { Matrix m = new Matrix(); m.preScale(-1, 1); Bitmap src = d.getBitmap(); Bitmap dst = Bitmap.createBitmap(src, 0, 0, src.getWidth(), src.getHeight(), m, false); dst.setDensity(DisplayMetrics.DENSITY_DEFAULT); return new BitmapDrawable(dst); } But how to use it to implement mirroring for camera X 来源: https://stackoverflow.com/questions

Navigating to another fragment from CameraX analyze() blocks current fragment's lifecycle and freezes the UI

送分小仙女□ 提交于 2021-01-29 05:33:56
问题 All my CameraX initializations reside in FragmentA , and my goal is to navigate to FragmentB depending on some condition that must be verified inside analyze() . When navigating directly from analyze() , through Logcat I can see that FragmentB is loaded correctly but the UI freezes on the camera preview, and unfreezes only when I navigate back to FragmentA . I discovered that under those circumstances FragmentA doesn't go through the rest of its lifecycle correctly, meaning that onDestroyView

Set CameraX image capture File path

≯℡__Kan透↙ 提交于 2021-01-28 19:56:12
问题 I set the File path to the following: File file = new File(Environment.getExternalStorageDirectory() + "/" + System.currentTimeMillis() + ".png"); ImageCapture.OutputFileOptions outputFileOptions = new ImageCapture.OutputFileOptions.Builder(file).build(); imageCapture.takePicture(outputFileOptions, Executors.newSingleThreadExecutor(), new ImageCapture.OnImageSavedCallback() { @Override public void onImageSaved(ImageCapture.OutputFileResults outputFileResults) { // insert your code here. Log.d

How to mirror the PreviewView in CameraX?

♀尐吖头ヾ 提交于 2021-01-24 14:39:05
问题 Disclaimer: I'm aware of the existence of this question, but it currently stands unresolved and I'm trying to provide extra information without polluting that one with useless answers that won't solve the problem anyway. I have a custom device with a front camera that is mirrored by default, so I want to display the preview normally and I need to horizontally flip the content of PreviewView, but I'm stuck. Other people in the past have suggested using PreviewView#setScaleX(-1) but it either

How to mirror the PreviewView in CameraX?

不问归期 提交于 2021-01-24 14:36:46
问题 Disclaimer: I'm aware of the existence of this question, but it currently stands unresolved and I'm trying to provide extra information without polluting that one with useless answers that won't solve the problem anyway. I have a custom device with a front camera that is mirrored by default, so I want to display the preview normally and I need to horizontally flip the content of PreviewView, but I'm stuck. Other people in the past have suggested using PreviewView#setScaleX(-1) but it either

Does mirroring the (front) camera affect MLKit with CameraX?

孤人 提交于 2021-01-07 02:55:10
问题 You might consider this question a sequel to this other one I've recently asked. I have a custom device with a front camera that is mirrored by default and I would like it to always behave like it was flipped horizontally. Note that the end goal of my app is to perform face, barcode and facemask detection (the last one with a custom .tflite model), and I'm trying to understand if it's possible with the current state of CameraX and the quirks of the device I'm using. For the preview, I can

How to crop image rectangle in camera preview on CameraX

孤人 提交于 2020-12-29 13:13:38
问题 I have a custom camera app which has a centered rectangle view, as you can see below: When I take a picture I want to ignore everything outside the rectangle. And this is my XML layout: <?xml version="1.0" encoding="utf-8"?> <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height=

How to listen to the cameraX lens facing changes

妖精的绣舞 提交于 2020-12-12 13:26:26
问题 Does camerax provide api for lens facing changes callback? After switching the lens facing camera I want to be notified when it has finished changing and the camera is ready to use. Currently I'm using this dependencies of camerax implementation "androidx.camera:camera-lifecycle:1.0.0-beta01" implementation "androidx.camera:camera-view:1.0.0-alpha08" implementation "androidx.camera:camera-extensions:1.0.0-alpha08" 回答1: Sounds like you need a signal for when the camera starts emitting frames.