Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Change Viewfinder Resolution in qt C++

Change Viewfinder Resolution in qt C++

Scheduled Pinned Locked Moved Unsolved General and Desktop
17 Posts 3 Posters 4.0k 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.
  • P Offline
    P Offline
    Praveen k
    wrote on last edited by
    #1

    Hey Guys!!!! Once again in trouble. I am trying to change viewfinder resolution at run time but unfortunately, application is closing..
    Let me explain you in detail:-

    • Initially i am setting my viewfinder resolution to the last supported viewfinder resolutions (say 1280 x 720) and then with the help of combo box i am selecting another resolution (say 640 x 480)
    • After selecting another resolution, my program is finishing unexpectedly.

    Anybody with the solution please.. Regrets for silly mistakes.
    Here is the sample snippet....

    mCameraViewFinder = new QCameraViewfinder;
    mCameraImageCapture = new QCameraImageCapture(mCamera,this);
    
        mCamera->start();
        QList<QSize> res = mCamera->supportedViewfinderResolutions();
         QSize selectedRes;
            if(!res.isEmpty())
            {
                selectedRes = res.takeLast();
            }
            else
            {
                 qDebug()<<"Empty Resolution!!!";
            }
        viewfindersettings.setResolution(selectedRes);
    //Here current resolution is 1280*720 
        mCamera->setViewfinderSettings(viewfindersettings);
    
    //After selecting resolution from combo box
        viewfindersettings.setResolution(n,n1);
    //Here n and n1 are 640 and 480 respectively
        mCamera->setViewfinderSettings(viewfindersettings);
        mCamera->setViewfinder(ui->viewfinder);
        mCamera->start();
    

    Need some help...

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      What does a run through the debugger tell you ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      1
      • P Offline
        P Offline
        Praveen k
        wrote on last edited by
        #3

        It is pointing to this error:-

         mCamera->setViewfinderSettings(viewfindersettings);
        

        Giving me Segmentation fault. And the value in (this) is 0x0 of type camera*

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Do you mean that mCamera is a null pointer ?

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          1
          • P Offline
            P Offline
            Praveen k
            wrote on last edited by
            #5

            No. I have initialized.

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              Can you post an image of the stack trace ?

              See the guide here for posting picture as the upload is currently broken.

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              1
              • P Offline
                P Offline
                Praveen k
                wrote on last edited by
                #7
                This post is deleted!
                1 Reply Last reply
                0
                • P Offline
                  P Offline
                  Praveen k
                  wrote on last edited by p3c0
                  #8

                  https://drive.google.com/open?id=0B27_ICxFo-UcaE9icWx3UTBZcmM

                  1 Reply Last reply
                  0
                  • p3c0P Offline
                    p3c0P Offline
                    p3c0
                    Moderators
                    wrote on last edited by
                    #9

                    @Praveen-k Use some other site where login is not required.
                    https://postimage.org
                    http://tinypic.com

                    157

                    1 Reply Last reply
                    2
                    • P Offline
                      P Offline
                      Praveen k
                      wrote on last edited by Praveen k
                      #10

                      I tried as @SGaist guided for posting pictures on forum. But unfortunately itz not posting. So here you can get it
                      https://postimg.org/image/x3po0e1lf

                      1 Reply Last reply
                      0
                      • SGaistS Offline
                        SGaistS Offline
                        SGaist
                        Lifetime Qt Champion
                        wrote on last edited by
                        #11

                        The camera object itself seems to be null. Are you sure it's initialized correctly ?

                        Interested in AI ? www.idiap.ch
                        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                        1 Reply Last reply
                        0
                        • P Offline
                          P Offline
                          Praveen k
                          wrote on last edited by
                          #12

                          Ok. if i have not initialized it, can you help me on how to initialize it?
                          I have done the initialization as below:

                              mCamera = new QCamera(this);
                              mCameraViewFinder = new QCameraViewfinder(this);
                              mCameraImageCapture = new QCameraImageCapture(mCamera,this);
                              mCamera->start();
                          
                          1 Reply Last reply
                          0
                          • SGaistS Offline
                            SGaistS Offline
                            SGaist
                            Lifetime Qt Champion
                            wrote on last edited by
                            #13

                            It's not your mCamera object that is null, it's your camera object.

                            Interested in AI ? www.idiap.ch
                            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                            1 Reply Last reply
                            0
                            • P Offline
                              P Offline
                              Praveen k
                              wrote on last edited by
                              #14

                              How can i initialize it? Plz help me

                              1 Reply Last reply
                              0
                              • SGaistS Offline
                                SGaistS Offline
                                SGaist
                                Lifetime Qt Champion
                                wrote on last edited by
                                #15

                                It's your own custom class, how can I know where you use it or how you use it ?

                                Interested in AI ? www.idiap.ch
                                Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                                1 Reply Last reply
                                0
                                • P Offline
                                  P Offline
                                  Praveen k
                                  wrote on last edited by Praveen k
                                  #16

                                  Sorry.. I got it. Thanks for the solution man. Silly mistake from my side..
                                  But after initializing new camera is starting. Wat if, i want the previous one

                                  1 Reply Last reply
                                  0
                                  • SGaistS Offline
                                    SGaistS Offline
                                    SGaist
                                    Lifetime Qt Champion
                                    wrote on last edited by
                                    #17

                                    Then don't create a new QCamera each time you change the resolution.

                                    Interested in AI ? www.idiap.ch
                                    Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                                    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