您好无法解决此问题.
我已经在ImageAvailable回调中调用了imageReader.close,但仍然有错误:
java.lang.IllegalStateException:已经获取了maxImages(1),在获取更多之前调用#close.
我的代码在这里:
private ImageReader.OnImageAvailableListener imageAvailableListener = new ImageReader.OnImageAvailableListener()
{
@Override
public void onImageAvailable(ImageReader reader) {
Image img = mReader.acquireLatestImage();
mReader.close();
}
};
Run Code Online (Sandbox Code Playgroud)
PS.我也使用参数阅读器,但似乎没有解决问题
我正在研究新的 CameraX API,以了解从我们当前的 Camera2 系统切换的可行性。
在我们的 Camera2 系统中,我们使用 OpenGL 表面从 PreviewCaptureSession 捕获帧,并且我们在大多数设备上达到一致的 30fps 图像处理速度,有些能够在启用 AutoExposure 设置的情况下达到 60fps。
CameraX 没有提供接近该速度的任何东西,我不确定它是否是我在设置中遗漏的东西。
我已经为 CameraX 和 ImageAnalysis 设置了测试示例,但是我正在锁定通过图像数量的帧速率。
例如,我可以将分辨率设置为低至 320x240 到 1920x960,并且两者都会以(看似上限)16fps 的速度出现。
当我添加一个预览用例与它一起运行并设置 enableTorch(true) 时,ImageAnalysis 用例将突然开始变得更像 20fps,它偶尔会达到 30ish。
显然预览用例改变了相机的一些 AutoExposure 状态?
这是我当前设置的狙击手......
private fun startCameraAnalysis() {
val metrics = DisplayMetrics().also { viewFinder.display.getRealMetrics(it) }
var resolution = Size(metrics.widthPixels, metrics.heightPixels)
resolution = Size(640, 480) //set to fixed size for testing
val aspectRatio = Rational(resolution.width, resolution.height)
val rotation = viewFinder.display.rotation
// Setup image analysis pipeline
val …Run Code Online (Sandbox Code Playgroud) 我正在使用Android firebase-ml-vision使用SurfaceView和相框的连续ByteBuffer扫描条形码。我以ML工具包快速入门项目作为起点,并且效果很好。
我项目的目的是识别与条形码关联的产品,并将其添加到扫描项目列表中。
相机对焦后,条形码处理器将多次检测到相同的条形码,因此您将在一秒钟内扫描20条而不是1条条形码。
这是来自CamereSource.FrameProcessingRunnable.run的 javadoc
Run Code Online (Sandbox Code Playgroud)* As long as the processing thread is active, this executes detection on frames continuously. * The next pending frame is either immediately available or hasn't been received yet. Once it * is available, we transfer the frame info to local variables and run detection on that frame. * It immediately loops back for the next frame without pausing.
我曾尝试在FrameProcessingRunnable中添加“已暂停”检查,但由于至少一个帧已被送入检测,因此我仍然至少两次被识别相同的条形码:
private class FrameProcessingRunnable implements Runnable {
private volatile …Run Code Online (Sandbox Code Playgroud)