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

PinchArea scale in and scale out touch coordinates



  • Hi

    I am working on pinch area and i would like to know whether i scaled in or scaled out..i was able to scale in and scale out,bt i want to know wen i scale out the image,I am bit confused with that..i tried to do with
    pinch.startPoint1 and pinch.startPoint1 and pinch.point1 and pinch.point2 bt of no use and confused.
    Can anyone help me with this..?

    My requirement is based on scaling i need to set the camera zoom...so
    when scaled in i do like:
    zoomvalue = prevScale + pinch.scale
    when scaled out i shud do like:
    zoomvalue = prevScale - pinch.scale

    here i dont know when i am scaling out and i have to find out that
    Please help me with some valuable answers

    Thanks in Advance



  • Hi guys,
    Do anyone know the answer...Please help me ..i am waiting for the help :-(

    Thanks
    Bala Beemaneni


  • Qt Champions 2017

    Did you look at the previousScale value of Pinch ? When the the pinch starts it starts with value 1.0. By reading the value of scale and previous scale continuously you may figure out the either it is scale-in or scale-out.



  • Hi,
    I really dont understand that will solve the problem.Consider
    *1st pinch: scale is 2.0 and previousScale: 0 *when we pinch again
    2nd Pinch: scale is 3.0 and previousScale: 2 .so now u can say we scale-in ...bt at the next time we scale-in only a small amount so that
    3rd pinch: scale is 1.5 and previousScale: 3
    consider pinch as scale-out now
    4th pinch: scale is 2 and previous scale: 1.5
    5thpinch: scale is 3 and previousScale: 2

    By this way how can we figure out?
    I am very much confused.If possible can u figure out anything with this?

    Thanks in Advance

    With Regards
    Bala


  • Moderators

    Did you see "this":http://developer.nokia.com/community/wiki/How_to_handle_pinch_gestures_using_PinchArea_item example ? May be onPinchStarted and onPinchUpdated handlers would be of interest to you.



  • hi p3c0
    Thanks for ur interest and i have seen that.that works well for pinch and zoom of an image ,bt further ater pinch and scale i need to set zoom value for camera.what value do i set for that and hw do i find that?

    Thanks
    Bala beemaneni


  • Moderators

    Is that needed ? Can't you directly use the pinch.scale to set the zoom ?



  • Every time pinch starts it resets to 1.So i used like
    pinch.scale += pinch.previousScale

    Even this does not give proper values as previousScale and scale are always equal.


  • Moderators

    Created the following sample, it zooms the camera as expected. Can you try it ?
    @
    Item {
    width: Screen.width
    height: Screen.height

    Camera {
        id: camera
        imageProcessing.whiteBalanceMode: CameraImageProcessing.WhiteBalanceFlash
    
        exposure {
            exposureCompensation: -1.0
            exposureMode: Camera.ExposurePortrait
        }
    
        flash.mode: Camera.FlashRedEyeReduction
    }
    
    VideoOutput {
        source: camera
        anchors.fill: parent
        focus : visible // to receive focus and capture key events when visible
    }
    
    PinchArea {
        anchors.fill: parent
        pinch.minimumScale: 0.1
        pinch.maximumScale: 1
        onPinchUpdated: camera.setDigitalZoom(pinch.scale)
    }
    

    }
    @



  • Did u capture the image and check?
    There is a marginal difference between the image captured and the amount of image zoomed for capture..


  • Moderators

    No i didn't as the question didn't say so. I thought you were struggling with the zooming using PinchArea and hence the above example. May be you should alter your question now ? Can you post what you have tried ?



  • Here the requirement goes as
    I should start the camera and zoom in zoom out the source and capture the image.
    my code is
    @Camera {
    id: cameraObj
    captureMode: Camera.CaptureStillImage

        onDigitalZoomChanged: {
            pathText.text = cameraObj.digitalZoom.toString()
        }
        imageCapture {
            resolution: "960x1280"
           onImageCaptured: {
              // some stuff here
            }
            onImageSaved: {           
             // similar 
            }
     }
    VideoOutput {
        id: viewfinderBack
        source: cameraObj
        anchors.fill: parent
        autoOrientation: true
        focus: visible
    }
    

    PinchArea {
    id: pincharea
    anchors.fill: parent
    pinch.target: viewfinderBack
    pinch.minimumScale: 1.0
    pinch.maximumScale: 4.0 // max cam zoom

        onPinchStarted: {
        }
        onPinchUpdated: {
          // Here th code should find out whether user is scaled in or scaled out.
           cameraObj.setDigitalZoom(pinch.scale)
        }
    

    }
    @

    Hi check out this and let me know ..


  • Moderators

    Yes there's a difference in the captured image and that the VideoOutput shows. I also tried "this":http://qt-project.org/doc/qt-5/qtmultimedia-declarative-camera-example.html QML camera example it too does that same. Can you check it if it works for you ?



  • Hi thanks for ur interest..

    I have seen that example already and they dont use pincharea for scale in and scale out.Instead they use mousearea .So that was not helpful as i tried implementing same logic to pincharea..

    Thanks
    Bala Beemaneni


  • Moderators

    I wanted to say that in that example also even if you digital zoom to the max and take the picture the result is not the same as expected. May be this is a bug, not sure though.



  • oh that is weird...i have nt checked that..let me check and update you

    Thanks
    Bala Beemaneni



  • Hi
    it captures the accurate image only..the example is quite good enough.
    As pinch and zoom is common in all mobiles now ,the logic should be pretty simple.Hope i am missing some basic stuff.
    i am struggling with this for so long almost an month..Can i get any help other than qt forum ? can u suggest any?

    Thanks Bala Beemaneni


  • Moderators

    Since the example is working properly, can you check the following scenario ?

    1. from declarative-camera example, zoom to highest level and capture the pic.
    2. from your app, zoom to the highest level and capture the pic.

    Compare these two pics if they are identical. Since both of them have set the digital zoom level to the highest which i assume is 4x, both captured pics must be identical.



  • Hi
    I would like to tel u onething here...if i set the zoom level manually to 1 or 2 or ...4 it works same as the example model.Both pics are identical.But the problem here is we are not able to sink the scale in value to zoom value.the camera viewfinder value i.e: the visible portion of the screen and captured portion of an image are not equal.Hope u know this already..
    Here wen i scale in ,based on scale portion zoom value has to be set.

    Thanks


  • Moderators

    bq. But the problem here is we are not able to sink the scale in value to zoom value

    One way to check this would be to check what are the actual values that are passed to setDigitalZoom function in the declarative-camera example when one zoom's it using the slider. These values can then be checked with the values that you set to setDigitalZoom which you receive when you Pinch. May be there's a difference, a multiplication factor or something like that.



  • hi
    i was trying the above method..it seems to be quite painful..But certainly there seems to be a multiplication factor .Meanwhile if u get any ideas please let me know

    Thanks


Log in to reply