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 19.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.
  • JonBJ JonB

    @jenya7
    After typing apt-get install followed by qt or qt5 did you press the Tab key (twice)?

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

    @JonB said in A camera problem.:

    @jenya7
    After typing apt-get install followed by qt or qt5 did you press the Tab key (twice)?

    thank you
    sudo apt-get install qtmultimedia5-dev
    it works. now all libraries are available.

    1 Reply Last reply
    2
    • J Offline
      J Offline
      jenya7
      wrote on last edited by jenya7
      #6

      This is my constructor

      Camera::Camera(QObject *parent) : QObject(parent)
      {
          //Camera devices:
      
          QActionGroup *videoDevicesGroup = new QActionGroup(this);
          videoDevicesGroup->setExclusive(true);
          const QList<QCameraInfo> availableCameras = QCameraInfo::availableCameras();
          for (const QCameraInfo &cameraInfo : availableCameras)
       {
              QAction *videoDeviceAction = new QAction(cameraInfo.description(), videoDevicesGroup);
              videoDeviceAction->setCheckable(true);
              videoDeviceAction->setData(QVariant::fromValue(cameraInfo));
              if (cameraInfo == QCameraInfo::defaultCamera())
                  videoDeviceAction->setChecked(true);
          }
      
          connect(videoDevicesGroup, &QActionGroup::triggered, this, &Camera::updateCameraDevice);
      
          setCamera(QCameraInfo::defaultCamera());
      }
      

      On availableCameras I get <0 items>.

      If I check the camera is alive
      raspistill -o Desktop/image.jpg
      it appears and I see a snapshot on the desktop.

      Does the library work with a Raspberry Pi camera at all? May be I'm beating a dead horse?

      jsulmJ 1 Reply Last reply
      0
      • J jenya7

        This is my constructor

        Camera::Camera(QObject *parent) : QObject(parent)
        {
            //Camera devices:
        
            QActionGroup *videoDevicesGroup = new QActionGroup(this);
            videoDevicesGroup->setExclusive(true);
            const QList<QCameraInfo> availableCameras = QCameraInfo::availableCameras();
            for (const QCameraInfo &cameraInfo : availableCameras)
         {
                QAction *videoDeviceAction = new QAction(cameraInfo.description(), videoDevicesGroup);
                videoDeviceAction->setCheckable(true);
                videoDeviceAction->setData(QVariant::fromValue(cameraInfo));
                if (cameraInfo == QCameraInfo::defaultCamera())
                    videoDeviceAction->setChecked(true);
            }
        
            connect(videoDevicesGroup, &QActionGroup::triggered, this, &Camera::updateCameraDevice);
        
            setCamera(QCameraInfo::defaultCamera());
        }
        

        On availableCameras I get <0 items>.

        If I check the camera is alive
        raspistill -o Desktop/image.jpg
        it appears and I see a snapshot on the desktop.

        Does the library work with a Raspberry Pi camera at all? May be I'm beating a dead horse?

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

        @jenya7 I think you will also need to install GStreamer plug-ins. On Linux Qt uses GStreamer for multimedia.

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

        J 1 Reply Last reply
        0
        • jsulmJ jsulm

          @jenya7 I think you will also need to install GStreamer plug-ins. On Linux Qt uses GStreamer for multimedia.

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

          @jsulm said in A camera problem.:

          @jenya7 I think you will also need to install GStreamer plug-ins. On Linux Qt uses GStreamer for multimedia.

          when I run
          dpkg -l | grep gstreamer
          I see gstreamer installed.

          jsulmJ 1 Reply Last reply
          0
          • J jenya7

            @jsulm said in A camera problem.:

            @jenya7 I think you will also need to install GStreamer plug-ins. On Linux Qt uses GStreamer for multimedia.

            when I run
            dpkg -l | grep gstreamer
            I see gstreamer installed.

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

            @jenya7 said in A camera problem.:

            I see gstreamer installed

            What exactly is installed? There are many GStreamer plug-ins which may be needed.

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

            J 1 Reply Last reply
            0
            • jsulmJ jsulm

              @jenya7 said in A camera problem.:

              I see gstreamer installed

              What exactly is installed? There are many GStreamer plug-ins which may be needed.

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

              @jsulm said in A camera problem.:

              @jenya7 said in A camera problem.:

              I see gstreamer installed

              What exactly is installed? There are many GStreamer plug-ins which may be needed.

              this is the list

              ii  gstreamer1.0-alsa:armhf               1.14.4-2+deb10u1                        armhf        GStreamer plugin for ALSA
              ii  gstreamer1.0-gtk3:armhf               1.14.4-1+rpt1+deb10u1                   armhf        GStreamer plugin for GTK+3
              ii  gstreamer1.0-libav:armhf              1.15.0.1+git20180723+db823502-2+deb10u1 armhf        libav plugin for GStreamer
              ii  gstreamer1.0-omx                      1.14.4-1+rpt1                           armhf        GStreamer OpenMAX plugins
              ii  gstreamer1.0-omx-rpi                  1.14.4-1+rpt1                           armhf        OpenMax plugins for GStreamer
              ii  gstreamer1.0-omx-rpi-config           1.14.4-1+rpt1                           armhf        OpenMax plugins for GStreamer
              ii  gstreamer1.0-plugins-bad:armhf        1.14.4-1+rvt+deb10u2                    armhf        GStreamer plugins from the "bad" set
              ii  gstreamer1.0-plugins-base:armhf       1.14.4-2+deb10u1                        armhf        GStreamer plugins from the "base" set
              ii  gstreamer1.0-plugins-good:armhf       1.14.4-1+rpt1+deb10u1                   armhf        GStreamer plugins from the "good" set
              ii  gstreamer1.0-x:armhf                  1.14.4-2+deb10u1                        armhf        GStreamer plugins for X11 and Pango
              ii  libgstreamer-gl1.0-0:armhf            1.14.4-2+deb10u1                        armhf        GStreamer GL libraries
              ii  libgstreamer-plugins-bad1.0-0:armhf   1.14.4-1+rvt+deb10u2                    armhf        GStreamer libraries from the "bad" set
              ii  libgstreamer-plugins-base1.0-0:armhf  1.14.4-2+deb10u1                        armhf        GStreamer libraries from the "base" set
              ii  libgstreamer1.0-0:armhf               1.14.4-1                                armhf        Core GStreamer libraries and elements
              ii  libreoffice-avmedia-backend-gstreamer 1:6.1.5-3+rpi1+deb10u7+rpt1             armhf        GStreamer backend for LibreOffice
              
              

              I really don't know if it's a complete list or a right version.

              jsulmJ 1 Reply Last reply
              0
              • J jenya7

                @jsulm said in A camera problem.:

                @jenya7 said in A camera problem.:

                I see gstreamer installed

                What exactly is installed? There are many GStreamer plug-ins which may be needed.

                this is the list

                ii  gstreamer1.0-alsa:armhf               1.14.4-2+deb10u1                        armhf        GStreamer plugin for ALSA
                ii  gstreamer1.0-gtk3:armhf               1.14.4-1+rpt1+deb10u1                   armhf        GStreamer plugin for GTK+3
                ii  gstreamer1.0-libav:armhf              1.15.0.1+git20180723+db823502-2+deb10u1 armhf        libav plugin for GStreamer
                ii  gstreamer1.0-omx                      1.14.4-1+rpt1                           armhf        GStreamer OpenMAX plugins
                ii  gstreamer1.0-omx-rpi                  1.14.4-1+rpt1                           armhf        OpenMax plugins for GStreamer
                ii  gstreamer1.0-omx-rpi-config           1.14.4-1+rpt1                           armhf        OpenMax plugins for GStreamer
                ii  gstreamer1.0-plugins-bad:armhf        1.14.4-1+rvt+deb10u2                    armhf        GStreamer plugins from the "bad" set
                ii  gstreamer1.0-plugins-base:armhf       1.14.4-2+deb10u1                        armhf        GStreamer plugins from the "base" set
                ii  gstreamer1.0-plugins-good:armhf       1.14.4-1+rpt1+deb10u1                   armhf        GStreamer plugins from the "good" set
                ii  gstreamer1.0-x:armhf                  1.14.4-2+deb10u1                        armhf        GStreamer plugins for X11 and Pango
                ii  libgstreamer-gl1.0-0:armhf            1.14.4-2+deb10u1                        armhf        GStreamer GL libraries
                ii  libgstreamer-plugins-bad1.0-0:armhf   1.14.4-1+rvt+deb10u2                    armhf        GStreamer libraries from the "bad" set
                ii  libgstreamer-plugins-base1.0-0:armhf  1.14.4-2+deb10u1                        armhf        GStreamer libraries from the "base" set
                ii  libgstreamer1.0-0:armhf               1.14.4-1                                armhf        Core GStreamer libraries and elements
                ii  libreoffice-avmedia-backend-gstreamer 1:6.1.5-3+rpi1+deb10u7+rpt1             armhf        GStreamer backend for LibreOffice
                
                

                I really don't know if it's a complete list or a right version.

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

                @jenya7 said in A camera problem.:

                or a right version

                That depends on the Qt version you're using.
                Try to also install gstreamer1.0-plugins-ugly, but I don't know whether this will help.

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

                J 1 Reply Last reply
                1
                • jsulmJ jsulm

                  @jenya7 said in A camera problem.:

                  or a right version

                  That depends on the Qt version you're using.
                  Try to also install gstreamer1.0-plugins-ugly, but I don't know whether this will help.

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

                  @jsulm said in A camera problem.:

                  @jenya7 said in A camera problem.:

                  or a right version

                  That depends on the Qt version you're using.
                  Try to also install gstreamer1.0-plugins-ugly, but I don't know whether this will help.

                  I found it out! It's not enough to install library
                  sudo apt-get install qtmultimedia5-dev
                  One should add plugins also
                  sudo apt-get install libqt5multimedia5-plugins

                  Now it founds the camera. But how do I refer to it later on? There are no fields like name or id or something
                  at least on debug level

                  availableCameras	<1 items>	QList<QCameraInfo>
                      [0]	@0x1027c8	QCameraInfo
                          d	@0x1027c8	QSharedPointer<QCameraInfoPrivate>
                  			data	@0x10cd88	QCameraInfoPrivate
                  			weakref	2	int
                  			strongref	2	int
                  	availableCameras@1	<optimized out>	
                  	cameraInfo	@0x1027c8	QCameraInfo &
                  		d	@0x1027c8	QSharedPointer<QCameraInfoPrivate>
                  			data	@0x10cd88	QCameraInfoPrivate
                  			weakref	2	int
                  			strongref	2	int
                  	cameraInfo@1	@0x1027c8	QCameraInfo &
                  		d	@0x1027c8	QSharedPointer<QCameraInfoPrivate>
                  			data	@0x10cd88	QCameraInfoPrivate
                  			weakref	2	int
                  			strongref	2	int
                  
                  QCameraInfo::defaultCamera()		QCameraInfo
                  		d		QSharedPointer<QCameraInfoPrivate>
                  			data	@0x111438	QCameraInfoPrivate
                  			weakref	1	int
                  			strongref	1	int
                  
                  jsulmJ 1 Reply Last reply
                  0
                  • J jenya7

                    @jsulm said in A camera problem.:

                    @jenya7 said in A camera problem.:

                    or a right version

                    That depends on the Qt version you're using.
                    Try to also install gstreamer1.0-plugins-ugly, but I don't know whether this will help.

                    I found it out! It's not enough to install library
                    sudo apt-get install qtmultimedia5-dev
                    One should add plugins also
                    sudo apt-get install libqt5multimedia5-plugins

                    Now it founds the camera. But how do I refer to it later on? There are no fields like name or id or something
                    at least on debug level

                    availableCameras	<1 items>	QList<QCameraInfo>
                        [0]	@0x1027c8	QCameraInfo
                            d	@0x1027c8	QSharedPointer<QCameraInfoPrivate>
                    			data	@0x10cd88	QCameraInfoPrivate
                    			weakref	2	int
                    			strongref	2	int
                    	availableCameras@1	<optimized out>	
                    	cameraInfo	@0x1027c8	QCameraInfo &
                    		d	@0x1027c8	QSharedPointer<QCameraInfoPrivate>
                    			data	@0x10cd88	QCameraInfoPrivate
                    			weakref	2	int
                    			strongref	2	int
                    	cameraInfo@1	@0x1027c8	QCameraInfo &
                    		d	@0x1027c8	QSharedPointer<QCameraInfoPrivate>
                    			data	@0x10cd88	QCameraInfoPrivate
                    			weakref	2	int
                    			strongref	2	int
                    
                    QCameraInfo::defaultCamera()		QCameraInfo
                    		d		QSharedPointer<QCameraInfoPrivate>
                    			data	@0x111438	QCameraInfoPrivate
                    			weakref	1	int
                    			strongref	1	int
                    
                    jsulmJ Offline
                    jsulmJ Offline
                    jsulm
                    Lifetime Qt Champion
                    wrote on last edited by
                    #13

                    @jenya7 said in A camera problem.:

                    There are no fields like name or id or something

                    There is: https://doc.qt.io/qt-5/qcamerainfo.html#deviceName

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

                    J 1 Reply Last reply
                    0
                    • jsulmJ jsulm

                      @jenya7 said in A camera problem.:

                      There are no fields like name or id or something

                      There is: https://doc.qt.io/qt-5/qcamerainfo.html#deviceName

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

                      @jsulm said in A camera problem.:

                      @jenya7 said in A camera problem.:

                      There are no fields like name or id or something

                      There is: https://doc.qt.io/qt-5/qcamerainfo.html#deviceName

                      I see. Thank you. I'll try to get it going.

                      1 Reply Last reply
                      0
                      • J Offline
                        J Offline
                        jenya7
                        wrote on last edited by
                        #15

                        something eluding me
                        To take a shot

                        void Camera::takeImage()
                        

                        Then on

                        connect(m_imageCapture.data(), &QCameraImageCapture::imageCaptured, this, &Camera::processCapturedImage);
                        
                        void Camera::processCapturedImage(int requestId, const QImage& img)
                        {
                            Q_UNUSED(requestId);
                            QImage scaledImage = 100, 100,
                                                            Qt::KeepAspectRatio,
                                                            Qt::SmoothTransformation);
                        
                            ui->lastImagePreviewLabel->setPixmap(QPixmap::fromImage(scaledImage));
                        
                            // Display captured image for 4 seconds.
                            displayCapturedImage();
                            QTimer::singleShot(4000, this, &Camera::displayViewfinder);
                        }
                        

                        But where the image actually stored?

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

                          Hi,

                          Unless you configure the capture to capture to file, its just going to be in the buffer. You can still save it yourself though.

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

                          J 1 Reply Last reply
                          0
                          • SGaistS SGaist

                            Hi,

                            Unless you configure the capture to capture to file, its just going to be in the buffer. You can still save it yourself though.

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

                            @SGaist said in A camera problem.:

                            Hi,

                            Unless you configure the capture to capture to file, its just going to be in the buffer. You can still save it yourself though.

                            How do I do that? I see m_imageCapture but no property or method to set a path to a file.
                            And where the buffer located?

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

                              The buffer just means it's in memory. You'll get a frame to process and then it's up to you to save it.

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

                              J 1 Reply Last reply
                              0
                              • SGaistS SGaist

                                The buffer just means it's in memory. You'll get a frame to process and then it's up to you to save it.

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

                                @SGaist said in A camera problem.:

                                The buffer just means it's in memory. You'll get a frame to process and then it's up to you to save it.

                                After

                                g_camera.SetCaptureMode(QCamera::CaptureMode::CaptureStillImage);
                                g_camera.takeImage();
                                

                                Nothing happens. I didn't get to

                                void Camera::processCapturedImage(int requestId, const QImage& img)
                                

                                or

                                void Camera::imageSaved(int id, const QString &fileName)
                                

                                How do I know where is the image (if it was taken at all)?

                                jsulmJ 1 Reply Last reply
                                0
                                • J jenya7

                                  @SGaist said in A camera problem.:

                                  The buffer just means it's in memory. You'll get a frame to process and then it's up to you to save it.

                                  After

                                  g_camera.SetCaptureMode(QCamera::CaptureMode::CaptureStillImage);
                                  g_camera.takeImage();
                                  

                                  Nothing happens. I didn't get to

                                  void Camera::processCapturedImage(int requestId, const QImage& img)
                                  

                                  or

                                  void Camera::imageSaved(int id, const QString &fileName)
                                  

                                  How do I know where is the image (if it was taken at all)?

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

                                  @jenya7 Did you connect a slot to https://doc.qt.io/qt-5/qcamera.html#errorOccurred to see whether you get any errors? Same for https://doc.qt.io/qt-5/qcameraimagecapture.html#error-1
                                  You can get the cptured image using this signal: https://doc.qt.io/qt-5/qcameraimagecapture.html#imageAvailable

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

                                  J 1 Reply Last reply
                                  0
                                  • jsulmJ jsulm

                                    @jenya7 Did you connect a slot to https://doc.qt.io/qt-5/qcamera.html#errorOccurred to see whether you get any errors? Same for https://doc.qt.io/qt-5/qcameraimagecapture.html#error-1
                                    You can get the cptured image using this signal: https://doc.qt.io/qt-5/qcameraimagecapture.html#imageAvailable

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

                                    @jsulm said in A camera problem.:

                                    @jenya7 Did you connect a slot to https://doc.qt.io/qt-5/qcamera.html#errorOccurred to see whether you get any errors? Same for https://doc.qt.io/qt-5/qcameraimagecapture.html#error-1
                                    You can get the cptured image using this signal: https://doc.qt.io/qt-5/qcameraimagecapture.html#imageAvailable

                                    this is what I have

                                    connect(m_imageCapture.data(), &QCameraImageCapture::readyForCaptureChanged, this, &Camera::readyForCapture);
                                    connect(m_imageCapture.data(), &QCameraImageCapture::imageCaptured, this, &Camera::processCapturedImage);
                                    connect(m_imageCapture.data(), &QCameraImageCapture::imageSaved, this, &Camera::imageSaved);
                                    connect(m_imageCapture.data(), QOverload<int, QCameraImageCapture::Error, const QString &>::of(&QCameraImageCapture::error),
                                                this, &Camera::displayCaptureError);
                                    
                                    jsulmJ 1 Reply Last reply
                                    0
                                    • J jenya7

                                      @jsulm said in A camera problem.:

                                      @jenya7 Did you connect a slot to https://doc.qt.io/qt-5/qcamera.html#errorOccurred to see whether you get any errors? Same for https://doc.qt.io/qt-5/qcameraimagecapture.html#error-1
                                      You can get the cptured image using this signal: https://doc.qt.io/qt-5/qcameraimagecapture.html#imageAvailable

                                      this is what I have

                                      connect(m_imageCapture.data(), &QCameraImageCapture::readyForCaptureChanged, this, &Camera::readyForCapture);
                                      connect(m_imageCapture.data(), &QCameraImageCapture::imageCaptured, this, &Camera::processCapturedImage);
                                      connect(m_imageCapture.data(), &QCameraImageCapture::imageSaved, this, &Camera::imageSaved);
                                      connect(m_imageCapture.data(), QOverload<int, QCameraImageCapture::Error, const QString &>::of(&QCameraImageCapture::error),
                                                  this, &Camera::displayCaptureError);
                                      
                                      jsulmJ Offline
                                      jsulmJ Offline
                                      jsulm
                                      Lifetime Qt Champion
                                      wrote on last edited by
                                      #22

                                      @jenya7 So, what about trying https://doc.qt.io/qt-5/qcameraimagecapture.html#imageAvailable ?

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

                                      J 1 Reply Last reply
                                      0
                                      • jsulmJ jsulm

                                        @jenya7 So, what about trying https://doc.qt.io/qt-5/qcameraimagecapture.html#imageAvailable ?

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

                                        @jsulm said in A camera problem.:

                                        @jenya7 So, what about trying https://doc.qt.io/qt-5/qcameraimagecapture.html#imageAvailable ?

                                        I did in Camera::setCamera

                                        connect(m_imageCapture.data(), &QCameraImageCapture::imageAvailable, this, &Camera::ImageAvailable);
                                        

                                        and then

                                        void Camera::ImageAvailable(int id, const QVideoFrame &frame)
                                        {
                                             qDebug() <<  id;
                                             //qDebug() << frame->???;
                                        }
                                        

                                        I also added

                                        void Camera::displayCameraError()
                                        {
                                            //QMessageBox::warning(this, tr("Camera Error"), m_camera->errorString());
                                            qDebug() << "Camera Error: " + m_camera->errorString() + "\n";
                                        }
                                        
                                        void Camera::displayCaptureError(int id, const QCameraImageCapture::Error error, const QString &errorString)
                                        {
                                            Q_UNUSED(id);
                                            Q_UNUSED(error);
                                            qDebug() << "Image Capture Error: " + errorString;
                                            m_isCapturingImage = false;
                                        }
                                        

                                        and when I do

                                        g_camera.SetCaptureMode(QCamera::CaptureMode::CaptureStillImage);
                                        g_camera.takeImage();
                                        

                                        I get

                                        "Image Capture Error: Camera not ready"
                                        

                                        How can I know a reason why the camera isn't ready?

                                        jsulmJ 1 Reply Last reply
                                        0
                                        • J jenya7

                                          @jsulm said in A camera problem.:

                                          @jenya7 So, what about trying https://doc.qt.io/qt-5/qcameraimagecapture.html#imageAvailable ?

                                          I did in Camera::setCamera

                                          connect(m_imageCapture.data(), &QCameraImageCapture::imageAvailable, this, &Camera::ImageAvailable);
                                          

                                          and then

                                          void Camera::ImageAvailable(int id, const QVideoFrame &frame)
                                          {
                                               qDebug() <<  id;
                                               //qDebug() << frame->???;
                                          }
                                          

                                          I also added

                                          void Camera::displayCameraError()
                                          {
                                              //QMessageBox::warning(this, tr("Camera Error"), m_camera->errorString());
                                              qDebug() << "Camera Error: " + m_camera->errorString() + "\n";
                                          }
                                          
                                          void Camera::displayCaptureError(int id, const QCameraImageCapture::Error error, const QString &errorString)
                                          {
                                              Q_UNUSED(id);
                                              Q_UNUSED(error);
                                              qDebug() << "Image Capture Error: " + errorString;
                                              m_isCapturingImage = false;
                                          }
                                          

                                          and when I do

                                          g_camera.SetCaptureMode(QCamera::CaptureMode::CaptureStillImage);
                                          g_camera.takeImage();
                                          

                                          I get

                                          "Image Capture Error: Camera not ready"
                                          

                                          How can I know a reason why the camera isn't ready?

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

                                          @jenya7 Did you call

                                          camera->setCaptureMode(QCamera::CaptureStillImage);
                                          camera->start();
                                          //on half pressed shutter button
                                          camera->searchAndLock();
                                          
                                          //on shutter button pressed
                                          imageCapture->capture();
                                          

                                          like shown in https://doc.qt.io/qt-5/qcameraimagecapture.html ?

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

                                          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