Configure Xcode (4.6.1) and opencvxcode in Opencv (2.4.9) on Mac
1: Install homebrew and cmake
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
Brew install cmake2: install opencvbrew tap homebrew/sciencebrew install opencv3. use Xcode for OpenCV Project Development
1. Open Xcode, chooseNew -> New Project -> Command Line Tool
2. Name it and selectC++For type
3. Click on your project from the left menu. Click
build settingsTab from the top. Filter all. Scroll
Search Paths. Under
header search paths, For debug and release, set the path
/usr/local/include. Under
library search paths, Set the pathto
$(PROJECT_DIR). Finally, check if
C++ standard libraryIs
Libc ++ (this is what Xcode uses by default. )Or not, if not, change it to this! Ps: libstdc ++ is required for some xcode and opencv versions. test which version is suitable for you. 4. Click on your project from the left menu.
File->New->New Group, Name the group
OpenCV Frameworks. 5. Select the folder (group) you just labeled,
OpenCV FrameworksIn the left menu. Go
File -> add Files, Type shift + command + G, which will allow you to manually go to a folder. Go to->
/usr/local/lib6. Select both of these files,
libopencv_core.dylib,
libopencv_highgui.dylib, And click
Add. (You may need to add other library files from this folder to run other code.) 7.You must include this line of code in the beginning of your main. cpp file:
#include <opencv2/opencv.hpp>You can modify main. cpp. The Code is as follows. The running result is to display a specified image.
# Include <opencv2/opencv. hpp>Usingnamespace cv; intmain (intargc, char
**Argv) {Matimage; image
=Imread ("/Users/hujiawei/Pictures/others/other_naicha/naicha.jpg", 1); namedWindow ("Display Image", WINDOW_AUTOSIZE); imshow ("Display Image", image ); waitKey (0); return0 ;}