Start by installing OpenCV4.0.1 with Homebrew
$ brew install opencv
If Open3.4.5 is installed
brew install opencv@3
** If you need –with OpenGL ** you need to [download] to [email protected] and change the compilation configuration.
brew install ./[email protected]
Update if you find any updates;
Then configure it in the CLion project cmMakelists.txt as follows:
cmake_minimum_required(VERSION 3.9)
project(untitled1)
set(CMAKE_CXX_STANDARD 11)
#find_library(OpenCV)
find_package(OpenCV)
include_directories(${OpenCV_INCLUDE_DIRS})
set(CMAKE_CXX_STANDARD 11)
add_executable(untitled1 main.cpp)
target_link_libraries(untitled1 ${OpenCV_LIBS})
Then you can write main.cpp to verify that:
#include <iostream>
#include <opencv2/opencv.hpp>
using namespace std;
using namespace cv;
int main() {
Mat srcImage = imread("your_img_path.jpg");
if (!srcImage.data) {
std::cout << "Image not loaded";
return -1;
}
imshow("[img]", srcImage);
waitKey(0);
return 0;
}
You can display the photo, but if you can’t find the photo, change the path to the absolute path.
the original: https://blog.csdn.net/u010319740/article/details/79012810
Read More:
- Configuring OpenGL environment on Mac OS
- Environment configuration at the beginning of OpenCV + vs2015
- Clion MinGW super fast configuration OpenGL development environment
- Vc2010 configuring OpenGL environment
- CodeBlocks configuring OpenGL environment
- Configuring C + + environment with atom under ubuntu1404
- Configuring OpenGL environment with code blocks16.0 in Windows 10
- Mac installation opencv brew tap homebrew / Science
- Imshow() reports an error after C + + opencv 4.5.1 configures the environment
- Configuring common environment variables in Windows
- Configuring OpenGL development environment in win10 + vs2015 (including the method of installing 32-bit and 64 bit libraries)
- A series of problems in configuring OpenGL development environment in vs2015
- Vs2015 configuring OpenGL development environment: configuration of glfw library and glad Library
- Mac – build. Net development environment
- Problems encountered in configuring OpenGL development environment in vs2015
- Problem in configuring Maven error: Java_ HOME not found in your environment.
- Installing flash in MAC environment
- Opencv perfect configuration strategy 2015 (win7 + opencv 2.4.9 + vs 2013)
- Project files may be invalid appears when cmake compiles opencv3.1, and the debug additional dependency of the compiled opencv3.1 is at the end
- Anaconda create environment, delete environment, activate environment, exit environment