Ask Your Question

Revision history [back]

Opencv on MacOS Xcode can not use imread to read image based on c++

I am not sure why I cannot read an image by using imread function and the details about my code are as the following. Please help me. Thank you, everybody!

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;}

The build information is as the following.

General configuration for OpenCV 3.4.3 ===================================== Version control: unknown

Extra modules: Location (extra): /tmp/opencv-20181001-83194-s618mv/opencv-3.4.3/opencv_contrib/modules Version control (extra): unknown

Platform: Timestamp: 2018-10-01T12:58:23Z Host: Darwin 18.0.0 x86_64 CMake: 3.12.2 CMake generator: Unix Makefiles CMake build tool: /usr/local/Homebrew/Library/Homebrew/shims/mac/super/gmake Configuration: Release

CPU/HW features: Baseline: SSE SSE2 SSE3 SSSE3 requested: DETECT disabled: SSE4_1 SSE4_2 AVX AVX2 Dispatched code generation: SSE4_1 SSE4_2 FP16 AVX AVX2 AVX512_SKX requested: SSE4_1 SSE4_2 AVX FP16 AVX2 AVX512_SKX SSE4_1 (3 files): + SSE4_1 SSE4_2 (1 files): + SSE4_1 POPCNT SSE4_2 FP16 (1 files): + SSE4_1 POPCNT SSE4_2 FP16 AVX AVX (5 files): + SSE4_1 POPCNT SSE4_2 AVX AVX2 (9 files): + SSE4_1 POPCNT SSE4_2 FP16 FMA3 AVX AVX2 AVX512_SKX (1 files): + SSE4_1 POPCNT SSE4_2 FP16 FMA3 AVX AVX2 AVX_512F AVX512_SKX

C/C++: Built as dynamic libs?: YES C++11: YES C++ Compiler: /usr/local/Homebrew/Library/Homebrew/shims/mac/super/clang++ (ver 10.0.0.10001145) C++ flags (Release): -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Winit-self -Winconsistent-missing-override -Wno-narrowing -Wno-delete-non-virtual-dtor -Wno-unnamed-type-template-args -Wno-comment -fdiagnostics-show-option -Wno-long-long -Qunused-arguments -Wno-semicolon-before-method-body -ffunction-sections -fdata-sections -msse -msse2 -msse3 -mssse3 -fvisibility=hidden -fvisibility-inlines-hidden -DNDEBUG -DNDEBUG C++ flags (Debug): -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Winit-self -Winconsistent-missing-override -Wno-narrowing -Wno-delete-non-virtual-dtor -Wno-unnamed-type-template-args -Wno-comment -fdiagnostics-show-option -Wno-long-long -Qunused-arguments -Wno-semicolon-before-method-body -ffunction-sections -fdata-sections -msse -msse2 -msse3 -mssse3 -fvisibility=hidden -fvisibility-inlines-hidden -g -O0 -DDEBUG -D_DEBUG C Compiler: /usr/local/Homebrew/Library/Homebrew/shims/mac/super/clang C flags (Release): -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Winit-self -Winconsistent-missing-override -Wno-narrowing -Wno-delete-non-virtual-dtor -Wno-unnamed-type-template-args -Wno-comment -fdiagnostics-show-option -Wno-long-long -Qunused-arguments -Wno-semicolon-before-method-body -ffunction-sections -fdata-sections -msse -msse2 -msse3 -mssse3 -fvisibility=hidden -fvisibility-inlines-hidden -DNDEBUG -DNDEBUG C flags (Debug): -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Winit-self -Winconsistent-missing-override -Wno-narrowing -Wno-delete-non-virtual-dtor -Wno-unnamed-type-template-args -Wno-comment -fdiagnostics-show-option -Wno-long-long -Qunused-arguments -Wno-semicolon-before-method-body -ffunction-sections -fdata-sections -msse -msse2 -msse3 -mssse3 -fvisibility=hidden -fvisibility-inlines-hidden -g -O0 -DDEBUG -D_DEBUG Linker flags (Release): Linker flags (Debug): ccache: NO Precompiled headers: NO Extra dependencies: 3rdparty dependencies:

