直接加配置好的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的平台

解决之后发现就可以读图啦~

 

posted on 2017-09-20 17:53  紫月小猫咪  阅读(1923)  评论(1编辑  收藏  举报