If you came here looking for resources for CS4053, you just missed them. You can request access to a different repository with some available here if you want.
Please note: Keep in mind that it matters where your 'build' folder is when you run CMake, and this path is where your build folder's path should point to for eternity.
- Install XCode
- Install CMake
- Download OpenCV:
- Get the latest release of OpenCV
- Create a folder called 'build' within the OpenCV folder you downloaded
- Open CMake
- Select the downloaded folder as the source file
- Select your new 'build' folder as where to build the binaries.
- Click 'configure', check that 'Unix Makefiles' is the generator for the project and that 'Use default native compilers' is checked.
- Click 'done'.
- When the configuration is done, click 'generate'.
- Inside your build folder in the downloaded OpenCV folder, run
make
. (You might need to runbrew install make gcc
) - In the same directory, run
sudo make install
- Open XCode and select 'create new XCode project'.
- Select the 'Command Line Tool' template under 'macOS'.
- Name and create your project (Make sure you select 'C++' as the language for the project)
- Update the Project's search paths:
- In 'Build Settings' search for 'Search Paths' (Make sure you are searching 'All' build settings and not just 'Basic' ones)
- Make sure that 'Always Search User Paths' is set to 'Yes'.
- Add
/usr/local/lib
to 'Framework Search Paths'. - Add
/usr/local/include
to 'Header Search Paths'. - Add
<The path to the build folder you made>/lib
to 'Library Search Paths'.
- Search the Build Settings for 'Other Linker Flags' and add every file except the 'cv2.so' from the 'lib' folder now inside your 'build' folder from before. (You can drag and drop these into the 'Other Linker Flags' in XCode)
You can test that you have set up OpenCV correctly by replacing the code in your main.cpp with this code and running it:
#include <iostream>
#include <opencv2/opencv.hpp>
int main(int argc, const char * argv[]) {
std::cout << "Open CV Version:" << CV_VERSION << std::endl;
return 0;
}