标签:new info bin return lag col alt 终端 width
安装sublime text3
打开mac终端,安装brew
安装opencv3,终端输入下面的coomand:
brew install opencv@3
注意:@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/opencv@3/3.4.5_2/include/opencv", "-I/usr/local/Cellar/opencv@3/3.4.5_2/include", "/usr/local/Cellar/opencv@3/3.4.5_2/lib/libopencv_calib3d.dylib", "/usr/local/Cellar/opencv@3/3.4.5_2/lib/libopencv_core.dylib", "/usr/local/Cellar/opencv@3/3.4.5_2/lib/libopencv_features2d.dylib", "/usr/local/Cellar/opencv@3/3.4.5_2/lib/libopencv_flann.dylib", "/usr/local/Cellar/opencv@3/3.4.5_2/lib/libopencv_highgui.dylib", "/usr/local/Cellar/opencv@3/3.4.5_2/lib/libopencv_imgcodecs.dylib", "/usr/local/Cellar/opencv@3/3.4.5_2/lib/libopencv_imgproc.dylib", "/usr/local/Cellar/opencv@3/3.4.5_2/lib/libopencv_ml.dylib", "/usr/local/Cellar/opencv@3/3.4.5_2/lib/libopencv_objdetect.dylib", "/usr/local/Cellar/opencv@3/3.4.5_2/lib/libopencv_photo.dylib", "/usr/local/Cellar/opencv@3/3.4.5_2/lib/libopencv_stitching.dylib", "/usr/local/Cellar/opencv@3/3.4.5_2/lib/libopencv_video.dylib", "/usr/local/Cellar/opencv@3/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/opencv@3/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开发环境
标签:new info bin return lag col alt 终端 width
原文地址:https://www.cnblogs.com/qianxiaolingyun/p/11001254.html