i using cmake , opencv c++ , trying run simple program:
#include "opencv/highgui.h" #include "opencv/highgui.hpp" #include "opencv/cv.h" #include "opencv/cxcore.h" #include "opencv/cxcore.hpp" #include <stdio.h> #include <iostream> using namespace cv; using namespace std; int main() { mat image = imread("test.jpg", cv_load_image_unchanged); if (!image.data) //check whether image loaded or not { cout << "image cannot loaded." << endl; } else { cout<<"image can loaded."<<endl; cout<<"size "<<image.size().height<<","<<image.size().width<<endl; namedwindow( "display window", cv_window_autosize ); imshow( "display image", image ); } }
when cmake, no errors, , when run program doing ./test, "image can loaded" along correct size of image.
why won't program create new window displays image?
thank you!
use cv::waitkey()
after imshow. needed proceed opencv rendering.
use waitkey(0)
pause until key pressed or waitkey(1)
pause short possible.
for further reference.
Comments
Post a Comment