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. A camera problem.
Forum Updated to NodeBB v4.3 + New Features

A camera problem.

Scheduled Pinned Locked Moved Unsolved General and Desktop
91 Posts 7 Posters 18.9k Views 2 Watching
  • 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.
  • J jenya7

    @J-Hilk said in A camera problem.:

    @jenya7 soooo, inside main() ?

    actually for debug purposes I instantiated it in other module - command line parser, but it's static and never goes out of scope.

    J.HilkJ Offline
    J.HilkJ Offline
    J.Hilk
    Moderators
    wrote on last edited by
    #57

    @jenya7

    static

    thats actually forbidden, no QObject based object must be created before the QCoreApplication instance. Static objects will be created before the QCoreApplication instance.


    Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


    Q: What's that?
    A: It's blue light.
    Q: What does it do?
    A: It turns blue.

    J 1 Reply Last reply
    0
    • J.HilkJ J.Hilk

      @jenya7

      static

      thats actually forbidden, no QObject based object must be created before the QCoreApplication instance. Static objects will be created before the QCoreApplication instance.

      J Offline
      J Offline
      jenya7
      wrote on last edited by
      #58

      @J-Hilk said in A camera problem.:

      @jenya7

      static

      thats actually forbidden, no QObject based object must be created before the QCoreApplication instance. Static objects will be created before the QCoreApplication instance.

      I mean it it's created without static attribute, but i's not locally allocated.

      J 1 Reply Last reply
      0
      • J jenya7

        @J-Hilk said in A camera problem.:

        @jenya7

        static

        thats actually forbidden, no QObject based object must be created before the QCoreApplication instance. Static objects will be created before the QCoreApplication instance.

        I mean it it's created without static attribute, but i's not locally allocated.

        J Offline
        J Offline
        jenya7
        wrote on last edited by
        #59

        If I only could drill down to the cause of
        "Image Capture Error: Camera not ready"
        What makes it not ready for m_imageCapture...

        JonBJ 1 Reply Last reply
        0
        • J jenya7

          If I only could drill down to the cause of
          "Image Capture Error: Camera not ready"
          What makes it not ready for m_imageCapture...

          JonBJ Offline
          JonBJ Offline
          JonB
          wrote on last edited by
          #60

          @jenya7
          I know nothing about cameras and captures, so no idea about causes. I will say your definition of void Camera::ReadyForCaptureChanged(bool ready) is wrong, since it does not examine the ready parameter value. But if you say it's never hit that is moot.

          J 1 Reply Last reply
          0
          • JonBJ JonB

            @jenya7
            I know nothing about cameras and captures, so no idea about causes. I will say your definition of void Camera::ReadyForCaptureChanged(bool ready) is wrong, since it does not examine the ready parameter value. But if you say it's never hit that is moot.

            J Offline
            J Offline
            jenya7
            wrote on last edited by
            #61

            @JonB said in A camera problem.:

            @jenya7
            I know nothing about cameras and captures, so no idea about causes. I will say your definition of void Camera::ReadyForCaptureChanged(bool ready) is wrong, since it does not examine the ready parameter value. But if you say it's never hit that is moot.

            Yes. But it never hits if (ready) line.

            void Camera::ReadyForCaptureChanged(bool ready)
            {
                if (ready)
                {
                    m_isCapturingImage = true;
                    m_imageCapture->capture();
            
                    m_camera->unlock();
                }
            }
            
            J.HilkJ JonBJ 2 Replies Last reply
            0
            • J jenya7

              @JonB said in A camera problem.:

              @jenya7
              I know nothing about cameras and captures, so no idea about causes. I will say your definition of void Camera::ReadyForCaptureChanged(bool ready) is wrong, since it does not examine the ready parameter value. But if you say it's never hit that is moot.

              Yes. But it never hits if (ready) line.

              void Camera::ReadyForCaptureChanged(bool ready)
              {
                  if (ready)
                  {
                      m_isCapturingImage = true;
                      m_imageCapture->capture();
              
                      m_camera->unlock();
                  }
              }
              
              J.HilkJ Offline
              J.HilkJ Offline
              J.Hilk
              Moderators
              wrote on last edited by
              #62

              @jenya7
              do you call show() on your viewfinder instance ? It will probably never change its state, if the viewfinder is not "visible"


              Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


              Q: What's that?
              A: It's blue light.
              Q: What does it do?
              A: It turns blue.

              J 1 Reply Last reply
              0
              • J jenya7

                @JonB said in A camera problem.:

                @jenya7
                I know nothing about cameras and captures, so no idea about causes. I will say your definition of void Camera::ReadyForCaptureChanged(bool ready) is wrong, since it does not examine the ready parameter value. But if you say it's never hit that is moot.

                Yes. But it never hits if (ready) line.

                void Camera::ReadyForCaptureChanged(bool ready)
                {
                    if (ready)
                    {
                        m_isCapturingImage = true;
                        m_imageCapture->capture();
                
                        m_camera->unlock();
                    }
                }
                
                JonBJ Offline
                JonBJ Offline
                JonB
                wrote on last edited by
                #63

                @jenya7
                Yes, at least the code is right, but won't help if that never gets hit.
                Bearing in mind I know nothing about cameras, why did you comment out the m_camera->isCaptureModeSupported(...) lines, what do these actually return? If they return false presumably that would explain why you never get QCameraImageCapture::readyForCaptureChanged ?

                Oh I see @J-Hilk has chimed in with some knowledge of this camera stuff....

                1 Reply Last reply
                0
                • J.HilkJ J.Hilk

                  @jenya7
                  do you call show() on your viewfinder instance ? It will probably never change its state, if the viewfinder is not "visible"

                  J Offline
                  J Offline
                  jenya7
                  wrote on last edited by jenya7
                  #64

                  @J-Hilk said in A camera problem.:

                  @jenya7
                  do you call show() on your viewfinder instance ? It will probably never change its state, if the viewfinder is not "visible"

                  It can be an issue.
                  Although I create an object in mainwindow.cpp

                  QCameraViewfinder *v_finder;
                  
                  MainWindow::MainWindow(QWidget *parent) :
                      QMainWindow(parent),
                      ui(new Ui::MainWindow)
                  {
                      v_finder= new QCameraViewfinder(this);
                  
                      ui->setupUi(this);
                      ui->textEditTerminalTx->installEventFilter(this);
                  }
                  

                  It's not physically allocated. The app wasn't suppose to have such widget.
                  So on v_finder->show() I get an exception.
                  Is it possible to emulate the viewfinder ?

                  J jsulmJ JonBJ 3 Replies Last reply
                  0
                  • J jenya7

                    @J-Hilk said in A camera problem.:

                    @jenya7
                    do you call show() on your viewfinder instance ? It will probably never change its state, if the viewfinder is not "visible"

                    It can be an issue.
                    Although I create an object in mainwindow.cpp

                    QCameraViewfinder *v_finder;
                    
                    MainWindow::MainWindow(QWidget *parent) :
                        QMainWindow(parent),
                        ui(new Ui::MainWindow)
                    {
                        v_finder= new QCameraViewfinder(this);
                    
                        ui->setupUi(this);
                        ui->textEditTerminalTx->installEventFilter(this);
                    }
                    

                    It's not physically allocated. The app wasn't suppose to have such widget.
                    So on v_finder->show() I get an exception.
                    Is it possible to emulate the viewfinder ?

                    J Offline
                    J Offline
                    jenya7
                    wrote on last edited by
                    #65
                    This post is deleted!
                    1 Reply Last reply
                    0
                    • J jenya7

                      @J-Hilk said in A camera problem.:

                      @jenya7
                      do you call show() on your viewfinder instance ? It will probably never change its state, if the viewfinder is not "visible"

                      It can be an issue.
                      Although I create an object in mainwindow.cpp

                      QCameraViewfinder *v_finder;
                      
                      MainWindow::MainWindow(QWidget *parent) :
                          QMainWindow(parent),
                          ui(new Ui::MainWindow)
                      {
                          v_finder= new QCameraViewfinder(this);
                      
                          ui->setupUi(this);
                          ui->textEditTerminalTx->installEventFilter(this);
                      }
                      

                      It's not physically allocated. The app wasn't suppose to have such widget.
                      So on v_finder->show() I get an exception.
                      Is it possible to emulate the viewfinder ?

                      jsulmJ Offline
                      jsulmJ Offline
                      jsulm
                      Lifetime Qt Champion
                      wrote on last edited by
                      #66

                      @jenya7 said in A camera problem.:

                      It's not physically allocated

                      It is, see the first line in the constructor

                      https://forum.qt.io/topic/113070/qt-code-of-conduct

                      J 1 Reply Last reply
                      0
                      • J jenya7

                        @J-Hilk said in A camera problem.:

                        @jenya7
                        do you call show() on your viewfinder instance ? It will probably never change its state, if the viewfinder is not "visible"

                        It can be an issue.
                        Although I create an object in mainwindow.cpp

                        QCameraViewfinder *v_finder;
                        
                        MainWindow::MainWindow(QWidget *parent) :
                            QMainWindow(parent),
                            ui(new Ui::MainWindow)
                        {
                            v_finder= new QCameraViewfinder(this);
                        
                            ui->setupUi(this);
                            ui->textEditTerminalTx->installEventFilter(this);
                        }
                        

                        It's not physically allocated. The app wasn't suppose to have such widget.
                        So on v_finder->show() I get an exception.
                        Is it possible to emulate the viewfinder ?

                        JonBJ Offline
                        JonBJ Offline
                        JonB
                        wrote on last edited by
                        #67

                        @jenya7
                        What is "not physically allocated", and why do you get an exception on what?

                        There is a basic example at https://doc.qt.io/qt-5/qcameraviewfinder.html

                        camera = new QCamera;
                        
                        viewfinder = new QCameraViewfinder();
                        viewfinder->show();
                        
                        camera->setViewfinder(viewfinder);
                        
                        imageCapture = new QCameraImageCapture(camera);
                        
                        camera->setCaptureMode(QCamera::CaptureStillImage);
                        camera->start();
                        

                        Did you test whether just this code might work for you?

                        You also ought check those m_camera->isCaptureModeSupported(...) I mentioned, else you are whistling in the wind....

                        J 2 Replies Last reply
                        1
                        • JonBJ JonB

                          @jenya7
                          What is "not physically allocated", and why do you get an exception on what?

                          There is a basic example at https://doc.qt.io/qt-5/qcameraviewfinder.html

                          camera = new QCamera;
                          
                          viewfinder = new QCameraViewfinder();
                          viewfinder->show();
                          
                          camera->setViewfinder(viewfinder);
                          
                          imageCapture = new QCameraImageCapture(camera);
                          
                          camera->setCaptureMode(QCamera::CaptureStillImage);
                          camera->start();
                          

                          Did you test whether just this code might work for you?

                          You also ought check those m_camera->isCaptureModeSupported(...) I mentioned, else you are whistling in the wind....

                          J Offline
                          J Offline
                          jenya7
                          wrote on last edited by jenya7
                          #68

                          @JonB
                          viewfinder = new QCameraViewfinder(); is an empty object, not tied to any widget. in the original example viewfinder is tied to a StackedWidget panel.

                          jsulmJ JonBJ 2 Replies Last reply
                          0
                          • jsulmJ jsulm

                            @jenya7 said in A camera problem.:

                            It's not physically allocated

                            It is, see the first line in the constructor

                            J Offline
                            J Offline
                            jenya7
                            wrote on last edited by
                            #69

                            @jsulm said in A camera problem.:

                            @jenya7 said in A camera problem.:

                            It's not physically allocated

                            It is, see the first line in the constructor

                            It doesn't work

                            jsulmJ 1 Reply Last reply
                            0
                            • J jenya7

                              @JonB
                              viewfinder = new QCameraViewfinder(); is an empty object, not tied to any widget. in the original example viewfinder is tied to a StackedWidget panel.

                              jsulmJ Offline
                              jsulmJ Offline
                              jsulm
                              Lifetime Qt Champion
                              wrote on last edited by
                              #70

                              @jenya7 said in A camera problem.:

                              viewfinder = new QCameraViewfinder(); is an empty object, not tied to any widget.

                              It's not "empty". And a widget does not have to be "tied" to another widget. If it is not and you call show() on it it will be shown in its own window, but it should not crash...

                              https://forum.qt.io/topic/113070/qt-code-of-conduct

                              J 1 Reply Last reply
                              0
                              • J jenya7

                                @jsulm said in A camera problem.:

                                @jenya7 said in A camera problem.:

                                It's not physically allocated

                                It is, see the first line in the constructor

                                It doesn't work

                                jsulmJ Offline
                                jsulmJ Offline
                                jsulm
                                Lifetime Qt Champion
                                wrote on last edited by
                                #71

                                @jenya7 said in A camera problem.:

                                It doesn't work

                                What doesn't work? I'm sure that line works. Do you call show() after that line or before?

                                https://forum.qt.io/topic/113070/qt-code-of-conduct

                                1 Reply Last reply
                                0
                                • jsulmJ jsulm

                                  @jenya7 said in A camera problem.:

                                  viewfinder = new QCameraViewfinder(); is an empty object, not tied to any widget.

                                  It's not "empty". And a widget does not have to be "tied" to another widget. If it is not and you call show() on it it will be shown in its own window, but it should not crash...

                                  J Offline
                                  J Offline
                                  jenya7
                                  wrote on last edited by
                                  #72

                                  @jsulm said in A camera problem.:

                                  @jenya7 said in A camera problem.:

                                  viewfinder = new QCameraViewfinder(); is an empty object, not tied to any widget.

                                  It's not "empty". And a widget does not have to be "tied" to another widget. If it is not and you call show() on it it will be shown in its own window, but it should not crash...

                                  I see. I'll try to understand what causes the crash.

                                  1 Reply Last reply
                                  0
                                  • J jenya7

                                    @JonB
                                    viewfinder = new QCameraViewfinder(); is an empty object, not tied to any widget. in the original example viewfinder is tied to a StackedWidget panel.

                                    JonBJ Offline
                                    JonBJ Offline
                                    JonB
                                    wrote on last edited by JonB
                                    #73

                                    @jenya7 said in A camera problem.:

                                    viewfinder = new QCameraViewfinder(); is an empty object, not tied to any widget

                                    QCameraViewfinder is a QWidget, so don't know what this means. In your case you may need to give it a parent or add it somewhere. I have suggested code you might try before turning to your own code....

                                    1 Reply Last reply
                                    0
                                    • JonBJ JonB

                                      @jenya7
                                      What is "not physically allocated", and why do you get an exception on what?

                                      There is a basic example at https://doc.qt.io/qt-5/qcameraviewfinder.html

                                      camera = new QCamera;
                                      
                                      viewfinder = new QCameraViewfinder();
                                      viewfinder->show();
                                      
                                      camera->setViewfinder(viewfinder);
                                      
                                      imageCapture = new QCameraImageCapture(camera);
                                      
                                      camera->setCaptureMode(QCamera::CaptureStillImage);
                                      camera->start();
                                      

                                      Did you test whether just this code might work for you?

                                      You also ought check those m_camera->isCaptureModeSupported(...) I mentioned, else you are whistling in the wind....

                                      J Offline
                                      J Offline
                                      jenya7
                                      wrote on last edited by jenya7
                                      #74

                                      @JonB said in A camera problem.:

                                      @jenya7
                                      What is "not physically allocated", and why do you get an exception on what?

                                      There is a basic example at https://doc.qt.io/qt-5/qcameraviewfinder.html
                                      Did you test whether just this code might work for you?

                                      You also ought check those m_camera->isCaptureModeSupported(...) I mentioned, else you are whistling in the wind....

                                      bool supported = m_camera->isCaptureModeSupported(QCamera::CaptureStillImage);
                                      

                                      Yes. It's supported.
                                      I see the Camera object is created before MainWindow::MainWindow(QWidget *parent) constructor.
                                      Is it normal?

                                      jsulmJ JonBJ 2 Replies Last reply
                                      0
                                      • J jenya7

                                        @JonB said in A camera problem.:

                                        @jenya7
                                        What is "not physically allocated", and why do you get an exception on what?

                                        There is a basic example at https://doc.qt.io/qt-5/qcameraviewfinder.html
                                        Did you test whether just this code might work for you?

                                        You also ought check those m_camera->isCaptureModeSupported(...) I mentioned, else you are whistling in the wind....

                                        bool supported = m_camera->isCaptureModeSupported(QCamera::CaptureStillImage);
                                        

                                        Yes. It's supported.
                                        I see the Camera object is created before MainWindow::MainWindow(QWidget *parent) constructor.
                                        Is it normal?

                                        jsulmJ Offline
                                        jsulmJ Offline
                                        jsulm
                                        Lifetime Qt Champion
                                        wrote on last edited by
                                        #75

                                        @jenya7 said in A camera problem.:

                                        I see the Camera object is created before MainWindow::MainWindow(QWidget *parent) constructor.

                                        Where do you see it and where do you create camera object? Can you please post relevant code?

                                        https://forum.qt.io/topic/113070/qt-code-of-conduct

                                        J 1 Reply Last reply
                                        0
                                        • J jenya7

                                          @JonB said in A camera problem.:

                                          @jenya7
                                          What is "not physically allocated", and why do you get an exception on what?

                                          There is a basic example at https://doc.qt.io/qt-5/qcameraviewfinder.html
                                          Did you test whether just this code might work for you?

                                          You also ought check those m_camera->isCaptureModeSupported(...) I mentioned, else you are whistling in the wind....

                                          bool supported = m_camera->isCaptureModeSupported(QCamera::CaptureStillImage);
                                          

                                          Yes. It's supported.
                                          I see the Camera object is created before MainWindow::MainWindow(QWidget *parent) constructor.
                                          Is it normal?

                                          JonBJ Offline
                                          JonBJ Offline
                                          JonB
                                          wrote on last edited by JonB
                                          #76

                                          @jenya7
                                          OK, but why not try the example from the docs, in a standalone test program? Not going to say it again.....

                                          J 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