opencv显示图片
时间: 2023-08-21 21:11:59 浏览: 51
在OpenCV中,可以使用imshow函数来显示图片。以下是一个示例代码:
```cpp
#include <opencv2/opencv.hpp>
using namespace cv;
int main() {
Mat src = imread("image.jpg"); // 读取图片
if (src.empty()) {
printf("未能找到图片\n");
return -1;
}
namedWindow("显示图片", WINDOW_AUTOSIZE); // 创建一个窗口
imshow("显示图片", src); // 在窗口中显示图片
waitKey(0); // 等待按键
destroyAllWindows(); // 销毁窗口
return 0;
}
```
在这个示例中,首先使用imread函数读取图片,然后创建一个窗口并命名为"显示图片",接着使用imshow函数将图片显示在窗口中。最后使用waitKey函数等待按键,当用户按下任意键时,程序继续执行,最后使用destroyAllWindows函数销毁窗口。
#### 引用[.reference_title]
- *1* *3* [opencv 显示图片](https://blog.csdn.net/xiatiankuaizou/article/details/125575229)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insertT0,239^v3^insert_chatgpt"}} ] [.reference_item]
- *2* [OpenCV——显示图片](https://blog.csdn.net/weixin_43971752/article/details/122124043)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insertT0,239^v3^insert_chatgpt"}} ] [.reference_item]
[ .reference_list ]
相关推荐
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.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)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)