opencv4 学习 01 环境搭建
1. 环境win10:
- opencv-4.4.0
- opencv_contrib-4.4.0
- cmake
- vs2017
2. 编译工程
配置cmake选项,设置 OPENCV_EXTRA_MODULES_PATH 变量值为 G:\tools\opencv4\opencv_contrib-4.4.0\modules。
上 https://www.ipaddress.com/ 查询 raw.githubusercontent.com 的ip 地址,然后在hosts文件最后加入:
199.232.68.133 raw.githubusercontent.com
(其中199.232.68.133为我查询时的ip,实际以你查到的为准)
注意:一定要配置上述ip地址,基本可以解决你所有的 下载出错 的问题。如果下载依然出错,请参考下面的手动下载方法
然后单击 Generate 按钮,生成工程。
3. 生成过程中遇到的error:
error1:
- ippicv 无法下载
-
错误 C1083 无法打开包括文件: “boostdesc_bgm.i”: No such file or directory opencv_xfeatures2d g:\tools\opencv4\opencv_contrib-4.4.0\modules\xfeatures2d\src\boostdesc.cpp 654
- 错误 C1083 无法打开包括文件: “vgg_generated_120.i”: No such file or directory opencv_xfeatures2d g:\tools\opencv4\opencv_contrib-4.4.0\modules\xfeatures2d\src\vgg.cpp 490
解决方法:打开 build文件夹(你生成工程的文件夹) 下的 CMakeDownloadLog.txt 文件,查找 boostdesc_bgm.i 等选项,可以看到文件的下载地址,手动下载文件到指定目录,我的下载脚本如下:
# boostdesc curl https://raw.githubusercontent.com/opencv/opencv_3rdparty/34e4206aef44d50e6bbcd0ab06354b52e7466d26/boostdesc_bgm.i > 0ea90e7a8f3f7876d450e4149c97c74f-boostdesc_bgm.i curl https://raw.githubusercontent.com/opencv/opencv_3rdparty/34e4206aef44d50e6bbcd0ab06354b52e7466d26/boostdesc_bgm_bi.i > 232c966b13651bd0e46a1497b0852191-boostdesc_bgm_bi.i curl https://raw.githubusercontent.com/opencv/opencv_3rdparty/34e4206aef44d50e6bbcd0ab06354b52e7466d26/boostdesc_bgm_hd.i > 324426a24fa56ad9c5b8e3e0b3e5303e-boostdesc_bgm_hd.i curl https://raw.githubusercontent.com/opencv/opencv_3rdparty/34e4206aef44d50e6bbcd0ab06354b52e7466d26/boostdesc_binboost_064.i > 202e1b3e9fec871b04da31f7f016679f-boostdesc_binboost_064.i curl https://raw.githubusercontent.com/opencv/opencv_3rdparty/34e4206aef44d50e6bbcd0ab06354b52e7466d26/boostdesc_binboost_128.i > 98ea99d399965c03d555cef3ea502a0b-boostdesc_binboost_128.i curl https://raw.githubusercontent.com/opencv/opencv_3rdparty/34e4206aef44d50e6bbcd0ab06354b52e7466d26/boostdesc_binboost_256.i > e6dcfa9f647779eb1ce446a8d759b6ea-boostdesc_binboost_256.i curl https://raw.githubusercontent.com/opencv/opencv_3rdparty/34e4206aef44d50e6bbcd0ab06354b52e7466d26/boostdesc_lbgm.i > 0ae0675534aa318d9668f2a179c2a052-boostdesc_lbgm.i # vgg curl https://raw.githubusercontent.com/opencv/opencv_3rdparty/fccf7cd6a4b12079f73bbfb21745f9babcd4eb1d/vgg_generated_48.i > e8d0dcd54d1bcfdc29203d011a797179-vgg_generated_48.i curl https://raw.githubusercontent.com/opencv/opencv_3rdparty/fccf7cd6a4b12079f73bbfb21745f9babcd4eb1d/vgg_generated_64.i > 7126a5d9a8884ebca5aea5d63d677225-vgg_generated_64.i curl https://raw.githubusercontent.com/opencv/opencv_3rdparty/fccf7cd6a4b12079f73bbfb21745f9babcd4eb1d/vgg_generated_80.i > 7cd47228edec52b6d82f46511af325c5-vgg_generated_80.i curl https://raw.githubusercontent.com/opencv/opencv_3rdparty/fccf7cd6a4b12079f73bbfb21745f9babcd4eb1d/vgg_generated_120.i > 151805e03568c9f490a5e3a872777b75-vgg_generated_120.i
# ippicv
curl https://raw.githubusercontent.com/opencv/opencv_3rdparty/a56b6ac6f030c312b2dce17430eef13aed9af274/ippicv/ippicv_2020_win_intel64_20191018_general.zip > 879741a7946b814455eee6c6ffde2984-ippicv_2020_win_intel64_20191018_general.zip
注意保存的文件的名字 要与你的 CMakeDownloadLog.txt 文件里的提示的文件名一致。
文件目录结构如下:
opencv源码
.| cache
| xfeatures2d
| boostdesc
0ae0675534aa318d9668f2a179c2a052-boostdesc_lbgm.i
0ea90e7a8f3f7876d450e4149c97c74f-boostdesc_bgm.i
......
| vgg
7cd47228edec52b6d82f46511af325c5-vgg_generated_80.i
7126a5d9a8884ebca5aea5d63d677225-vgg_generated_64.i
| ippicv
879741a7946b814455eee6c6ffde2984-ippicv_2020_win_intel64_20191018_general.zip
......
下载过程中会遇到地址无法访问的问题,即使你开 vpn,也无法访问,主要是因为 raw.githubusercontent.com 的ip不对,直接
上 https://www.ipaddress.com/ 查找其对应的 ip 地址,然后修改host 文件(在该目录下C:\Windows\System32\drivers\etc),
在文件末尾加上:
199.232.68.133 raw.githubusercontent.com
(其中199.232.68.133为我查询时的ip,实际以你查到的为准)
4、使用vs2017打开工程
在 Release 模式下,生成 “ALL_BUILD” 工程,然后再选择 “INSTALL” --> "仅用于项目" --> "仅生成INSTALL"
参开链接:
https://blog.csdn.net/chujian_CSDN/article/details/106137508
https://blog.csdn.net/u014085595/article/details/102847499