无法在 Opencv 中显示图像导致内存位置
Can't display image in Opencv cause memory location
我试图用opencv显示图像,但失败了。搜索谷歌,不知道最近的一个如何仅显示调试
这里的代码
#include<opencv2/opencv.hpp>
#include<iostream>
using namespace std;
using namespace cv;
int main()
{
Mat img = imread("dom.png");
namedWindow("image", WINDOW_NORMAL);
imshow("image", img);// It stuck here
waitKey(0);
return 0;
}
我尝试将img放入资源文件和源文件中,但仍然出错。该平台适用于 x64 .
Exception thrown at 0x00007FFBE404A388 in Opencv_01.exe: Microsoft C++ exception: cv::Exception at memory location 0x000000768258F1B0.
Unhandled exception at 0x00007FFBE404A388 in Opencv_01.exe: Microsoft C++ exception: cv::Exception at memory location 0x000000768258F1B0.
我哪里做错了?
问题是您没有处理 if 无法加载图像的情况。也许在程序的 currnet 目录中找不到它。
检查图像是否已加载的方法如下:
int main()
{
Mat img = imread("dom.png");
if(!img.data) {
cout << "Could not load image" << 'n';
return 1;
}
namedWindow("image", WINDOW_NORMAL);
imshow("image", img);// It stuck here
waitKey(0);
return 0;
}
相关文章:
- 重新定位图像时如何前进到下一个内存块
- 使用 ImageIO.read() 生成的图像是否仍然使用传递给它的相同内存?
- 是否可以通过每次在内存中仅保存一个平铺来处理完整的平铺 tiff 图像?
- C++:从GPU内存(cudaMemcpy2D)获取BGR图像(cv::Mat)
- 如何返回定义良好的内存部分?例如来自图像数据的像素的颜色值
- C++gdi::内存中的位图到PNG图像
- 无法在 Opencv 中显示图像导致内存位置
- 我可以使用 stb_image_write.h 将 JPG 图像写入内存吗?
- 为什么在开始绘制获取的交换链图像时不需要内存障碍?
- 内存泄漏,许多位图图像C CLI
- 如何从内存中读取原始图像 (YUV 4:2:2) 格式的图像数据
- QT图像查看器示例,可能存在内存泄漏
- 在python openCV中一次将许多图像读入内存
- 尝试为图像缓冲区分配内存时 ptr 值错误
- 如何使用OpenCL处理GPU内存中总大小过大的图像
- 如何使用LEADTOOLS 19将图像效果应用于内存缓冲区中的JPEG
- Vulkan:在多个命令缓冲区中排列图像内存屏障
- 是否可以在图形卡上渲染场景,然后将图像传输回系统内存
- 存储矢量的精确内存图像
- 访问像素值,而不在内存中加载大图像的图像