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



  • 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


  • Lifetime Qt Champion

    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.



  • 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.



  • @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.


  • Lifetime Qt Champion

    Can you explain what exactly you are trying to achieve ?

    What should your application do ?



  • @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.


  • Lifetime Qt Champion

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


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.