在mac上使用sublime text3搭建opencv3开发环境
Posted qianxiaolingyun
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了在mac上使用sublime text3搭建opencv3开发环境相关的知识,希望对你有一定的参考价值。
安装sublime text3
打开mac终端,安装brew
安装opencv3,终端输入下面的coomand:
brew install [email protected]
注意:@3表示安装的版本,如果不加@3,那么会默认安装最新的版本;建议安装版本3。
在sublime text3中添加build system
Tools->Build System->New Build System...
复制下面的code到新建的.sublime-build
文件
"cmd": ["g++", "-Wall", "-Wextra", "$file", "-o", "$file_path/$file_base_name", "-I/usr/local/Cellar/[email protected]/3.4.5_2/include/opencv", "-I/usr/local/Cellar/[email protected]/3.4.5_2/include", "/usr/local/Cellar/[email protected]/3.4.5_2/lib/libopencv_calib3d.dylib", "/usr/local/Cellar/[email protected]/3.4.5_2/lib/libopencv_core.dylib", "/usr/local/Cellar/[email protected]/3.4.5_2/lib/libopencv_features2d.dylib", "/usr/local/Cellar/[email protected]/3.4.5_2/lib/libopencv_flann.dylib", "/usr/local/Cellar/[email protected]/3.4.5_2/lib/libopencv_highgui.dylib", "/usr/local/Cellar/[email protected]/3.4.5_2/lib/libopencv_imgcodecs.dylib", "/usr/local/Cellar/[email protected]/3.4.5_2/lib/libopencv_imgproc.dylib", "/usr/local/Cellar/[email protected]/3.4.5_2/lib/libopencv_ml.dylib", "/usr/local/Cellar/[email protected]/3.4.5_2/lib/libopencv_objdetect.dylib", "/usr/local/Cellar/[email protected]/3.4.5_2/lib/libopencv_photo.dylib", "/usr/local/Cellar/[email protected]/3.4.5_2/lib/libopencv_stitching.dylib", "/usr/local/Cellar/[email protected]/3.4.5_2/lib/libopencv_video.dylib", "/usr/local/Cellar/[email protected]/3.4.5_2/lib/libopencv_videostab.dylib"], "file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$", "working_dir": "$file_path", "selector": "source.c, source.c++", "variants": [ "name": "Run", "cmd": ["bash", "-c", "g++ ‘$file‘ -o ‘$file_path/$file_base_name‘ `/usr/bin/pkg-config --cflags --libs /usr/Local/Cellar/[email protected]/3.4.5_2/lib/pkgconfig/opencv.pc` && ‘$file_path/$file_base_name‘ "] ]
保存,注意扩展名是.sublime-build,我这里取名是opencv.sublime-build,勾选新建的build system,作为build opencv code的指令。
hello opencv测试
#include <opencv2/opencv.hpp> using namespace std; using namespace cv; int main() //从文件中读入图像 Mat img = imread("1.jpeg"); //如果读入图像失败 if(img.empty()) fprintf(stderr, "Can not load image!\\n"); return -1; //显示图像 imshow("original picture", img); //此函数等待按键,按键盘任意键就返回 waitKey(); return 0;
在sublime text中使用快捷键command+B,build测试用例,输出结果如下:
以上是关于在mac上使用sublime text3搭建opencv3开发环境的主要内容,如果未能解决你的问题,请参考以下文章
Mac 上 Sublime Text3-Package control-console安装失败解决方案
在Mac OS终端的Terminal 中使用Sublime Text3
windows下golang开发环境搭建(sublime text3 + gosublime + sublimeGDB)