I want to create a mat and show it in a window named "figure".
If there is nothing wrong, there should be a window named "figure", and accept any key to stop.
In Release mode, the following code works finely.
but in Debug mode, the imshow()
will create a new window which has the same name with the window create by nameWindow()
. and only the figure created by namedWindow()
accepts my input.
#include<opencv2opencv.hpp>
const std::string winName = "figure";
int main() {
cv::Mat m;
cv::namedWindow(winName,cv::WINDOW_AUTOSIZE);
m.create(300, 300, CV_32FC3);
m.setTo(cv::Scalar(0.0f, 2.0f, 5.0f));
cv::imshow(winName, m);
cv::waitKey(0);
}
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…