为什么在调试模式下opencv imshow()创建一个与namedWindow()同名的新窗口? [英] why opencv imshow() create a new window has the same name as namedWindow() does in Debug Mode?
本文介绍了为什么在调试模式下opencv imshow()创建一个与namedWindow()同名的新窗口?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想创建一个垫子并将其显示在名为"figure"的窗口中.
I want to create a mat and show it in a window named "figure".
如果没有问题,应该有一个名为"figure"的窗口,并接受任何要停止的键.
If there is nothing wrong, there should be a window named "figure", and accept any key to stop.
在发布模式下,以下代码可以正常工作.
但是在调试模式下,imshow()
将创建一个新窗口,该窗口的名称与nameWindow()
创建的窗口相同.并且只有namedWindow()
创建的图形才能接受我的输入.
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<opencv2\opencv.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);
}
推荐答案
此问题是由于链接设置错误所致.
This problem is due to wrong linking settings.
- 在 Debug 中,您只需链接到调试库
opencv_world331d.lib
- 在发布中,您只需链接到发布库
opencv_world331.lib
- In Debug, you need to link only to the debug library
opencv_world331d.lib
- In Release, you need to link only to the release library
opencv_world331.lib
这篇关于为什么在调试模式下opencv imshow()创建一个与namedWindow()同名的新窗口?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文