I have a window that I open just like the OpenCV tutorials show but I want to be able to close the window and do other things in my program. The image displays correctly but when the call to destroyWindow is made it seems to do nothing and just moves to the next line of code. I have also tried destroyAllWindow() as well with the same result. Most of the questions relating to this that I have found are for C, or they just say use destroyWindow() but that is not working for me.
#include <iostream>
#include <string>
#include "opencv2/core/core.hpp"
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/highgui/highgui.hpp>//FOR TESTING
void MyPause(std::string msg){
if(msg != ""){
std::cout << "[+] " << msg << std::endl;
}
std::cout << "Press enter to continue" << std::endl;
std::cin.get();
}
void DisplayMat(cv::Mat img){
cv::namedWindow( "Input", cv::WINDOW_AUTOSIZE );// Create a window for display.
cv::imshow( "Input", img );
cv::waitKey(0);
cv::destroyWindow("Input");
return;
}
std::string filename = "/home/nedwards/Code/projectFiles/testMedia/myYellow.jpg";
int main(){
DisplayMat(som.inputImg);//just assume that som.input is a correctly opend Mat... it is!
MyPause("END OF MAIN");
return 0;
}