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. Texting and drawing Shapes over webcam display

Texting and drawing Shapes over webcam display

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 1 Posters 466 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.
  • S Offline
    S Offline
    star673
    wrote on last edited by star673
    #1

    Hello all,
    I would like to make a an application that gets an camera stream from webcam("/dev/video") and put some text and shapes over this camera stream. I could draw shapes and put some text over available video on my machine. I have used QGraphicssView and QGraphicsScene. for the shapes and I have play the video with QMediaPlayer.
    Now I would like to get streamin video from my camera instead of available videos. I have used QCamera fro getting the stream and I have used QVideoWidget for rendering. The problem is that I could not use the QGraphicsScene and QGraphicsView for drawing shapes. I have tried to use QGraphicsView ove QVideoWidget but I cant make the QGraphicsView instance transparent.
    So far, I have done it with the video like below. It is constructor of my mainwindow. Now, I would like to use webcam camera streaming instead of video.

         graphicsView = new QGraphicsView(this);
    
          setCentralWidget(graphicsView);
          scene = new QGraphicsScene(graphicsView);
    
          graphicsView->setScene(scene);
          item = new QGraphicsVideoItem;
    
      
          player = new QMediaPlayer;
    
          player->setVideoOutput(item);
          player->setMedia(QUrl::fromLocalFile("/home/pc/test.mp4"));
    
         textItem = new QGraphicsTextItem("TEST");
          textItem->setPos(250,10);
        textItem->setDefaultTextColor(QColor(255,0,0));
    
        graphicsView->scene()->addItem(item);
    
    
        scene->addItem(textItem);
        player->play();
         showMaximized();
    
    

    How can I text and raw shapes over streaming video? I expect to hear an idea about the hierarchy. Thanks for helping.

    S 2 Replies Last reply
    0
    • S star673

      Hello all,
      I would like to make a an application that gets an camera stream from webcam("/dev/video") and put some text and shapes over this camera stream. I could draw shapes and put some text over available video on my machine. I have used QGraphicssView and QGraphicsScene. for the shapes and I have play the video with QMediaPlayer.
      Now I would like to get streamin video from my camera instead of available videos. I have used QCamera fro getting the stream and I have used QVideoWidget for rendering. The problem is that I could not use the QGraphicsScene and QGraphicsView for drawing shapes. I have tried to use QGraphicsView ove QVideoWidget but I cant make the QGraphicsView instance transparent.
      So far, I have done it with the video like below. It is constructor of my mainwindow. Now, I would like to use webcam camera streaming instead of video.

           graphicsView = new QGraphicsView(this);
      
            setCentralWidget(graphicsView);
            scene = new QGraphicsScene(graphicsView);
      
            graphicsView->setScene(scene);
            item = new QGraphicsVideoItem;
      
        
            player = new QMediaPlayer;
      
            player->setVideoOutput(item);
            player->setMedia(QUrl::fromLocalFile("/home/pc/test.mp4"));
      
           textItem = new QGraphicsTextItem("TEST");
            textItem->setPos(250,10);
          textItem->setDefaultTextColor(QColor(255,0,0));
      
          graphicsView->scene()->addItem(item);
      
      
          scene->addItem(textItem);
          player->play();
           showMaximized();
      
      

      How can I text and raw shapes over streaming video? I expect to hear an idea about the hierarchy. Thanks for helping.

      S Offline
      S Offline
      star673
      wrote on last edited by
      #3

      @star673

      I have solved the video problem by using QGraphicsPixmapItem. I have added OpenCV library to my project and I have convert the OpenCV Mat object to pixmap and I have added that pixmap to QGraphicsView. Now I can put text on webcam video.

      1 Reply Last reply
      0
      • S star673

        Hello all,
        I would like to make a an application that gets an camera stream from webcam("/dev/video") and put some text and shapes over this camera stream. I could draw shapes and put some text over available video on my machine. I have used QGraphicssView and QGraphicsScene. for the shapes and I have play the video with QMediaPlayer.
        Now I would like to get streamin video from my camera instead of available videos. I have used QCamera fro getting the stream and I have used QVideoWidget for rendering. The problem is that I could not use the QGraphicsScene and QGraphicsView for drawing shapes. I have tried to use QGraphicsView ove QVideoWidget but I cant make the QGraphicsView instance transparent.
        So far, I have done it with the video like below. It is constructor of my mainwindow. Now, I would like to use webcam camera streaming instead of video.

             graphicsView = new QGraphicsView(this);
        
              setCentralWidget(graphicsView);
              scene = new QGraphicsScene(graphicsView);
        
              graphicsView->setScene(scene);
              item = new QGraphicsVideoItem;
        
          
              player = new QMediaPlayer;
        
              player->setVideoOutput(item);
              player->setMedia(QUrl::fromLocalFile("/home/pc/test.mp4"));
        
             textItem = new QGraphicsTextItem("TEST");
              textItem->setPos(250,10);
            textItem->setDefaultTextColor(QColor(255,0,0));
        
            graphicsView->scene()->addItem(item);
        
        
            scene->addItem(textItem);
            player->play();
             showMaximized();
        
        

        How can I text and raw shapes over streaming video? I expect to hear an idea about the hierarchy. Thanks for helping.

        S Offline
        S Offline
        star673
        wrote on last edited by
        #2

        @star673
        Is there anybody to answer?

        1 Reply Last reply
        0
        • S star673

          Hello all,
          I would like to make a an application that gets an camera stream from webcam("/dev/video") and put some text and shapes over this camera stream. I could draw shapes and put some text over available video on my machine. I have used QGraphicssView and QGraphicsScene. for the shapes and I have play the video with QMediaPlayer.
          Now I would like to get streamin video from my camera instead of available videos. I have used QCamera fro getting the stream and I have used QVideoWidget for rendering. The problem is that I could not use the QGraphicsScene and QGraphicsView for drawing shapes. I have tried to use QGraphicsView ove QVideoWidget but I cant make the QGraphicsView instance transparent.
          So far, I have done it with the video like below. It is constructor of my mainwindow. Now, I would like to use webcam camera streaming instead of video.

               graphicsView = new QGraphicsView(this);
          
                setCentralWidget(graphicsView);
                scene = new QGraphicsScene(graphicsView);
          
                graphicsView->setScene(scene);
                item = new QGraphicsVideoItem;
          
            
                player = new QMediaPlayer;
          
                player->setVideoOutput(item);
                player->setMedia(QUrl::fromLocalFile("/home/pc/test.mp4"));
          
               textItem = new QGraphicsTextItem("TEST");
                textItem->setPos(250,10);
              textItem->setDefaultTextColor(QColor(255,0,0));
          
              graphicsView->scene()->addItem(item);
          
          
              scene->addItem(textItem);
              player->play();
               showMaximized();
          
          

          How can I text and raw shapes over streaming video? I expect to hear an idea about the hierarchy. Thanks for helping.

          S Offline
          S Offline
          star673
          wrote on last edited by
          #3

          @star673

          I have solved the video problem by using QGraphicsPixmapItem. I have added OpenCV library to my project and I have convert the OpenCV Mat object to pixmap and I have added that pixmap to QGraphicsView. Now I can put text on webcam video.

          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