1. 程式人生 > >【OpenCV】imread讀取數據為空

【OpenCV】imread讀取數據為空

依賴 技術分享 分享 bug features 附加 分開 什麽 ont

直接加配置好的props文件到新的工程時,會出現imread讀出來的Mat為空的情形,搜了一下,發現是opencv的配置問題!!!

是這樣的,之前配置時為了省事兒,無論是Debug還是Release中的附加依賴項,都添加了所有的lib,也就是沒有分Debug和Release。

但實際上OpenCv是要分的,文件名尾帶d的為Debug庫函數,不帶d的為Release庫函數。只需將其中庫函數分開添加進附加依賴項即可:

其他版本以此類推。

Debug庫:

opencv_calib3d244d.lib
opencv_contrib244d.lib
opencv_core244d.lib
opencv_features2d244d.lib
opencv_flann244d.lib
opencv_gpu244d.lib
opencv_highgui244d.lib
opencv_imgproc244d.lib
opencv_legacy244d.lib
opencv_ml244d.lib
opencv_nonfree244d.lib
opencv_objdetect244d.lib
opencv_photo244d.lib
opencv_stitching244d.lib
opencv_ts244d.lib
opencv_video244d.lib
opencv_videostab244d.lib

Release庫:

opencv_calib3d244.lib
opencv_contrib244.lib
opencv_core244.lib
opencv_features2d244.lib
opencv_flann244.lib
opencv_gpu244.lib
opencv_highgui244.lib
opencv_imgproc244.lib
opencv_legacy244.lib
opencv_ml244.lib
opencv_nonfree244.lib
opencv_objdetect244.lib
opencv_photo244.lib
opencv_stitching244.lib
opencv_ts244.lib
opencv_video244.lib
opencv_videostab244.lib

這樣修改後,發現還是不行,為什麽呢?後來發現還跟平臺有關系,不能多添加x86的平臺

技術分享

解決之後發現就可以讀圖啦~

【OpenCV】imread讀取數據為空