我正在使用CameraX用例在屏幕上显示来自摄像头的图像,同时在其上执行对象检测。您可以在下面的main activity的onCreate()函数中找到与CameraX相关的代码。
尽管如此,我在一些(比如说1/5)应用程序初始化时遇到了错误,在工作和非工作情况之间没有任何代码或二进制修改:
java.lang.NullPointerException: previewView.display must not be null
如果我试图不访问previewView.display以避免崩溃,我只会得到空白裁剪的图像,直到我重新启动应用程序。
它似乎与视图初始化和useCaseGroup有关
我的CameraXFragment中有下面这行代码,Android Studio向我显示了一个错误: videoCapture = VideoCaptureConfig.Builder() // <--- Builder is in red
.setTargetRotation(binding.previewView.display.rotation)
.setCameraSelector(cameraSelector)
.setTargetAspectRatio(screenAspectRatio)
我想要捕获图像并使用CameraX库保存到文件中。我捕捉到了图像并保存下来。图像文件的大小为0B。我不知道我哪里出了问题。日志显示此错误:
androidx.camera.core.ImageCaptureException: Not bound to a valid Camera [ImageCapture:androidx.camera.core.ImageCapture-52180692-0099-40c3-8d17-508e08019b84]
以下是我的捕获代码:
fun bindPreview(
lifecycleOwner: LifecycleOwner,
设备:华为P40精简版E依赖: //CameraX dependencies
def camerax_version = "1.1.0-alpha03"
//ML kit for computer vision, needed for face detection
//bundled with app
implementation 'com.google.mlkit:face-detection:16.0.6'
//CameraX core library using camera implementation
implementation "an
我遵循了这些教程:https://developer.android.com/training/camerax/preview,https://proandroiddev.com/update-android-camerax-4a44c3e4cdcc当我第一次运行应用程序时,预览工作正常,但在我旋转屏幕之后,所有的东西都坏了。我重新安装了应用程序,但预览不再起作用 public class ScanActivity extends AppCompatActivity {
private ListenableFuture<ProcessCameraProvider> camer
我开始在我的安卓应用程序中使用CameraX (1.0.8alpha)库,在开发真正的Samnsung A50设备+仿真器时,所有这些都工作得很好。但是当它发布来玩商店的时候--我在Pixel 2XL和Nexus 5X设备上看到了很多崩溃(我在这个设备的模拟器上试用了我的应用程序,但是一切都很好)。
我只是打电话给bindToLifecle:
Fatal Exception: java.lang.IllegalArgumentException: Can not get supported output size under supported maximum for the format:
我知道还有其他的问题被回答了很多次,我试图找到答案,但我大部分都不能理解。我想让相机拍一张照片,但不是做一个物理图像文件,我想直接把它做成位图并显示在来自不同活动的ImageView中,但是我总是得到Attempt to invoke virtual method 'android.content.pm.ApplicationInfo android.content.Context.getApplicationInfo()' on a null object reference,这是因为viewFinder.bitmap是空的,所以决定做一个单独的函数getBitmap():