Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Special Interest Groups
  3. C++ Gurus
  4. Hi,I'm viewing 2 camera video simultanesly and recording them on linux system, but both camera lags(slow) after 3sec and I tried to put recording in Qtconcurrent::run(). but also both camera lags(slow)
Forum Updated to NodeBB v4.3 + New Features

Hi,I'm viewing 2 camera video simultanesly and recording them on linux system, but both camera lags(slow) after 3sec and I tried to put recording in Qtconcurrent::run(). but also both camera lags(slow)

Scheduled Pinned Locked Moved Unsolved C++ Gurus
14 Posts 4 Posters 3.1k 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.
  • T thippu

    Hi,I'm viewing 2 camera video simultanesly and recording them on linux system,
    but both camera lags(slow) after 3sec and I tried to put recording in Qtconcurrent::run().
    but also both camera lags(slow)
    plz give me solution.

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

    @thippu How is anybody supposed to give you a solution if you do not provide much information?
    Does your app leak memory?

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

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

      Hi,

      To add to @jsulm, please change your thread title to something meaningful. You won't get much attention with what you wrote there.

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

        @jsulm , @SGaist ,Im sorry about title.
        @jsulm there is no error.

        here is the code plz help me:

        //function kept in Qtconcurrent and thread calls rec1() and function will record and same for cam2 record :
        connect(ui->radio_cam1_rec_on,&QAbstractButton::clicked,this,={if(camera1){
        QtConcurrent::run(=
        {rec1();
        });
        }});

        //rec1()
        definition is:
        {
        ui->radio_cam1_rec_on->setEnabled(0);
        ui->radio_cam1_rec_off->setEnabled(1);
        QString filename = "thippu" + QDateTime::currentDateTime().toString("dd.MM.yy-h-m-s");
        QString name="/home/mmrfic/Desktop/RECORD/"+filename+".mp4";
        qDebug()<< mediarecorder1->setOutputLocation(QUrl::fromLocalFile(name));
        mediarecorder1->record();
        }

        @SGaist @jsulm , Can we pass below function to QtConcurrent thread
        below function is to view the camera
        code:
        void MainWindow::setCameratoview1(const QCameraInfo cam)
        { delete camera1;

            ui->radio_cam1_on->setEnabled(0);
            ui->radio_cam1_off->setEnabled(1);
            ui->radio_cam1_rec_off->setEnabled(0);
             ui->radio_cam1_rec_on->setEnabled(1);
        
        camera1=new QCamera(cam);
        camera1->setViewfinder(ui->camview1);
        mediarecorder1=new QMediaRecorder(camera1);
        QVideoEncoderSettings settings1 = mediarecorder1->videoSettings();
        settings1.setResolution(640,480);
        
        settings1.setQuality(QMultimedia::VeryHighQuality);
        settings1.setFrameRate(30.0);
        mediarecorder1->setVideoSettings(settings1);
         camera1->setCaptureMode(QCamera::CaptureVideo);
            camera1->start();
        

        }

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

          No you can't. You are trying to modify GUI objects from another thread than the GUI thread which is wrong and forbidden.

          You might also be trying to write twice in the same file and from the looks of it, you'd might even be deleting your camera objects while setting them up.

          Also, recording an mp4 file is a pretty heavy task, did you benchmark your computer to be sure you can support recording two streams at once ?

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

          T 1 Reply Last reply
          1
          • SGaistS SGaist

            No you can't. You are trying to modify GUI objects from another thread than the GUI thread which is wrong and forbidden.

            You might also be trying to write twice in the same file and from the looks of it, you'd might even be deleting your camera objects while setting them up.

            Also, recording an mp4 file is a pretty heavy task, did you benchmark your computer to be sure you can support recording two streams at once ?

            T Offline
            T Offline
            thippu
            wrote on last edited by
            #6

            @SGaist I did take bench mark and I'm using highend system lenovo carbon x1.
            May I know the best and light recording file otherthan mp4 format?

            jsulmJ 1 Reply Last reply
            0
            • T thippu

              @SGaist I did take bench mark and I'm using highend system lenovo carbon x1.
              May I know the best and light recording file otherthan mp4 format?

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

              @thippu What about fixing these issues first mentioned by @SGaist :
              "You are trying to modify GUI objects from another thread than the GUI thread which is wrong and forbidden.

              You might also be trying to write twice in the same file and from the looks of it, you'd might even be deleting your camera objects while setting them up."
              ?

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

              T 1 Reply Last reply
              0
              • jsulmJ jsulm

                @thippu What about fixing these issues first mentioned by @SGaist :
                "You are trying to modify GUI objects from another thread than the GUI thread which is wrong and forbidden.

                You might also be trying to write twice in the same file and from the looks of it, you'd might even be deleting your camera objects while setting them up."
                ?

                T Offline
                T Offline
                thippu
                wrote on last edited by
                #8

                @jsulm You might also be trying to write twice in the same file and from the looks of it, you'd might even be deleting your camera objects while setting them up."
                ? ans: No twice write rec2() function got diffrent file name so,that is not a problem for me.
                "You are trying to modify GUI objects from another thread than the GUI thread which is wrong and forbidden. ans: I want there should no lag in cameras view thats y went to do in diffrent thread but I dono how to avoid lags
                plz help me

                jsulmJ 1 Reply Last reply
                0
                • T thippu

                  @jsulm You might also be trying to write twice in the same file and from the looks of it, you'd might even be deleting your camera objects while setting them up."
                  ? ans: No twice write rec2() function got diffrent file name so,that is not a problem for me.
                  "You are trying to modify GUI objects from another thread than the GUI thread which is wrong and forbidden. ans: I want there should no lag in cameras view thats y went to do in diffrent thread but I dono how to avoid lags
                  plz help me

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

                  @thippu Never modify any GUI related classes from other thread than GUI thread. From other threads you should emit signals if something needs to be changed in the GUI.

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

                  T 1 Reply Last reply
                  0
                  • mrdebugM Offline
                    mrdebugM Offline
                    mrdebug
                    wrote on last edited by mrdebug
                    #10

                    Are you using a embedded device?
                    With a Raspberry Pi I can watch only one camera without to have problem.

                    I'm watching 4 videocameras with a Pentium 4 and more than 8 with a Intel Core 2 duo, with motion detection ...

                    To do this I'm using the FFMpeg libs for the rtsp cameras and OpenCV for the /dev/video* cameras.

                    I suggest you to use a dedicated object (thread) for each camera and, if you want to watch and not only to store, to emit an event for each frame.

                    Please considered that if you are resizing the frames that it is very cpu expensive activity.

                    Need programmers to hire?
                    www.labcsp.com
                    www.denisgottardello.it
                    GMT+1
                    Skype: mrdebug

                    T 1 Reply Last reply
                    1
                    • mrdebugM mrdebug

                      Are you using a embedded device?
                      With a Raspberry Pi I can watch only one camera without to have problem.

                      I'm watching 4 videocameras with a Pentium 4 and more than 8 with a Intel Core 2 duo, with motion detection ...

                      To do this I'm using the FFMpeg libs for the rtsp cameras and OpenCV for the /dev/video* cameras.

                      I suggest you to use a dedicated object (thread) for each camera and, if you want to watch and not only to store, to emit an event for each frame.

                      Please considered that if you are resizing the frames that it is very cpu expensive activity.

                      T Offline
                      T Offline
                      thippu
                      wrote on last edited by
                      #11

                      @mrdebug Thnx for the replay and suggestions
                      please send me example code or code which u have developed to my email : thippeswamydcts@gmail.com
                      for this : "I suggest you to use a dedicated object (thread) for each camera and, if you want to watch and not only to store, to emit an event for each frame."

                      1 Reply Last reply
                      0
                      • jsulmJ jsulm

                        @thippu Never modify any GUI related classes from other thread than GUI thread. From other threads you should emit signals if something needs to be changed in the GUI.

                        T Offline
                        T Offline
                        thippu
                        wrote on last edited by
                        #12

                        @jsulm hey is there any source, i can get to understand the gui thread like how to those gui threads are there and what we shouldnot do.

                        jsulmJ 1 Reply Last reply
                        0
                        • T thippu

                          @jsulm hey is there any source, i can get to understand the gui thread like how to those gui threads are there and what we shouldnot do.

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

                          @thippu http://doc.qt.io/qt-5/threads-technologies.html
                          https://doc.qt.io/qt-5.10/thread-basics.html
                          https://mayaposch.wordpress.com/2011/11/01/how-to-really-truly-use-qthreads-the-full-explanation/

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

                          T 1 Reply Last reply
                          0
                          • jsulmJ jsulm

                            @thippu http://doc.qt.io/qt-5/threads-technologies.html
                            https://doc.qt.io/qt-5.10/thread-basics.html
                            https://mayaposch.wordpress.com/2011/11/01/how-to-really-truly-use-qthreads-the-full-explanation/

                            T Offline
                            T Offline
                            thippu
                            wrote on last edited by
                            #14

                            @jsulm Thank u so much

                            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