OpenCV modules: To be built: aruco bgsegm bioinspired calib3d ccalib core datasets dnn dnn_objdetect dpm face features2d flann fuzzy hfs highgui img_hash imgcodecs imgproc java_bindings_generator line_descriptor ml objdetect optflow phase_unwrapping photo plot python2 python3 python_bindings_generator reg rgbd saliency shape stereo stitching structured_light superres surface_matching tracking video videoio videostab xfeatures2d ximgproc xobjdetect xphoto Disabled: js text world Disabled by dependency: - Unavailable: cnn_3dobj cudaarithm cudabgsegm cudacodec cudafeatures2d cudafilters cudaimgproc cudalegacy cudaobjdetect cudaoptflow cudastereo cudawarping cudev cvv freetype hdf java matlab ovis sfm ts viz Applications: apps Documentation: NO Non-free algorithms: YES

GUI: Cocoa: YES

Media I/O: ZLib: /usr/lib/libz.dylib (ver 1.2.11) JPEG: build-libjpeg-turbo (ver 1.5.3-62) WEBP: build (ver encoder: 0x020e) PNG: /usr/local/lib/libpng.dylib (ver 1.6.35) TIFF: /usr/local/lib/libtiff.dylib (ver 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 (ver 2.2.0) HDR: YES SUNRASTER: YES PXM: YES

Video I/O: FFMPEG: YES avcodec: YES (ver 58.18.100) avformat: YES (ver 58.12.100) avutil: YES (ver 56.14.100) swscale: YES (ver 5.1.100) avresample: YES (ver 4.0.0) AVFoundation: YES

Parallel framework: TBB (ver 2018.0 interface 10005)

Trace: YES (with Intel ITT)

Other third-party libraries: Intel IPP: 2017.0.3 [2017.0.3] at: /tmp/opencv-20181001-83194-s618mv/opencv-3.4.3/build/3rdparty/ippicv/ippicv_mac Intel IPP IW: sources (2017.0.3) at: /tmp/opencv-20181001-83194-s618mv/opencv-3.4.3/build/3rdparty/ippicv/ippiw_mac Lapack: YES (/System/Library/Frameworks/Accelerate.framework /System/Library/Frameworks/Accelerate.framework) Eigen: YES (ver 3.3.5) Custom HAL: NO Protobuf: build (3.5.1)

OpenCL: YES (no extra features) Include path: NO Link libraries: -framework OpenCL

Python 2: Interpreter: /usr/local/opt/python@2/bin/python (ver 2.7.15) Libraries: /usr/local/Cellar/python@2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/lib/libpython2.7.dylib (ver 2.7.15) numpy: /usr/local/lib/python2.7/site-packages/numpy/core/include (ver 1.15.1) packages path: lib/python2.7/site-packages

Python 3: Interpreter: /usr/local/opt/python/bin/python3 (ver 3.7) Libraries: /usr/local/opt/python/Frameworks/Python.framework/Versions/3.7/lib/python3.7/config-3.7m-darwin/libpython3.7.dylib (ver 3.7.0) numpy: /usr/local/lib/python3.7/site-packages/numpy/core/include (ver 1.15.1) packages path: lib/python3.7/site-packages

Python (for build): /usr/local/opt/python@2/bin/python

Java: ant: NO JNI: /Library/Java/JavaVirtualMachines/jdk-11.jdk/Contents/Home/include /Library/Java/JavaVirtualMachines/jdk-11.jdk/Contents/Home/include/darwin /Library/Java/JavaVirtualMachines/jdk-11.jdk/Contents/Home/include Java wrappers: NO Java tests: NO

Matlab: NO

Install to: /usr/local/Cellar/opencv/3.4.3

click to hide/show revision 2
retagged

updated 2018-10-26 07:14:10 -0600

berak gravatar image

Opencv on MacOS Xcode can not use imread to read image based on c++

I am not sure why I cannot read an image by using imread function and the details about my code are as the following. Please help me. Thank you, everybody!

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;}

