Results 1 to 3 of 3

Thread: OpenCV --> window reopens while webcam outputing..How to stop it?

  1. #1
    Join Date
    Jul 2010
    Location
    /home/hakermania/
    Posts
    233
    Thanks
    129
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Angry OpenCV --> window reopens while webcam outputing..How to stop it?

    That's the code:
    Qt Code:
    1. #include "opencv/highgui.h"
    2. int main( int argc, char** argv ) {
    3. /* // Capture the Image from the webcam
    4.   CvCapture *pCapturedImage = cvCreateCameraCapture(0);
    5.  
    6.   // Get the frame
    7.   IplImage *pSaveImg = cvQueryFrame(pCapturedImage);
    8.  
    9.   // Save the frame into a file
    10.   cvSaveImage("test.jpg" ,pSaveImg);
    11.  
    12. */
    13.  
    14.  
    15. cvNamedWindow( "Example2", CV_WINDOW_AUTOSIZE );
    16.  
    17. CvCapture* capture = cvCreateCameraCapture(0) ;
    18. IplImage* frame;
    19.  
    20. while(1) {
    21. frame = cvQueryFrame( capture );
    22. if( !frame ) break;
    23. cvShowImage( "Example2", frame );
    24. char c = cvWaitKey(33);
    25. if( c == 27 ) break;
    26.  
    27. }
    28. cvReleaseCapture( &capture );
    29. cvDestroyWindow( "Example2" );
    30.  
    31. }
    To copy to clipboard, switch view to plain text mode 
    It actually shows the webcam video till it gets [Esc]
    This is OK but when I manually close the window from the X button then it reopens...How can i avoid this from being done?
    When you 're trying to help somebody in the newbie section, don't forget that he is a newbie. Be specific and give examples.

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: OpenCV --> window reopens while webcam outputing..How to stop it?

    My money is on cvShowImage() unhiding the window, which still exists when "closed" it is just hidden until the cvNamedWindow object is destroyed. As for how you break out of the loop when the cvNamedWindow is "closed": you probably should ask this question in an OpenCV forum because it has nothing to do with Qt.

  3. #3
    Join Date
    Mar 2010
    Location
    Brazil
    Posts
    39
    Thanks
    2
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: OpenCV --> window reopens while webcam outputing..How to stop it?

    Hey, look this example http://qt-apps.org/content/show.php/...?content=89995

    The author put the captured video inside QMainWindow and you don't need the highgui.

Similar Threads

  1. Replies: 8
    Last Post: 18th March 2011, 11:27
  2. ¿How to stop thread that is capturing from a webcam?
    By JoseTlaseca in forum Qt Programming
    Replies: 8
    Last Post: 28th August 2008, 04:45
  3. use Webcam
    By sabeesh in forum Qt Programming
    Replies: 1
    Last Post: 21st August 2007, 07:52
  4. Stop window moving when clicking LMB
    By steg90 in forum Qt Programming
    Replies: 11
    Last Post: 11th June 2007, 10:59
  5. Ctrl key to allow user to stop docking a window
    By irudkin in forum Qt Programming
    Replies: 2
    Last Post: 7th June 2007, 04:42

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.