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. CameraBin error: "Internal data flow error." on tab switching
QtWS25 Last Chance

CameraBin error: "Internal data flow error." on tab switching

Scheduled Pinned Locked Moved Solved General and Desktop
cameratab switchingcamerabin
8 Posts 2 Posters 4.3k 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.
  • G Offline
    G Offline
    gsharma
    wrote on last edited by gsharma
    #1

    Hi,

    I have requirement to write an application which have multiple camera and same camera can be shown on different tabs of tabbed widget. It works fine unless switch the tab. It reproduced below error & live video stops on tab:

    CameraBin error: "Internal data flow error."
    CameraBin error: "Internal data flow error."

    Here is the test code I have written:

    Form::Form(QWidget *parent) :
     QGraphicsView(parent),
      ui(new Ui::Form)
     {
       ui->setupUi(this);
    
       QList<QCameraInfo>  camLst = QCameraInfo::availableCameras();
       camera = new QCamera(camLst.at(0));
       view1 = new QGraphicsView(this);
       scene1 = new QGraphicsScene(view1);
    
       view2 = new QGraphicsView(this);
       scene2 = new QGraphicsScene(view2);
      view3 = new QGraphicsView(this);
      scene3 = new QGraphicsScene(view3);
      ui->tabWidget->addTab(view1, "View1");
      ui->tabWidget->addTab(view2, "View2");
      ui->tabWidget->addTab(view3, "View3");
    
      videoItem = new QGraphicsVideoItem();
      videoItem->setSize(QSize(SIZEX, SIZEY));
    
      view1->setScene(scene1);
      scene1->addItem(videoItem);
    
      view2->setScene(scene2);
      view3->setScene(scene3);
      camera->setViewfinder(videoItem);
      camera->start();
      flag1 = false; flag2 = false; flag3 = false;
     view1->setSceneRect(0, 0, SIZEX, SIZEY);
     scene1->setSceneRect(0, 0, SIZEX, SIZEY);
    }
    
    void Form::on_tabWidget_currentChanged(int index)
    {
    if (index == 0)
    {
        if (flag2)
        {
            scene2->removeItem(videoItem);
            flag2 = false;
        }
        if (flag3)
        {
            scene3->removeItem(videoItem);
            flag3 = false;
        }
        if (flag1 == false && videoItem != NULL)
        {
            scene1->addItem(videoItem);
           // scene1->addItem(graphItem);
            flag1 = true;
        }
    }
    else if (index == 1)
    {
        /*if (flag1)
        {
            scene1->removeItem(videoItem);
            scene1->removeItem(graphItem);
            flag1 = false;
        }
        if (flag3)
        {
            scene3->removeItem(videoItem);
            flag3 = false;
        }
        scene2->addItem(videoItem);
        flag2 = true;*/
    }
    else
    {
        if (flag1)
        {
            scene1->removeItem(videoItem);
            scene1->removeItem(graphItem);
            flag1 = false;
        }
        if (flag2)
        {
            scene2->removeItem(videoItem);
            flag2 = false;
        }
        scene3->addItem(videoItem);
        flag3 = true;
       }
    }
    

    As soon as I moved to tab "View2" from "View1" I get the camera bin error. Then After going back to tab "View1" live video from camera has stopped.

    Please suggest where I am doing wrong. I am using Qt-5.6.2 build from source.

    Thank you

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

      Hi and welcome to devnet,

      Unless you are doing something particular, you don't need two scene, you can have several QGraphicsView looking at the same scene. I'd rather test that before searching further on the multimedia part.

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

      G 1 Reply Last reply
      0
      • G Offline
        G Offline
        gsharma
        wrote on last edited by
        #3

        Problem comes even if I show hide the tabwidget. However if I stop camera before tab switch & then start camera on re-switch, then its working properly.

        Please suggest other solutions for the same.

        1 Reply Last reply
        0
        • SGaistS SGaist

          Hi and welcome to devnet,

          Unless you are doing something particular, you don't need two scene, you can have several QGraphicsView looking at the same scene. I'd rather test that before searching further on the multimedia part.

          G Offline
          G Offline
          gsharma
          wrote on last edited by
          #4

          @SGaist, I agree but I have to use different scene in each tab as I have to show only video on some tabs and on others tabs I have to draw additional shaped over video.

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

            Can you explain what exactly you are trying to achieve ?

            What should your application do ?

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

            G 1 Reply Last reply
            0
            • SGaistS SGaist

              Can you explain what exactly you are trying to achieve ?

              What should your application do ?

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

              @SGaist, Thank you for your support. My application has multiple cameras and each camera footage is shown on separate tabs. There is a tab named "ALL" where footage of all cameras are shown in split layout. Requirement is that user should be able select some points over video footage in single camera view and selected points should be highlighted with circle with color- red, green, black etc. These selected points will be used to set some settings over camera. Once setting done circles will be removed. This can be done repeatedly.

              Hence I have used separate scene in each tab.

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

                Then I wonder if you shouldn't rather use something like the QtGStreamer project to have a lower level control on your cameras.

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

                  Solved problem by stopping/starting camera while tab switching.

                  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