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. add several QCameras on one window
Qt 6.11 is out! See what's new in the release blog

add several QCameras on one window

Scheduled Pinned Locked Moved Unsolved General and Desktop
13 Posts 3 Posters 2.2k Views 1 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.
  • G Garza

    Hi,

    I want to add 4 QCameras on one window and record video. I manage to do it with one camera, but when trying to add the second one I get an error on the constructor of the QCamera:

    usbcam.cpp:18:14: error: no viable overloaded '='
    qcamera.h:251:5: note: candidate function not viable: no known conversion from 'QCamera *' to 'const QCamera' for 1st argument; dereference the argument with *
    qglobal.h:436:12: note: expanded from macro 'Q_DISABLE_COPY'

    Can someone give me a hint whats my issue. Thanks

    jsulmJ Online
    jsulmJ Online
    jsulm
    Lifetime Qt Champion
    wrote on last edited by
    #2

    @Garza said in add several QCameras on one window:

    usbcam.cpp:18:14: error: no viable overloaded '='

    Please show your code. It looks like you're trying to copy a QCamera instance.

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

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

      Hi,

      Looks like you are trying to do something like QCamera camera = new QCamera() which is wrong as the error states.

      If something else, like @jsulm wrote, please show your code.

      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
      • G Offline
        G Offline
        Garza
        wrote on last edited by
        #4

        this is on the .h file:
        QCamera* cameraFL, cameraFR;//, cameraRL, cameraRR;
        QCameraViewfinder* viewfinderFL, viewfinderFR;//, viewfinderRL, viewfinderRR;
        QMediaRecorder* recorderFL, recorderFR;//, recorderRL, recorderRR;
        QVideoEncoderSettings settingsFL;//s, settingsFR, settingsRL, settingsRR;

        This on the cpp file:
        cameraFL = new QCamera("/dev/video0");
        viewfinderFL = new QCameraViewfinder();
        cameraFL->setViewfinder(viewfinderFL);
        ui->gridLayout->addWidget(viewfinderFL);
        cameraFL->start();

        cameraFR = new QCamera("/dev/video2");
        
        jsulmJ 1 Reply Last reply
        0
        • G Garza

          this is on the .h file:
          QCamera* cameraFL, cameraFR;//, cameraRL, cameraRR;
          QCameraViewfinder* viewfinderFL, viewfinderFR;//, viewfinderRL, viewfinderRR;
          QMediaRecorder* recorderFL, recorderFR;//, recorderRL, recorderRR;
          QVideoEncoderSettings settingsFL;//s, settingsFR, settingsRL, settingsRR;

          This on the cpp file:
          cameraFL = new QCamera("/dev/video0");
          viewfinderFL = new QCameraViewfinder();
          cameraFL->setViewfinder(viewfinderFL);
          ui->gridLayout->addWidget(viewfinderFL);
          cameraFL->start();

          cameraFR = new QCamera("/dev/video2");
          
          jsulmJ Online
          jsulmJ Online
          jsulm
          Lifetime Qt Champion
          wrote on last edited by jsulm
          #5

          @Garza said in add several QCameras on one window:

          QCamera* cameraFL, cameraFR;

          cameraFR is not a pointer here. Change to

          QCamera*        cameraFL, *cameraFR;
          

          Or better

          QCamera* cameraFL;
          QCamera* cameraFR;
          

          to avoid such confusion.

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

          G 1 Reply Last reply
          3
          • jsulmJ jsulm

            @Garza said in add several QCameras on one window:

            QCamera* cameraFL, cameraFR;

            cameraFR is not a pointer here. Change to

            QCamera*        cameraFL, *cameraFR;
            

            Or better

            QCamera* cameraFL;
            QCamera* cameraFR;
            

            to avoid such confusion.

            G Offline
            G Offline
            Garza
            wrote on last edited by
            #6

            @jsulm Thanks it worked.

            1 Reply Last reply
            0
            • G Offline
              G Offline
              Garza
              wrote on last edited by
              #7

              I have managed to add the cameras on one window and are working, I have used a grid of 2x2, now I want to add a text label below each camera. This sounds easy but I havent been able to make it, this is my code:

              cameraFL = new QCamera("/dev/video2");
              viewfinderFL = new QCameraViewfinder();
              cameraFL->setViewfinder(viewfinderFL);
              grid->addWidget(viewfinderFL,0,0,2,2);
              recorderFL =new QMediaRecorder(cameraFL,this);
              settingsFL = recorderFL->videoSettings();
              settingsFL.setResolution(640,480);
              settingsFL.setQuality(QMultimedia::VeryHighQuality);
              settingsFL.setFrameRate(10.0);
              recorderFL->setVideoSettings(settingsFL);
              recorderFL->setContainerFormat("mp4");
              cameraFL->setCaptureMode(QCamera::CaptureVideo);
              cameraFL->start();

              This is for one camera, I have read I have to use a QVBoxLayout inside the grid and then add the camera and the label, but I havent been able to accomplish this. Thanks for the support.

              jsulmJ 1 Reply Last reply
              0
              • G Garza

                I have managed to add the cameras on one window and are working, I have used a grid of 2x2, now I want to add a text label below each camera. This sounds easy but I havent been able to make it, this is my code:

                cameraFL = new QCamera("/dev/video2");
                viewfinderFL = new QCameraViewfinder();
                cameraFL->setViewfinder(viewfinderFL);
                grid->addWidget(viewfinderFL,0,0,2,2);
                recorderFL =new QMediaRecorder(cameraFL,this);
                settingsFL = recorderFL->videoSettings();
                settingsFL.setResolution(640,480);
                settingsFL.setQuality(QMultimedia::VeryHighQuality);
                settingsFL.setFrameRate(10.0);
                recorderFL->setVideoSettings(settingsFL);
                recorderFL->setContainerFormat("mp4");
                cameraFL->setCaptureMode(QCamera::CaptureVideo);
                cameraFL->start();

                This is for one camera, I have read I have to use a QVBoxLayout inside the grid and then add the camera and the label, but I havent been able to accomplish this. Thanks for the support.

                jsulmJ Online
                jsulmJ Online
                jsulm
                Lifetime Qt Champion
                wrote on last edited by
                #8

                @Garza Create a QWidget for each camera, put a layout on it, put camera and label on that widget and then put that widget into the grid.

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

                1 Reply Last reply
                3
                • G Offline
                  G Offline
                  Garza
                  wrote on last edited by
                  #9

                  @jsulm said in add several QCameras on one window:

                  put camera and label on t

                  Thanks, it worked.

                  1 Reply Last reply
                  0
                  • G Offline
                    G Offline
                    Garza
                    wrote on last edited by Garza
                    #10

                    Hi,
                    I have managed to make the 4 webcams on a Main Window and it works, now I am porting this to my GUI and this webcam window should appear when I press a button wit a camera Icon.

                    My questions is:
                    -On the NewWindow code I could set::
                    this->setCentralWidget(w);
                    but now I get the message:
                    error: no member named 'setCentralWidget' in 'Webcam'
                    I added the code as a Qt Designer Form Class and then called the class when I pressed the button and it works but the widget is not centered to the new window and also does not change size when I resize the window.
                    Can you give a hint ? thanks

                    jsulmJ 1 Reply Last reply
                    0
                    • G Garza

                      Hi,
                      I have managed to make the 4 webcams on a Main Window and it works, now I am porting this to my GUI and this webcam window should appear when I press a button wit a camera Icon.

                      My questions is:
                      -On the NewWindow code I could set::
                      this->setCentralWidget(w);
                      but now I get the message:
                      error: no member named 'setCentralWidget' in 'Webcam'
                      I added the code as a Qt Designer Form Class and then called the class when I pressed the button and it works but the widget is not centered to the new window and also does not change size when I resize the window.
                      Can you give a hint ? thanks

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

                      @Garza said in add several QCameras on one window:

                      setCentralWidget

                      This is only available in QMainWindow. If you use QWidget there is no need for setCentralWidget.

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

                      G 1 Reply Last reply
                      1
                      • jsulmJ jsulm

                        @Garza said in add several QCameras on one window:

                        setCentralWidget

                        This is only available in QMainWindow. If you use QWidget there is no need for setCentralWidget.

                        G Offline
                        G Offline
                        Garza
                        wrote on last edited by
                        #12

                        @jsulm and how do I make the widget to resize when this new window is resized?

                        jsulmJ 1 Reply Last reply
                        0
                        • G Garza

                          @jsulm and how do I make the widget to resize when this new window is resized?

                          jsulmJ Online
                          jsulmJ Online
                          jsulm
                          Lifetime Qt Champion
                          wrote on last edited by
                          #13

                          @Garza You put it in a layout

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

                          1 Reply Last reply
                          3

                          • Login

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