HOWTO: Setup XCode 6.1 to work with OpenCV3 libraries
来源:互联网 发布:云裳恋衣淘宝店 编辑:程序博客网 时间:2024/06/07 17:16
HOWTO: Setup XCode 6.1 to work with OpenCV3 libraries
Overview
This post demonstrates how to setup your XCode IDE to work with openCV libraries on Yosemite. Initially XCode can be an intimidating environment, but past all the windows and complex sections, it boasts a number of beneficial features that aid and simplify programming – which for newcomers to openCV are a must. Features such as autocomplete and integrated compiler are extremely useful in simplifying compilation, speeding up programming time and clarifying how pieces of code fit together.
WARNING: This guide assumes you have compiled and installed openCV
It not, see this guide.
How To
- Open XCode
- Create New Project
- Under OSX Application > Choose Command Line Tool
- Give your application a name then Save
Assigning the Search Paths
- Click the XCode project file in your inspector (which is the blue icon in the furthest left hand tab). You should now have three tabs in the centre window.
Build Settings | Build Options | Build Rules
- Click
Build Settings
- Scroll down until you find Search Paths
- Double Click the Header Search Paths option, then Click the plus icon
- Type in the following
/usr/local/include
- Next Double Click the Library Search Paths option, then Click the plus icon
- Type in the following
/usr/local/lib
Linking the Libraries
Build Settings
.- Scroll until you find Linking
- Double Click Other Linker Flags and Click the plus icon
- Copy and Paste the following, then press enter
-lopencv_calib3d -lopencv_core -lopencv_features2d -lopencv_flann -lopencv_highgui -lopencv_imgcodecs -lopencv_imgproc -lopencv_ml -lopencv_objdetect -lopencv_photo -lopencv_shape -lopencv_stitching -lopencv_superres -lopencv_ts -lopencv_video -lopencv_videoio -lopencv_videostab
Setting the Build Path
- Open XCode Preferences
- Select Locations Tab
- Click Advanced
- Change the Location Button from Unique to Legacy
Build your Application
This is a sample application from the openCV package.
#include <opencv2/imgcodecs.hpp>#include <opencv2/videoio/videoio.hpp>#include <opencv2/highgui/highgui.hpp>#include <iostream>#include <stdio.h>using namespace cv;using namespace std;//hide the local functions in an anon namespacenamespace { void help(char** av) { cout << "The program captures frames from a video file, image sequence (01.jpg, 02.jpg ... 10.jpg) or camera connected to your computer." << endl << "Usage:\n" << av[0] << " <video file, image sequence or device number>" << endl << "q,Q,esc -- quit" << endl << "space -- save frame" << endl << endl << "\tTo capture from a camera pass the device number. To find the device number, try ls /dev/video*" << endl << "\texample: " << av[0] << " 0" << endl << "\tYou may also pass a video file instead of a device number" << endl << "\texample: " << av[0] << " video.avi" << endl << "\tYou can also pass the path to an image sequence and OpenCV will treat the sequence just like a video." << endl << "\texample: " << av[0] << " right%%02d.jpg" << endl; } int process(VideoCapture& capture) { int n = 0; char filename[200]; string window_name = "video | q or esc to quit"; cout << "press space to save a picture. q or esc to quit" << endl; namedWindow(window_name, WINDOW_KEEPRATIO); //resizable window; Mat frame; for (;;) { capture >> frame; if (frame.empty()) break; imshow(window_name, frame); char key = (char)waitKey(30); //delay N millis, usually long enough to display and capture input switch (key) { case 'q': case 'Q': case 27: //escape key return 0; case ' ': //Save an image sprintf(filename,"filename%.3d.jpg",n++); imwrite(filename,frame); cout << "Saved " << filename << endl; break; default: break; } } return 0; }}int main(int ac, char** av) { if (ac != 2) { help(av); return 1; } std::string arg = av[1]; VideoCapture capture(arg); //try to open string, this will attempt to open it as a video file or image sequence if (!capture.isOpened()) //if this fails, try to open as a video camera, through the use of an integer param capture.open(atoi(arg.c_str())); if (!capture.isOpened()) { cerr << "Failed to open the video device, video file or image sequence!\n" << endl; help(av); return 1; } return process(capture);}
Then hold CMD + B
(This builds and compiles the application)
Go to your project folder. There should be a new folder called Debug, inside is your executable file.
Open Terminal then navigate to the folder, then simply type ./<yourprojectname> 0
This should open window and display the camera image.
And there you go!
- HOWTO: Setup XCode 6.1 to work with OpenCV3 libraries
- /howto-configure-msmtp-to-work-with-gmail-on-linux
- HOWTO: Setup Samba peer-to-peer with Windows
- [git] HOWTO-work with git
- [git] HOWTO work with git flow
- qt5.6.1 opencv3.1 setup
- How to work with Ant
- How do UNIX linkers work with archive libraries?
- HOWTO Joystick Setup
- HOWTO Setup Android Development
- Configuring pydev to work with django
- How to work with MeshLab's mesh
- Configuring Services to work with Keystone
- How to Work with FBX SDK
- 0924_How to Work with Me
- How to setup FlumeNG with example configuration
- HOWTO: How to tunnel with SSH - Part 1
- How to configure IPMI to work with Oracle RAC
- LeetCode 20 Valid Parentheses
- HTML其实就是把页面的数据封装并加上标签
- 《JAVA源码分析》:ArrayList
- Jenkins的安装和配置
- 【POJ 2492】【并查集】A Bug's Life
- HOWTO: Setup XCode 6.1 to work with OpenCV3 libraries
- BZOJ 1500: [NOI2005] 维修数列
- leetcode---Factorial Trailing Zeroes
- 简单工厂模式---计算器
- Oracle 9I FOR ALL OS 官方数据库介质+补丁包 百度云迅雷下载
- ntp 设置时间 ---fwqlzz love is for ever
- iOS 选项器
- StringBuffer和String的区别
- ps--蝙蝠侠大战超人