Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Connect a slider to control zoom on qml Camera
QtWS25 Last Chance

Connect a slider to control zoom on qml Camera

Scheduled Pinned Locked Moved QML and Qt Quick
7 Posts 2 Posters 2.2k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    neda
    wrote on last edited by neda
    #1

    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
              }
          }
      }
    
    raven-worxR 1 Reply Last reply
    0
    • N neda

      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
                }
            }
        }
      
      raven-worxR Offline
      raven-worxR Offline
      raven-worx
      Moderators
      wrote on last edited by
      #2

      @neda
      maybe this helps?

      --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
      If you have a question please use the forum so others can benefit from the solution in the future

      1 Reply Last reply
      0
      • N Offline
        N Offline
        neda
        wrote on last edited by
        #3

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

        raven-worxR 1 Reply Last reply
        0
        • N neda

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

          raven-worxR Offline
          raven-worxR Offline
          raven-worx
          Moderators
          wrote on last edited by
          #4

          @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 ;)

          --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
          If you have a question please use the forum so others can benefit from the solution in the future

          1 Reply Last reply
          0
          • N Offline
            N Offline
            neda
            wrote on last edited by
            #5

            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.

            raven-worxR 1 Reply Last reply
            0
            • N neda

              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.

              raven-worxR Offline
              raven-worxR Offline
              raven-worx
              Moderators
              wrote on last edited by
              #6

              @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.

              --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
              If you have a question please use the forum so others can benefit from the solution in the future

              N 1 Reply Last reply
              0
              • raven-worxR raven-worx

                @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.

                N Offline
                N Offline
                neda
                wrote on last edited by
                #7

                @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
                                                          }
                                                      }
                
                1 Reply Last reply
                0

                • Login

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • Users
                • Groups
                • Search
                • Get Qt Extensions
                • Unsolved