首页 > 编程语言 > 解决使用OpenCV中的imread()内存报错问题
2021
03-16

解决使用OpenCV中的imread()内存报错问题

错误截图如下:

类似报错的原因

1.imread()中的路径参数有误

a.相对路径:此项目文件夹下可写成imread(“1.jpg”);

b.绝对路径:.例如 imread(“C:\\Users\\Administrator\\Desktop\\picture\\1.jpg”);

2.内存不足

本人在使用imread()加载图片时,因为图片过大(小图片试过没问题),而且程序运行时是在x86环境下的,导致内存不足

x86能够使用的内存比x6要少很多,所以把x86改成x64就可解决

补充:关于在Opencv中使用Release、imread时候出现,错误

0x5a6f37ff (msvcr100d.dll) 处有未经处理的异常: 0xC0000005: 读取位置 0x706d622e 时发生访问冲突

使用imread("test.bmp");发生错误:

错误原因为我们在配置opencv的时候直接将debug版本和release版本的lib一起包含进去

解决方法:

分别包含,release和debug版本的库文件

vs2010 opencv2.4.9配置属性表:

debug:

opencv_ml249d.lib
opencv_calib3d249d.lib
opencv_contrib249d.lib
opencv_core249d.lib
opencv_features2d249d.lib
opencv_flann249d.lib
opencv_gpu249d.lib
opencv_highgui249d.lib
opencv_imgproc249d.lib
opencv_legacy249d.lib
opencv_objdetect249d.lib
opencv_ts249d.lib
opencv_video249d.lib
opencv_nonfree249d.lib
opencv_ocl249d.lib
opencv_photo249d.lib
opencv_stitching249d.lib
opencv_superres249d.lib
opencv_videostab249d.lib

release:

opencv_objdetect249.lib
opencv_ts249.lib
opencv_video249.lib
opencv_nonfree249.lib
opencv_ocl249.lib
opencv_photo249.lib
opencv_stitching249.lib
opencv_superres249.lib
opencv_videostab249.lib
opencv_calib3d249.lib
opencv_contrib249.lib
opencv_core249.lib
opencv_features2d249.lib
opencv_flann249.lib
opencv_gpu249.lib
opencv_highgui249.lib
opencv_imgproc249.lib
opencv_legacy249.lib
opencv_ml249.lib

以上为个人经验,希望能给大家一个参考,也希望大家多多支持自学编程网。如有错误或未考虑完全的地方,望不吝赐教。

编程技巧