Search code examples
qtcameraqml

How can I fix bug camera in Qt5.13.1?


I wanna adjust exposure related settings in my camera. For example I try to use function camera.searchAndLock() but it doesn't work.

I tried to run camera example of Qt, but for the following code I have always Unlocked status.

switch (m_camera->lockStatus()) {
    case QCamera::Searching:
    case QCamera::Locked:
        m_camera->unlock();
        break;
    case QCamera::Unlocked:
        m_camera->searchAndLock();
    }

I write the following QML codes, but the following code always return unlocking focus.

if (camera.lockStatus == Camera.Unlocked) {
    camera.searchAndLock();
    console.log("searching focus...")                                
   }                                 
   else {                           
        camera.unlock();                        
        console.log("unlocking focus...")                            
     }

I want to change exposure related settings in my camera by the following codes, but all of them do not work:

camera.searchAndLock()    
camera.exposure.exposureCompensation = value
camera.exposure.spotMeteringPoint.x=value
camera.exposure.spotMeteringPoint.y=value
camera.exposure.manualShutterSpeed = value
camera.exposure.iso  = value
camera.exposure.manualAperture=value

I try to use searchAndLock() function for start focusing, exposure calculation, but after running this function status of my camera is still Unlocked rather Searching.

What can I do with this bug? Which version of Qt I can install that doesn't has this bug?

I was success to fix bug of SerialPort by read this link: How to make QSerialPort from Qt5.13.1 work?

Is there a way for fix this bug by me?

Qt Version: Qt 5.13.1 (MSVC 2017, 32 bit), Platform: Windows 10


Solution

  • I guess you should check that your camera actually has any supported focus modes, and what these modes are:

    console.debug("supported focus modes: " + focus.supportedFocusModes
                                  + ", FocusManual: " + CameraFocus.FocusManual
                                  + ", FocusHyperfocal: " + CameraFocus.FocusHyperfocal
                                  + ", FocusInfinity: " + CameraFocus.FocusInfinity
                                  + ", FocusAuto: " + CameraFocus.FocusAuto
                                  + ", FocusContinuous: " + CameraFocus.FocusContinuous
                                  + ", FocusMacro: " + CameraFocus.FocusMacro
                                  )
    

    By using the information provided by the results of this, you may set a focus mode that suits your camera hardware. There is a lot of different hardware out there, so please take that into account when writing your camera part of the app.