Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. 3rd Party Software
  4. How to display opencv output window inside a Label or Widget in form.ui

How to display opencv output window inside a Label or Widget in form.ui

Scheduled Pinned Locked Moved Solved 3rd Party Software
3 Posts 2 Posters 11.0k 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.
  • P Offline
    P Offline
    pj0909
    wrote on 27 Mar 2017, 14:31 last edited by
    #1

    Hi all,

    I am new to Qt and opencv, I am programming a graphical interface to record a video through webcam using opencv libraries in Qt. Problem is when I push the start recording button on my interface, a new window gets launched and I dont want that. It should be like after pressing the start recording button it should display the opencv output of webcam inside a Label or Widget on my graphical interface and not on a newly launched window.

    I am using Qt 5.8 on windows 10. Below is the while loop which captures the frame and displays in a window

    while (1)
                {
    
                    Mat frame;
    
                    bool bSuccess = cap.read(frame); // read a new frame from video
    
                    if (!bSuccess) 
                   {
                         cout << "ERROR: Cannot read a frame from video file" << endl;
                         break;
                    }
    
                     oVideoWriter.write(frame); 
                     
    
                    imshow("MyVideo", frame); //this line launches a new output window
    
    
                   if (waitKey(10) == 27) 
                   {
    
                        cout << "esc key is pressed by user" << endl;
                        return ;
                        
                    }
                }
    

    Can anyone please guide me on how can I embed the opencv output window inside a Label or Widget in my form.ui.

    Thank you for your time and knowledge.

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 27 Mar 2017, 22:57 last edited by
      #2

      Hi,

      AFAIK, you can't direclty.

      One way to do it is described here.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      P 1 Reply Last reply 31 Mar 2017, 15:04
      1
      • S SGaist
        27 Mar 2017, 22:57

        Hi,

        AFAIK, you can't direclty.

        One way to do it is described here.

        P Offline
        P Offline
        pj0909
        wrote on 31 Mar 2017, 15:04 last edited by
        #3

        @SGaist I tried with your suggested link and it works. Thank you so much

        1 Reply Last reply
        0

        3/3

        31 Mar 2017, 15:04

        • Login

        • Login or register to search.
        3 out of 3
        • First post
          3/3
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved