Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version
        } else {
            cv::imshow(path, src);
            while(cv::waitKey(1) != 27); //if ESC is not pressed /* if esc is pressed cv window GUI become close */
            src.release(); /* if src is released  the cv window become close */
            retStatus = 0; /* if esc = > retstatus 0 */
        }

You need to show the image in other type of window GUI ... like openGL or Qt, GTK, and use relative command to close the image without closing the program .... If use cv::imshow opencv open cv-window and is not possible to close it without close the main loop ... you need at last 2 loop ... If cv-loop is cloose the secdone (not cv but std c++ for example, or Qt or other ..) survive!! The best approach is open the cv image (with other cv operation) in a thread and show the result in GUI thread of some other tipe of gui support ... In these way You have 2 loop ...

In your case You have only "main" thread .... and if:

        if(!src.data) { //check for validity of the file /* if is false */
            std::cout << "File is corrupted!" << std::endl;
        } else { /* is false in case of esc  => go out of main thread */
            cv::imshow(path, src);
            while(cv::waitKey(1) != 27); //if ESC is not pressed
            src.release();
            retStatus = 0;
        }

I hope I explained myself, my English is faltering ...

Possibility of grabbing "X" on windows depends of your SO ... for example in linux ubuntu, debian (std install) It is possible but not so easy because WM He prefers to have priority control... In windows SO maybe more easy ...

regards giorgio