Connect a slider to control zoom on qml Camera



  • Hi,
    I am using Camera to take movies.
    I want to use a slider to zooming video like zoom of google map.
    I try to set digitalZoom for camera but I have this error: The camera doesn't support zooming.
    I wrote code that is not working correctly. I have not found error, but video size will be very large, then I do not see video.

    VideoOutput {
         id: viewfinder
         source: camera
         anchors.fill: parent
         focus : true                                
         transform: [
             Scale {
                 id: zoomScale
             },
             Translate {
                 id: zoomTranslate
             }
          ]
    
          //Keys.onLeftPressed: viewfinder.seek(viewfinder.position - 5000)
          //Keys.onRightPressed: viewfinder.seek(viewfinder.position + 5000)
    
          MouseArea {
               anchors.fill: parent
               acceptedButtons: Qt.AllButtons
               onClicked: {
                  var zoomIn = mouse.button === Qt.LeftButton;
                  zoomScale.origin.x = mouse.x;
                  zoomScale.origin.y = mouse.y;
               }
          }
    
          Slider {
              id:zoomVideo
              orientation: Qt.Vertical
              minimumValue: 0
              maximumValue: 5000
              stepSize: 100
    
              onValueChanged: {
                  zoomScale.xScale = zoomVideo.value
                  zoomScale.yScale = zoomVideo.value
              }
          }
      }
    

  • Moderators

    @neda
    maybe this helps?



  • Thank you but The camera doesn't support zooming.
    "camera.maximumDigitalZoom" and maximumOpticalZoom return 1


  • Moderators

    @neda said in Connect a slider to control zoom on qml Camera:

    Thank you but The camera doesn't support zooming.

    And you are then trying to convince it to still do so?
    I think you will loose this one ;)



  • I know my camera does not support "DigitalZoom" and "OpticalZoom". I want to find a way to zoom in on video taken from camera.

    I've found another Question on SO but the proposed solution works for click whereas I would like to develop a solution for slider.


  • Moderators

    @neda
    k got it now.
    Your slider values are way too high for this. A value of 1.0 means 100%, 1.5 => 150% and so on.
    But you are already increasing by 100 with the first slider step.



  • @raven-worx

    I change my code:
    I want zooming in center of video like + zoom button in google map.

    Slider {
                                              id:zoomVideo
                                              orientation: Qt.Vertical
                                              minimumValue: 1
                                              maximumValue: 2
                                              stepSize: 0.01
                                              anchors{
                                               left:parent.left
                                               leftMargin:5
                                               verticalCenter:parent.verticalCenter
                                              }
                                              onValueChanged: {
                                                  zoomScale.xScale = zoomVideo.value
                                                  zoomScale.yScale = zoomVideo.value
                                              }
                                          }
    

Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.