The build information is as the following.

General configuration for OpenCV 3.4.3 ===================================== Version control: unknown

Extra modules: Location (extra): /tmp/opencv-20181001-83194-s618mv/opencv-3.4.3/opencv_contrib/modules Version control (extra): unknown

Platform: Timestamp: 2018-10-01T12:58:23Z Host: Darwin 18.0.0 x86_64 CMake: 3.12.2 CMake generator: Unix Makefiles CMake build tool: /usr/local/Homebrew/Library/Homebrew/shims/mac/super/gmake Configuration: Release

CPU/HW features: Baseline: SSE SSE2 SSE3 SSSE3 requested: DETECT disabled: SSE4_1 SSE4_2 AVX AVX2 Dispatched code generation: SSE4_1 SSE4_2 FP16 AVX AVX2 AVX512_SKX requested: SSE4_1 SSE4_2 AVX FP16 AVX2 AVX512_SKX SSE4_1 (3 files): + SSE4_1 SSE4_2 (1 files): + SSE4_1 POPCNT SSE4_2 FP16 (1 files): + SSE4_1 POPCNT SSE4_2 FP16 AVX AVX (5 files): + SSE4_1 POPCNT SSE4_2 AVX AVX2 (9 files): + SSE4_1 POPCNT SSE4_2 FP16 FMA3 AVX AVX2 AVX512_SKX (1 files): + SSE4_1 POPCNT SSE4_2 FP16 FMA3 AVX AVX2 AVX_512F AVX512_SKX

C/C++: Built as dynamic libs?: YES C++11: YES C++ Compiler: /usr/local/Homebrew/Library/Homebrew/shims/mac/super/clang++ (ver 10.0.0.10001145) C++ flags (Release): -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Winit-self -Winconsistent-missing-override -Wno-narrowing -Wno-delete-non-virtual-dtor -Wno-unnamed-type-template-args -Wno-comment -fdiagnostics-show-option -Wno-long-long -Qunused-arguments -Wno-semicolon-before-method-body -ffunction-sections -fdata-sections -msse -msse2 -msse3 -mssse3 -fvisibility=hidden -fvisibility-inlines-hidden -DNDEBUG -DNDEBUG C++ flags (Debug): -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Winit-self -Winconsistent-missing-override -Wno-narrowing -Wno-delete-non-virtual-dtor -Wno-unnamed-type-template-args -Wno-comment -fdiagnostics-show-option -Wno-long-long -Qunused-arguments -Wno-semicolon-before-method-body -ffunction-sections -fdata-sections -msse -msse2 -msse3 -mssse3 -fvisibility=hidden -fvisibility-inlines-hidden -g -O0 -DDEBUG -D_DEBUG C Compiler: /usr/local/Homebrew/Library/Homebrew/shims/mac/super/clang C flags (Release): -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Winit-self -Winconsistent-missing-override -Wno-narrowing -Wno-delete-non-virtual-dtor -Wno-unnamed-type-template-args -Wno-comment -fdiagnostics-show-option -Wno-long-long -Qunused-arguments -Wno-semicolon-before-method-body -ffunction-sections -fdata-sections -msse -msse2 -msse3 -mssse3 -fvisibility=hidden -fvisibility-inlines-hidden -DNDEBUG -DNDEBUG C flags (Debug): -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Winit-self -Winconsistent-missing-override -Wno-narrowing -Wno-delete-non-virtual-dtor -Wno-unnamed-type-template-args -Wno-comment -fdiagnostics-show-option -Wno-long-long -Qunused-arguments -Wno-semicolon-before-method-body -ffunction-sections -fdata-sections -msse -msse2 -msse3 -mssse3 -fvisibility=hidden -fvisibility-inlines-hidden -g -O0 -DDEBUG -D_DEBUG Linker flags (Release): Linker flags (Debug): ccache: NO Precompiled headers: NO Extra dependencies: 3rdparty dependencies:

