When I used VS Code to write my C++ code with OpenCV, I found that although the exe file is generated, the terminal will not show the output of my code. Here is the screenshot of my terminal.
Here's my code:
#include <iostream>
#include <opencv2/opencv.hpp>
using namespace cv;
int main(int argc, char** argv) {
std::cout << "aa" << std::endl;
std::string img = "lenna.jpg";
Mat srcImage = imread(img);
if (!srcImage.data) {
return 1;
}
namedWindow("Display window", WINDOW_AUTOSIZE);
imshow("Display window", srcImage);
waitKey(0);
return 0;
}
However, when I comment all the codes related with OpenCV (from std::string img = "lenna.jpg"
to waitKey(0)
), the problem disappears, and it just display "aa" normally.
How can I fix the problem?