Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

QML Camera Status Issue



  • Hi,

    I'm using Qt 5.13.2 version.

    I want to check cameraStatus for my mac desktop app to notice that camera really work or not(depends on permission).
    I use QML Camera component for my app.

    Camera is not webcam, it's built-in camera on Laptop

    I checked cameraStatus work with Window OS.
    But, in macOS, cameraStatus value shows no diffrence while I turning on/off permission of camera for Qt Creator and MyApp.

    Also, I checked camera.availibilty , camera.cameraState

    Here is my Code for check camera-status

            onCameraStatusChanged: {
                console.log("camera-Status " + cameraStatus)
                // Camera Status
                // 0 : UnavailableStatus , 1: UnloadedStatus, 2: LoadingStatus, 3: UnloadingStatus, 4: LoadedStatus
                // 5: StandbyStatus, 6: StartingStatus, 7: StoppingStatus, 8: ActiveStatus
                if(App.windows){
                    if(cameraStatus < 4){
                        cameraConnection = false
                    } else if (cameraStatus >= 4){
                        cameraConnection = true
                    }
                    pageMain.selectImageCamera(cameraConnection)
                }
    
    
                if(!pageMain.watch && !snapShotDone && cameraStatus === 8){
                    console.log("camera-try to capture sanpshot")
                    capture()
                }
            }
    
            onCameraStateChanged: {
                console.log("dboo : camera-state changed to : " + cameraState)
    
                console.log("dboo : camera-availibility" + camera.availability)
                console.log("dboo : camera-   aviliable = " + Camera.Available)
                console.log("dboo : camera-   busy = " + Camera.Busy)
                console.log("dboo : camera-   Unavailable = " + Camera.Unavailable)
                console.log("dboo : camera-   ResourceMissing = " + Camera.ResourceMissing)
                if(App.macosx) {
                    switch(cameraState){
                    case 1:
                        pageMain.selectImageCamera(false)
                        break
                    case 2:
                        break
                    case 3:
                        pageMain.selectImageCamera(true)
                    }
                }
            }
    

    Here is Log, whether camera-permission on/off, log shows same.

    qml: camera-Status 4
    qml: camera-Status 6
    qml: dboo : camera-state changed to : 2
    qml: dboo : camera-availibility0
    qml: dboo : camera-   aviliable = 0
    qml: dboo : camera-   busy = 2
    qml: dboo : camera-   Unavailable = 1
    qml: dboo : camera-   ResourceMissing = 3
    qml: camera-Status 8
    qml: camera-Status 7
    qml: dboo : camera-state changed to : 1
    qml: dboo : camera-availibility0
    qml: dboo : camera-   aviliable = 0
    qml: dboo : camera-   busy = 2
    qml: dboo : camera-   Unavailable = 1
    qml: dboo : camera-   ResourceMissing = 3
    

    Is there another way to check camera availibilty on macOS?
    Or, Is there right way to check macOS availibilty with above code?


Log in to reply