OpenCV modules: To be built: aruco bgsegm bioinspired calib3d ccalib core datasets dnn dnn_objdetect dpm face features2d flann fuzzy hfs highgui img_hash imgcodecs imgproc java_bindings_generator line_descriptor ml objdetect optflow phase_unwrapping photo plot python2 python3 python_bindings_generator reg rgbd saliency shape stereo stitching structured_light superres surface_matching tracking video videoio videostab xfeatures2d ximgproc xobjdetect xphoto Disabled: js text world Disabled by dependency: - Unavailable: cnn_3dobj cudaarithm cudabgsegm cudacodec cudafeatures2d cudafilters cudaimgproc cudalegacy cudaobjdetect cudaoptflow cudastereo cudawarping cudev cvv freetype hdf java matlab ovis sfm ts viz Applications: apps Documentation: NO Non-free algorithms: YES

GUI: Cocoa: YES

Media I/O: ZLib: /usr/lib/libz.dylib (ver 1.2.11) JPEG: build-libjpeg-turbo (ver 1.5.3-62) WEBP: build (ver encoder: 0x020e) PNG: /usr/local/lib/libpng.dylib (ver 1.6.35) TIFF: /usr/local/lib/libtiff.dylib (ver 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 (ver 2.2.0) HDR: YES SUNRASTER: YES PXM: YES

Video I/O: FFMPEG: YES avcodec: YES (ver 58.18.100) avformat: YES (ver 58.12.100) avutil: YES (ver 56.14.100) swscale: YES (ver 5.1.100) avresample: YES (ver 4.0.0) AVFoundation: YES

Parallel framework: TBB (ver 2018.0 interface 10005)

Trace: YES (with Intel ITT)

Other third-party libraries: Intel IPP: 2017.0.3 [2017.0.3] at: /tmp/opencv-20181001-83194-s618mv/opencv-3.4.3/build/3rdparty/ippicv/ippicv_mac Intel IPP IW: sources (2017.0.3) at: /tmp/opencv-20181001-83194-s618mv/opencv-3.4.3/build/3rdparty/ippicv/ippiw_mac Lapack: YES (/System/Library/Frameworks/Accelerate.framework /System/Library/Frameworks/Accelerate.framework) Eigen: YES (ver 3.3.5) Custom HAL: NO Protobuf: build (3.5.1)

OpenCL: YES (no extra features) Include path: NO Link libraries: -framework OpenCL

Python 2: Interpreter: /usr/local/opt/python@2/bin/python (ver 2.7.15) Libraries: /usr/local/Cellar/python@2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/lib/libpython2.7.dylib (ver 2.7.15) numpy: /usr/local/lib/python2.7/site-packages/numpy/core/include (ver 1.15.1) packages path: lib/python2.7/site-packages

Python 3: Interpreter: /usr/local/opt/python/bin/python3 (ver 3.7) Libraries: /usr/local/opt/python/Frameworks/Python.framework/Versions/3.7/lib/python3.7/config-3.7m-darwin/libpython3.7.dylib (ver 3.7.0) numpy: /usr/local/lib/python3.7/site-packages/numpy/core/include (ver 1.15.1) packages path: lib/python3.7/site-packages

Python (for build): /usr/local/opt/python@2/bin/python

Java: ant: NO JNI: /Library/Java/JavaVirtualMachines/jdk-11.jdk/Contents/Home/include /Library/Java/JavaVirtualMachines/jdk-11.jdk/Contents/Home/include/darwin /Library/Java/JavaVirtualMachines/jdk-11.jdk/Contents/Home/include Java wrappers: NO Java tests: NO

Matlab: NO

Install to: /usr/local/Cellar/opencv/3.4.3