第一步:安装Homebrew
/bin/bash -c "$(curl -fsSL https://cdn.jsdelivr.net/gh/ineo6/homebrew-install/install.sh)"
或者
user/bin/zsh -c "$(curl -fsSL [https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh](https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh))"
已经安装这里不做演示了,我顺便更新下新版本
![](https://img.haomeiwen.com/i3236595/4f7a2b6d8ea6ae6a.png)
第二步:用Homebrew安装OpenCV
brew install opencv (一般是安装在usr/local/Cellar)
![](https://img.haomeiwen.com/i3236595/04a088f8ba8cb471.png)
安装成功如下
![](https://img.haomeiwen.com/i3236595/ac19b29eb4d95d02.png)
安装目录如下(/usr/local/Cellar/opencv/4.5.2_4)
![](https://img.haomeiwen.com/i3236595/5c194afa30f699ca.png)
第三步、创建opencv工程
![](https://img.haomeiwen.com/i3236595/630fea3ac954a3b0.png)
![](https://img.haomeiwen.com/i3236595/8da54cf8fdb8a092.png)
第四步:配置头文件和库文件
![](https://img.haomeiwen.com/i3236595/807ea736e9f4d259.png)
![](https://img.haomeiwen.com/i3236595/aba4b55f5e02b07d.png)
将库文件拖入项目中
![](https://img.haomeiwen.com/i3236595/8ac03b430dbe9528.png)
![](https://img.haomeiwen.com/i3236595/0709d6f29ddfad88.png)
编写opencv代码
![](https://img.haomeiwen.com/i3236595/a4d11f451f264f6b.png)
运行程序
![](https://img.haomeiwen.com/i3236595/cd0da0ed67d159d6.png)
动态库需要要签名,不签名就不让用,接下来需要对dylib进行签名
codesign -f -s "Apple Development: 8613518120306 (FZ3TB8THGR)" /usr/local/Cellar/opencv/4.5.2_4/lib/*.dylib
![](https://img.haomeiwen.com/i3236595/6d755356e10a32e8.png)
网友评论