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 ...
随机推荐
- 这 30 类 CSS 选择器,你必须理解!
CSS 选择器是一种模式,用于选择需要添加样式的元素.平时使用最多也是最简单的就是 #id..class 和标签选择器,在 CSS 中还有很多更加强大更加灵活的选择方式,尤其是在 CSS3 中,增加了 ...
- 玩转HTML5移动页面(动效篇)
原文:http://www.grycheng.com/?p=458 作为一名前端,在拿到设计稿时你有两种选择: 1.快速输出静态页面 2.加上高级大气上档次狂拽炫酷屌炸天的动画让页面动起来 作为一个有 ...
- C# 实现繁体字和简体字之间的转换
今天收到一个需求,将一组简体的汉字转换成繁体的汉字,刚开始有点茫然,后来在网上搜了一下思路,结果很少有涉及,终于我在看了MSDN后找到了如何解决,可能这方面对一些高程来说很Easy,但是除了高程还有很 ...
- AFNetworking的原理与基本使用-b
全称是AFNetworking 虽然运行效率没有ASI高,但是使用比ASI简单 是对NSURLConnection和NSURLSession的各自的一层包装 AFN的内部中的RunLoop AFN内部 ...
- spoj VFMUL FFT快速傅立叶变换模板题
题意:求两个数相乘. 第一次写非递归的fft,因为一个数组开小了调了两天TAT. #include<iostream> #include<cstring> #include&l ...
- bzoj 3043: IncDec Sequence 模拟
3043: IncDec Sequence Time Limit: 10 Sec Memory Limit: 128 MBSubmit: 248 Solved: 139[Submit][Statu ...
- 【Ecmall】ECMall2.x模板制作入门系列(认识ECMall模板)
ECMall2.x模板制作入门系列之1(认识ECMall模板) 从ECMall2.0全新架构发布以来,随着版本的不断更新,ECMall已经逐渐走向一个稳定时期,是时候整理一些实用教程了.下面给大家带来 ...
- PS命令删除所有EXCHANGE2013内用户邮件
因为在测试的时间产生了大量测试邮件,所以在正式上线前,要删除所有用户的邮件. 命令如下: Get-Mailbox | Search-Mailbox -DeleteContent
- C51 的编程规范
编程首要是要考虑程序的可行性,然后是可读性.可移植性.健壮性以及可测试性.这是总则.但是很多人忽略了可读性.可移植性和健壮性(可调试的方法可能歌不相同),这是不对的. 1.当项目比较大时,最好分模块编 ...
- 忽然想到,为什么以前iOS的工资高
听说做iOS的在上海工资也可以 前几年还行,现在也不太行了除非你水平很高 现在移动应用已经100多万了,基本饱和了以前是新的商业模式要抢时间,会的人也少