我不确定为什么无法使用imread函数读取图像,有关我的代码的详细信息如下。
#include <iostream>
#include "opencv2/imgproc/imgproc.hpp"
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/core/core.hpp"
int main(int argc, const char * argv[])
{
cv::Mat scrImage = cv::imread("/Users/zsk/Downloads/zsk.JPEG", CV_LOAD_IMAGE_COLOR);
if(scrImage.empty())
{
std::cout << "something wrong" << std::endl;
return -1;
}
cv::Mat scrGray;
cv::cvtColor(scrImage, scrGray, CV_RGB2GRAY);
cv::imshow("scrGray", scrGray);
cv::Mat blurDstImage;
blur(scrGray, blurDstImage, cv::Size(5, 5), cv::Point(-1, 1));
cv::imshow("blurDstImage", blurDstImage);
cv::imwrite("/Users/zsk/Downloads/blurgirl.jpg", blurDstImage);
cv::waitKey(0);
return 0;
}
OpenCV 3.4.3的常规配置====================================== 版本控制:未知
其他模块: 位置(额外):/ tmp / opencv-20181001-83194-s618mv / opencv-3.4.3 / opencv_contrib / modules 版本控制(额外):未知
平台: 时间戳记:2018-10-01T12:58:23Z 主持人:达尔文18.0.0 x86_64 CMake的:3.12.2 CMake生成器:Unix Makefiles CMake构建工具:/ usr / local / Homebrew / Library / Homebrew / shims / mac / super / gmake 配置:发布
CPU /硬件功能: 基准:SSE SSE2 SSE3 SSSE3 要求:检测 禁用:SSE4_1 SSE4_2 AVX AVX2 分派代码生成:SSE4_1 SSE4_2 FP16 AVX AVX2 AVX512_SKX 要求:SSE4_1 SSE4_2 AVX FP16 AVX2 AVX512_SKX SSE4_1(3个文件):+ SSE4_1 SSE4_2(1个文件):+ SSE4_1 POPCNT SSE4_2 FP16(1个文件):+ SSE4_1 POPCNT SSE4_2 FP16 AVX AVX(5个文件):+ SSE4_1 POPCNT SSE4_2 AVX AVX2(9个文件):+ SSE4_1 POPCNT SSE4_2 FP16 FMA3 AVX AVX2 AVX512_SKX(1个文件):+ SSE4_1 POPCNT SSE4_2 FP16 FMA3 AVX AVX2 AVX_512F AVX512_SKX
C / C ++:
作为动态库构建?:是
C ++ 11:是
C ++编译器:/ usr / local / Homebrew / Library / Homebrew / shims / mac / super / clang ++(版本10.0.0.10001145)
C ++标志(发布):-fsigned-char -W -Wall -Werror =返回类型-Werror =非虚拟字符-Werror =地址-Werror =序列点-Wformat -Werror = format-security -Wmissing-declaration -Wmissing原型-Wstrict原型-Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Winit-self -Winconsistent-missing-override -Wno-Rarrowing -Wno-delete-non-virtual-dtor -Wno-unnamed-type-template-args -Wno-comment -fdiagnostics-show-option -Wno-long-long -Quadsed参数-Wno-分号-方法前体-ffunction-sections -fdata-sections -msse -msse2 -msse3 -mssse3 -fvisibility =隐藏-fvisibility-inlines-hidden -DNDEBUG -DNDEBUG
C ++标志(调试):-fsigned-char -W -Wall -Werror =返回类型-Werror =非虚拟变量-Werror =地址-Werror =序列点-Wformat -Werror = format-security -Wmissing声明-Wmissing原型-Wstrict原型-Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Winit-self -Winconsistent-missing-override -Wno-Rarrowing -Wno-delete-non-virtual-dtor -Wno-unnamed-type-template-args -Wno-comment -fdiagnostics-show-option -Wno-long-long -Quadsed参数-Wno-分号-方法前体-ffunction-sections -fdata-sections -msse -msse2 -msse3 -mssse3 -fvisibility =隐藏-fvisibility-inlines隐藏-g -O0 -DDEBUG -D_DEBUG
C编译器:/ usr / local / Homebrew / Library / Homebrew / shims / mac / super / clang
C标志(发布):-fsigned-char -W -Wall -Werror =返回类型-Werror =非虚拟变量-Werror =地址-Werror =序列点-Wformat -Werror = format-security -Wmissing声明-Wmissing原型-Wstrict原型-Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Winit-self -Winconsistent-missing-override -Wno-Rarrowing -Wno-delete-non-virtual-dtor -Wno-unnamed-type-template-args -Wno-comment -fdiagnostics-show-option -Wno-long-long -Quadsed参数-Wno-分号-方法前体-ffunction-sections -fdata-sections -msse -msse2 -msse3 -mssse3 -fvisibility =隐藏-fvisibility-inlines-hidden -DNDEBUG -DNDEBUG
C标志(Debug):-fsigned-char -W -Wall -Werror =返回类型-Werror =非虚拟变量-Werror =地址-Werror =序列点-Wformat -Werror = format-security -Wmissing声明-Wmissing原型-Wstrict原型-Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Winit-self -Winconsistent-missing-override -Wno-Rarrowing -Wno-delete-non-virtual-dtor -Wno-unnamed-type-template-args -Wno-comment -fdiagnostics-show-option -Wno-long-long -Quadsed参数-Wno-分号-方法前体-ffunction-sections -fdata-sections -msse -msse2 -msse3 -mssse3 -fvisibility =隐藏-fvisibility-inlines隐藏-g -O0 -DDEBUG -D_DEBUG
链接器标志(发布):
链接器标志(调试):
ccache:否
预编译头文件:否
额外的依赖项:
第三方依赖性:
OpenCV模块: 即将构建:aruco bgsegm受生物启发的calib3d ccalib核心数据集dnn dnn_objdetect dpm face features2d flann Fuzzy HFS Highgui img_hash imgcodecs imgproc java_bindings_generator line_descriptor ml objdetectoptopt phase_procwing相片绑定X_spacing _gensing_sing_sing_sgs_x_sgs_x_sg_x_videos摄影 禁用:js文本世界 被依赖项禁用:- 不可用:cnn_3dobj cudaarithm cudabgsegm cudacodec cudafeatures2d cudafilters cudaimgproc cudalegacy cudaobjdetect cudaoptflow cudastereo cudawarping cudev cvv freetype hdf java matlab ovis sfm ts viz 应用程序:apps 说明文件:否 非自由算法:是
GUI: 可可:是的
媒体I / O: ZLib:/usr/lib/libz.dylib(1.2.11版) JPEG:build-libjpeg-turbo(版本1.5.3-62) WEBP:构建(版本编码器:0x020e) PNG:/usr/local/lib/libpng.dylib(版本1.6.35) TIFF:/usr/local/lib/libtiff.dylib(版本42 / 4.0.9) OpenEXR:/usr/local/lib/libImath.dylib /usr/local/lib/libIlmImf.dylib /usr/local/lib/libIex.dylib /usr/local/lib/libHalf.dylib / usr / local / lib / libIlmThread .dylib(2.2.0版) HDR:是 日出者:是的 PXM:是
视频I / O: FFMPEG:是 AVCODEC:是(版本58.18.100) avformat:是(版本58.12.100) avutil:是(版本56.14.100) swscale:是(5.1.100版) avresample:是(4.0.0版) AVFoundation:是
并行框架:TBB(版本2018.0接口10005)
跟踪:是(对于Intel ITT)
其他第三方库: 英特尔IPP:2017.0.3 [2017.0.3] 在:/tmp/opencv-20181001-83194-s618mv/opencv-3.4.3/build/3rdparty/ippicv/ippicv_mac 英特尔IPP IW:来源(2017.0.3) 位于:/tmp/opencv-20181001-83194-s618mv/opencv-3.4.3/build/3rdparty/ippicv/ippiw_mac Lapack:是(/System/Library/Frameworks/Accelerate.framework /System/Library/Frameworks/Accelerate.framework) 本征:是(3.3.5版) 自定义HAL:否 Protobuf:构建(3.5.1)
OpenCL:是(没有其他功能) 包含路径:否 链接库:-framework OpenCL
Python 2: 口译员:/ usr / local / opt / python @ 2 / bin / python(版本2.7.15) 库:/usr/local/Cellar/python@2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/lib/libpython2.7.dylib(版本2.7.15) numpy:/usr/local/lib/python2.7/site-packages/numpy/core/include(1.15.1版) 软件包路径:lib / python2.7 / site-packages
Python 3: 口译员:/ usr / local / opt / python / bin / python3(版本3.7) 库:/usr/local/opt/python/Frameworks/Python.framework/Versions/3.7/lib/python3.7/config-3.7m-darwin/libpython3.7.dylib(版本3.7.0) numpy:/usr/local/lib/python3.7/site-packages/numpy/core/include(1.15.1版) 软件包路径:lib / python3.7 / site-packages
Python(用于构建):/ usr / local / opt / python @ 2 / bin / python
Java:
蚂蚁:没有
JNI:/Library/Java/JavaVirtualMachines/jdk-11.jdk/Contents/Home/include /Library/Java/JavaVirtualMachines/jdk-11.jdk/Contents/Home/include/darwin / Library / Java / Java / JavaVirtualMachines / jdk-11 .jdk / Contents / Home / include
Java包装器:否
Java测试:否
Matlab:否
答案 0 :(得分:0)
最后,我发现问题在于Opencv仅是头文件,需要进行特殊编译。