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