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. Displaying live video feed in openGL 2D
Forum Updated to NodeBB v4.3 + New Features

Displaying live video feed in openGL 2D

Scheduled Pinned Locked Moved General and Desktop
6 Posts 2 Posters 2.8k 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 Offline
    G Offline
    gpuckett54
    wrote on last edited by
    #1

    I am developing a application that will run only on a Windows 7 machine. It has a split screen with one half of the screen displays an interactive map and the other half displaying the live feed from a camera connected to the computer. I have used QCamera and that works fine. However the map used openGL. When I place buttons over the screen they are rendered differently over the map side than over the video side. I can't change the map side so I need to change the video side to use openGL so I can generate decent looking buttons. Plus any performance improvement that openGL might provide is a desired result.

    I am recently new to Qt and C++ and completely new to any of the OpenGL applications. I really could use some example code of displaying video using OpenGL. The vast majority of example code I can find is primarily meant to show how to do 3D graphics programming. And those get caught up in the complexities of generating the objects that are being displayed. Even the 2D examples I have found is so difficult to understand I struggle and mostly just come away understanding less than before.

    Any help is definitely appreciated.

    1 Reply Last reply
    0
    • G Offline
      G Offline
      gpuckett54
      wrote on last edited by
      #2

      I tried the following code:

      @QByteArray cameraDevice = QCamera::availableDevices()[0];
      camera = new QCamera(cameraDevice);

      QGraphicsScene *scene = new QGraphicsScene();
      ui->cameraView->setScene(scene);
      
      QGraphicsVideoItem *item = new QGraphicsVideoItem();
      camera->setViewfinder(item);
      ui->cameraView->scene()->addItem(item);
      ui->cameraView->show();
      camera->start();@
      

      cameraView in the ui is a QGraphicsView. I get the error

      no video surface, cant start

      1 Reply Last reply
      0
      • JKSHJ Offline
        JKSHJ Offline
        JKSH
        Moderators
        wrote on last edited by
        #3

        Hi,

        Let's go back to your original problem, to avoid the "XY Problem":http://meta.stackexchange.com/questions/66377/what-is-the-xy-problem

        So, your root issue is that you can't get the buttons to display the same way on both sides. Can you post your code to show how you tried to do that?

        Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

        1 Reply Last reply
        0
        • G Offline
          G Offline
          gpuckett54
          wrote on last edited by
          #4

          I have developed a new solution for the video side. I am now using QGraphicsVideoItem and QGraphicsScene to show the video stream. So that will end up resolving the issue. The video itself is also behaving much better. I also resolved the button issue for now by not overlaying the graphics. They now have their own area at the bottom of the screen. This is not how I want it to end up but it demos much better.

          This has created a rather nasty problem. Where the video and map worked appropriately before when using QCamera I now have a problem with performance. The new video works great. I even built a test application where I could place up to 4 instances of the video on a screen and they worked great. When I changed the real application to use the new video player it just doesn't work. The video is blank and the map does not have a steady movement. It will move for a few seconds then freeze for a few seconds before moving again.

          I am trying to determine if there is a problem because I have two graphics processes competing for graphics resources or there is a problem with too much processing in the GUI thread. It only started when I changed to the new video player.

          Is the first one even a possibility? I don't know how to make that determination. The mapping is being generated by a 3rd party API that I have little control over at that level.

          I am in the process of attempting to split up my code so some of it can run in a separate thread. But I can't see that there is a lot I can split out that would really make a difference.

          I can provide code but not sure what would help.

          1 Reply Last reply
          0
          • G Offline
            G Offline
            gpuckett54
            wrote on last edited by
            #5

            I have another forum thread regarding another aspect of this project. The issues have begun to merge into related problems. I will be using the other thread to discuss these issues. I appreciate all interest in helping get me through this project. That thread is "Here":http://qt-project.org/forums/viewthread/46241/

            1 Reply Last reply
            0
            • JKSHJ Offline
              JKSHJ Offline
              JKSH
              Moderators
              wrote on last edited by
              #6

              [quote] I also resolved the button issue for now by not overlaying the graphics. They now have their own area at the bottom of the screen. This is not how I want it to end up but it demos much better.
              This has created a rather nasty problem. Where the video and map worked appropriately before when using QCamera I now have a problem with performance.[/quote]Since you are no longer attempting to overlay the buttons, would it be possible now to switch back to QCamera?

              [quote]Is the first one even a possibility? I don’t know how to make that determination. The mapping is being generated by a 3rd party API that I have little control over at that level.[/quote]I'm not sure. I don't have experience with OpenGL or video-within-QGraphicsView; everything I know so far is from reading basic theory.

              If you'd still like help on the graphics performance issue, I recommend starting a new thread and posting a stripped-down version of your code that only contains the map display and the video display. (It's hard to tell what's going on based on high-level descriptions alone)

              Good luck!

              Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

              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