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:

Qt Code:
  1. while (1)
  2. {
  3.  
  4. Mat frame;
  5.  
  6. bool bSuccess = cap.read(frame); // read a new frame from video
  7.  
  8. if (!bSuccess)
  9. {
  10. cout << "ERROR: Cannot read a frame from video file" << endl;
  11. break;
  12. }
  13.  
  14. oVideoWriter.write(frame);
  15.  
  16.  
  17. imshow("MyVideo", frame); //this line launches a new output window
  18.  
  19.  
  20. if (waitKey(10) == 27)
  21. {
  22.  
  23. cout << "esc key is pressed by user" << endl;
  24. return ;
  25.  
  26. }
  27. }
To copy to clipboard, switch view to plain text mode 

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

Thank you for your time and knowledge.