解決使用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
以上為個人經驗,希望能給大傢一個參考,也希望大傢多多支持WalkonNet。如有錯誤或未考慮完全的地方,望不吝賜教。
推薦閱讀:
- python讀取文件名及後綴詳解
- 一篇文章帶你順利通過Python OpenCV入門階段
- windows下vscode使用cmake的方法
- Java OpenCV圖像處理之SIFT角點檢測詳解
- Qt5.14 與 OpenCV4.5 教程之圖片增強效果