HOWTO: Setup XCode 6.1 to work with OpenCV3 libraries
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 namespace
namespace {
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[] << " <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[] << "" << endl
<< "\tYou may also pass a video file instead of a device number" << endl
<< "\texample: " << av[] << " 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[] << " right%%02d.jpg" << endl;
} int process(VideoCapture& capture) {
int n = ;
char filename[];
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(); //delay N millis, usually long enough to display and capture input switch (key) {
case 'q':
case 'Q':
case : //escape key
return ;
case ' ': //Save an image
sprintf(filename,"filename%.3d.jpg",n++);
imwrite(filename,frame);
cout << "Saved " << filename << endl;
break;
default:
break;
}
}
return ;
}
} int main(int ac, char** av) { if (ac != ) {
help(av);
return ;
}
std::string arg = av[];
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 ;
}
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!
15NOVEMBER 19, 2014 BY DAVID HAYLOCKOPENCV, XCODE, YOSEMITE
Post navigation
HOWTO: Setup XCode 6.1 to work with OpenCV3 libraries的更多相关文章
- Howto Setup yum repositories to update or install package from ISO CDROM Image
Step # 1: Mount an ISO file Type the following command (replace iso file name with the actual iso fi ...
- HowTo: Xen 4.1.3 Windows 8 HVM domU with Intel HD4000 VGA Passthrough on Debian Wheezy
http://linux-bsd-sharing.blogspot.com/2012/10/howto-xen-413-windows-8-hvm-domu-with.html Update 05/0 ...
- OpenSSL Command-Line HOWTO
OpenSSL Command-Line HOWTO The openssl application that ships with the OpenSSL libraries can perform ...
- Server Name Indication(SNI)
转载自: http://openwares.net/misc/server_name_indication.html Server Name Indication是用来改善SSL(Secure Soc ...
- ubuntu下解析udt数据包
udt是通过udp进行端到端可靠传输的一个协议,有其默认拥塞控制算法. 之前ubuntu下wireshark的版本是1.10,不能直接解析udt数据包[1],升级到最新的2.0.0即可过滤udt数据包 ...
- Cocoapods的使用教程
前言 对于iOS App的开发,几乎都采用了Cocoapods来管理第三方库,那么对于我们开发人员来说,这是必备技能,必须要掌握如何使用.这篇文章就是介绍如何安装和使用CocoaPods的. 这篇文章 ...
- Shell终端配置
Shell终端配置 How to: Change / Setup bash custom prompt (PS1) 参考链接:https://www.cyberciti.biz/tips/howto- ...
- 【openwrt】再设置
https://wiki.openwrt.org/zh-cn/doc/uci/network https://wiki.openwrt.org/zh-cn/doc/uci/wireless https ...
- Building gRPC Client iOS Swift Note Taking App
gRPC is an universal remote procedure call framework developed by Google that has been gaining inter ...
随机推荐
- 【原创】Linux下获取命令的帮助与常用命令
Linux中的shell命令一般是执行步骤:用户在终端输入命令回车,系统内核会在当前用户的环境变量PATH中去读取环境变量的值 变量的值就是命令的路径,命令路径不只一个,于是系统会从这些路径中从左至右 ...
- 一个开源的可视化的jQuery工作流插件
特点 1.跨浏览器,可兼容IE7--IE11, FireFox, Chrome, Opera等几大内核的浏览器,且不需要浏览器再加装任何控件. (IE7-IE8时,使用VML:IE9以上,FF,OPE ...
- c语言位运算符
C语言既具有高级语言的特点,又具有低级语言的功能. 所谓位运算是指进行二进制位的运算. C语言提供的位运算: 运算符 含义 & 按位与 | 按位或 ∧ 按位异或 ∽ ...
- js stringObject的indexOf方法
我所写的这个是基本知识的基本知识,为什么我还是要写呢,所谓说好记性不如烂比头,作为一名前端开发人员,太多相似的代码见的又太多,但是又不常见,所以很容易忘记,那我把indexOf原理讲清楚 indexO ...
- html渐隐轮播
这是我之前用的时候从一个模板中下载下来用的,现在又用到了,我又重新找了一遍,为防止我下次用到忘记,特写下此文: 下载插件:jquery-2.1.4.min.js和slider.js 首页轮播页面首页i ...
- 基于类和redis的监控系统开发
最近学习python运维开发,编写得一个简单的监控系统,现记录如下,仅供学习参考. 整个程序分为7个部分: 第一个部分根据监控架构设计文档架构如下: .├── m_client│ ├── conf ...
- JavaBean的使用
JavaBean主要用于实现一些业务逻辑或封装一些业务对象 通常将JavaBean中的属性设置为私有的(private),但需要为其提供公共的(public)访问方法,也就是所说的getXXX()方法 ...
- python is == 的区别
要点: is 判断是否是同一个对象.是通过id来判断的 == 是通过值来判断的 为了提高内存利用率对一些简单的对象,如一些数值较小的int对象,python采用重用对象内存的方法 例如指向 ...
- Google面试题之100层仍两个棋子
一道Google面试题,题目如下:"有一个100层高的大厦,你手中有两个相同的玻璃围棋子.从这个大厦的某一层扔下围棋子就会碎,用你手中的这两个玻璃围棋子,找出一个最优的策略,来得知那个临界层 ...
- 【POJ 2152】 Fire (树形DP)
Fire Description Country Z has N cities, which are numbered from 1 to N. Cities are connected by h ...