In this video you can check how to install OpenCV/c++ on mac m1 with CLion IDE and a CMake software manager.
Chapters:
0:00 - Introduction
0:21 - Homebrew/CMake
2:03 - Cloning git repo
4:27 - Set CMake Flags
5:33 - Building OpenCV from sources
11:04 - Installing OpenCV
11:26 - CLion project setting
Commands you need
- homebrew(https://brew.sh/)
- brew install cmake
- git clone https://github.com/opencv/opencv.git
- mkdir build
- cmake ../opencv/ .
- arch -arm64 cmake ../opencv/ -DWITH_QT=OFF -DWITH_OPENGL=OFF -DFORCE_VTK=OFF -DWITH_TBB=OFF -DWITH_GDAL=OFF -DWITH_XINE=OFF -DBUILD_EXAMPLES=OFF -DBUILD_ZLIB=OFF -DBUILD_TESTS=OFF .
- arch -arm64 sudo make -j 4
- arch -arm64 sudo make install
Cmake.txt file content
cmake_minimum_required(VERSION 2.8)
project( Open_CV_Project )
find_package(OpenCV REQUIRED)
include_directories( ${OpenCV_INCLUDE_DIRS} )
add_executable( Open_CV_Project main.cpp )
target_link_libraries( Open_CV_Project ${OpenCV_LIBS})
====================
main.cpp file content
====================
#include opencv2/opencv.hpp
#include iostream
using namespace cv;
using namespace std;
///////////////// Images //////////////////////
int main() {
string path = “Your_Image_Dir”;
Mat img = imread(path);
imshow("Image", img);
waitKey(0);
return 0;
}