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. Qlabel in video not showing - Raspberry pi 4 Opencv 4.1.0
Forum Updated to NodeBB v4.3 + New Features

Qlabel in video not showing - Raspberry pi 4 Opencv 4.1.0

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 2 Posters 388 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.
  • B Offline
    B Offline
    bknhatice
    wrote on last edited by
    #1

    I installed Opencv 4.1.0 and Qt Creator on Rpi 4. I created a gui with a button and a label. When the button is clicked, I want the video to play in the label. The codes I use for this are:
    VideoCapture cap(“/home/users/video.mp4”);
      if(!cap.isOpened()){
         cout << "Error opening video stream or file" << endl;
         return -1;
      }

    while(1)
    {
    	Mat frame;
    	cap >> frame;
    	if (frame.empty())
    

    break;

    	Qimage img = Qimage((uchar*) frame.data, frame.cols, frame.rows, frame.step, Qimage::Format_RGB888);
    	ui→label→setPixmap(QPixmap::fromImage(img));
    	char c = (char) waitKey(25);
    	if(c==27)
    		break;
    }
    cap.release();
    destroyAllWindows();
    

    No video is shown in Label. But imshow (“Frame”, frame); When I add the command line, the video is displayed in the label.
    How can I show the video in qlabel ?

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

      Hi,

      You are blocking the event loop with your tight loop as well as your wait key.

      Use a Timer that will read your file at regular interval since you anyway wait for 25ms.

      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
      1
      • B Offline
        B Offline
        bknhatice
        wrote on last edited by
        #3

        ui->label->repaint()

        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