Qt/QML Android:检测到相机,但 ImageCapture 发送“相机未就绪”。错误

问题描述 投票:0回答:1

我有以下代码,Qt/QML android 应用程序中的相机检测正确,但 ImageCapture 发送“相机未准备好”。错误。

import QtQuick
import QtQuick.Controls
import QtMultimedia



/*! ***********************************************************************************************
 * The CameraController's task involves periodically refreshing CameraDevice frames through a
 * CaptureSession within a specified time interval.
 *
 * ************************************************************************************************/
Item {
    id: cameraController

    /* Property Declarations
     * ****************************************************************************************/
    //! Media devices
    property MediaDevices mediaDevices: null

    //! Camera Device
    property ICamera cameraDev: null

    /* Children
     * ****************************************************************************************/
    // Timer to capture frames as fast as possible
    Timer {
        id: timer
        running: cameraDev.enable
        interval: 1000.0 / 24.0
        repeat: true
        onTriggered: {
            if (imageCapture.readyForCapture)
                imageCapture.capture();
        }
    }

    // Frame handler
    CaptureSession {
        id: captureSession

        // camera
        camera: Camera {
            id: mycameraDevice
            active: true
            
            cameraDevice: cameraDev.index >= 0 ? mediaDevices.videoInputs[cameraDev.index] : null

            onErrorOccurred: (error, errorString) => {
                                 console.log("Camera name", cameraDev.name,
                                             "Camera error:", errorString)
                             }
        }

        // image capture
        imageCapture: ImageCapture {
            id: imageCapture

            onImageCaptured: (requestId, previewImage) => {
                                 cameraDev.currentFrame = previewImage
                             }

            onErrorOccurred: (id, err, errstr) => {
                                 console.log("errstr :  ", id, err, errstr) // Camera is not ready.
                             }
        }
    }
}
  • Qt 6.4.3 / clang
  • ndk版本:23.1.7779620
  • Android_abi:armeabi-v7a
  • Android构建平台sdk:31.0.0
  • Android平台:android-23

我需要在 QML 中从相机捕获帧。 谢谢

android qt qml android-camera qtmultimedia
1个回答
0
投票

我目前使用的是 Qt 版本 6.5.2,它的功能符合预期。此版本的 Qt 利用 FFmpeg 进行多媒体操作。

© www.soinside.com 2019 - 2024. All rights reserved.