2

我正在使用 CameraX 版本 1.0.0-alpha05。使用这个版本的原因是因为我正在关注一个pytorch对象检测android示例代码。

我知道 ssh <username>@<hostname>.local -Y "mplayer tv://device=/dev/video0"但当当的存在,我也不知道如何捕获要输入 ImageAnalysis 或 Preview Object 的视频源。

非常感谢任何帮助或线索!

  final TextureView textureView = getCameraPreviewTextureView();
        final PreviewConfig previewConfig = new PreviewConfig
                .Builder()
                .build();
        final Preview preview = new Preview(previewConfig);
        preview.setOnPreviewOutputUpdateListener(output -> {
            textureView.setSurfaceTexture(output.getSurfaceTexture());
            Matrix m = new Matrix();
            m.postRotate(90, 1000, 350);
            textureView.setTransform(m);
        });
        final var imageAnalysisConfig =
                new ImageAnalysisConfig.Builder()
                        .setTargetResolution(new Size(500, 500))
                        .setCallbackHandler(mBackgroundHandler)
                     .setImageReaderMode(ImageAnalysis.ImageReaderMode.ACQUIRE_LATEST_IMAGE)
                        .build();

        imageAnalysis = new ImageAnalysis(imageAnalysisConfig);
        imageAnalysis.setAnalyzer((image, rotationDegrees) -> {
            if (SystemClock.elapsedRealtime() - mLastAnalysisResultTime < 500) {
                return;
            }
            //This the portion where pytorch does it's AI predictions
            final R2 result = analyzeImage(image, rotationDegrees);
            if (result != null) {
                mLastAnalysisResultTime = SystemClock.elapsedRealtime();
                runOnUiThread(() -> applyToUiAnalyzeImageResult(result));
            }
        });


        CameraX.bindToLifecycle(this, preview, imageAnalysis);
4

0 回答 0