void display_mat(cv::Mat& img ,std::string name){cv::imshow(name,img);cv::waitkey();}
时间: 2024-04-23 13:27:44 浏览: 22
这是一个用于显示图像的函数。它接受一个cv::Mat类型的图像和一个名称作为参数,并在窗口中显示图像。
函数的实现如下:
```cpp
void display_mat(cv::Mat& img, std::string name) {
cv::imshow(name, img);
cv::waitKey();
}
```
这个函数使用OpenCV库的imshow函数来显示图像,并使用waitKey函数等待用户按键。这样,图像将在窗口中显示,直到用户按下任意键为止。
相关问题
NewFaceDlg.obj : error LNK2001: 无法解析的外部符号 "public: void __thiscall cv::Mat::copyTo(class cv::debug_build_guard::_OutputArray const &)const " (?copyTo@Mat@cv@@QBEXABV_OutputArray@debug_build_guard@2@@Z) 1>NewFaceDlg.obj : error LNK2001: 无法解析的外部符号 "void __cdecl cv::blur(class cv::debug_build_guard::_InputArray const &,class cv::debug_build_guard::_OutputArray const &,class cv::Size_<int>,class cv::Point_<int>,int)" (?blur@cv@@YAXABV_InputArray@debug_build_guard@1@ABV_OutputArray@31@V?$Size_@H@1@V?$Point_@H@1@H@Z) 1>NewFaceDlg.obj : error LNK2001: 无法解析的外部符号 "void __cdecl cv::imshow(class cv::String const &,class cv::debug_build_guard::_InputArray const &)" (?imshow@cv@@YAXABVString@1@ABV_InputArray@debug_build_guard@1@@Z)
这些错误是链接器(linker)错误,意味着在链接过程中找不到相应的函数定义。根据错误信息,看起来是与 OpenCV 相关的函数未能解析。
要解决这些链接错误,你需要确保以下几点:
1. 确保已正确配置 OpenCV:
- 确保已将 OpenCV 的库文件路径添加到项目的库目录中。
- 确保已将 OpenCV 的库文件(.lib)添加到项目的附加依赖项中。
2. 确保链接器能够找到正确的 OpenCV 版本:
- 检查你的项目和 OpenCV 库是否使用相同的平台(32 位或 64 位)。
- 确保你正在链接与你使用的 OpenCV 版本相对应的库文件。
3. 确保已包含正确的头文件:
- 确保在使用 OpenCV 函数之前,已经包含了相应的头文件(如 `#include <opencv2/opencv.hpp>`)。
4. 检查函数调用和参数:
- 确保函数名和参数与 OpenCV 版本中的定义相匹配。
- 确保使用了正确的命名空间(如 `using namespace cv;`)。
如果上述步骤都正确,并且仍然出现链接错误,请确保你所使用的 OpenCV 版本与你的项目兼容,并且没有其他编译配置问题。如果问题仍然存在,请提供更多的上下文和代码示例,我可以帮助你进一步调查并提供更具体的解决方案。
VS 无法解析的外部符号 "void __cdecl cv::imshow(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,class cv::debug_buil
这个错误表明编译器在链接过程中无法找到相关的函数或符号。在这种情况下,错误是关于OpenCV函数`cv::imshow`的外部符号无法解析。
要解决这个问题,你需要确保正确设置了OpenCV库的链接。请按照以下步骤进行操作:
1. 确保已经正确安装了OpenCV,并且已经配置了开发环境,包括设置了正确的包含目录和库目录。
2. 在Visual Studio中,右键点击你的项目,选择 "属性"。
3. 在属性窗口中,选择 "配置属性" -> "VC++目录",确保 "包含目录" 和 "库目录" 设置为正确的OpenCV目录。
4. 在属性窗口中,选择 "配置属性" -> "链接器" -> "输入",在 "附加依赖项" 中添加所需的OpenCV库文件名,比如`opencv_worldXXX.lib`(XXX代表版本号)。
5. 确保你的源代码中包含了正确的OpenCV头文件和命名空间,比如:
```cpp
#include <opencv2/opencv.hpp>
using namespace cv;
```
6. 编译并运行你的项目,看看是否成功解决了链接错误。
如果仍然遇到问题,请确保你正确地安装和配置了OpenCV,并且检查你的项目设置是否正确。如果问题仍然存在,请提供更多的错误信息以便更好地帮助你解决问题。
相关推荐
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![-](https://csdnimg.cn/download_wenku/file_type_column_c1.png)
![-](https://csdnimg.cn/download_wenku/file_type_column_c1.png)
![-](https://csdnimg.cn/download_wenku/file_type_column_c1.png)
![-](https://csdnimg.cn/download_wenku/file_type_column_c1.png)
![-](https://csdnimg.cn/download_wenku/file_type_column_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)