PI3 B+ 编译opencv 3.4.1出错

/src/gms.cpp.o
[ 86%] Building CXX object modules/xfeatures2d/CMakeFiles/opencv_xfeatures2d.dir/src/sift.cpp.o
[ 87%] Building CXX object modules/xfeatures2d/CMakeFiles/opencv_xfeatures2d.dir/src/pct_signatures_sqfd.cpp.o
[ 87%] Building CXX object modules/xfeatures2d/CMakeFiles/opencv_xfeatures2d.dir/src/boostdesc.cpp.o
/home/pi/opencv_contrib-3.4.1/modules/xfeatures2d/src/boostdesc.cpp:653:37: fatal error: boostdesc_bgm.i: 没有那个文件或目录
           #include "boostdesc_bgm.i"
                                     ^
compilation terminated.
modules/xfeatures2d/CMakeFiles/opencv_xfeatures2d.dir/build.make:428: recipe for target 'modules/xfeatures2d/CMakeFiles/opencv_xfeatures2d.dir/src/boostdesc.cpp.o' failed
make[2]: *** [modules/xfeatures2d/CMakeFiles/opencv_xfeatures2d.dir/src/boostdesc.cpp.o] Error 1
CMakeFiles/Makefile2:17493: recipe for target 'modules/xfeatures2d/CMakeFiles/opencv_xfeatures2d.dir/all' failed
make[1]: *** [modules/xfeatures2d/CMakeFiles/opencv_xfeatures2d.dir/all] Error 2
Makefile:146: recipe for target 'all' failed
make: *** [all] Error 2
网上说是文件有问题

PI3 B+ 编译opencv 3.4.1出错_第1张图片

 

打开CMakeDownloadLog.txt内容

use_cache "/home/pi/opencv-3.4.1/.cache"
do_unpack "v1.0.0a3.tar.gz" "adb1c512e09ca2c7a6faef36f9c53e59" "https://github.com/tiny-dnn/tiny-dnn/archive/v1.0.0a3.tar.gz" "/home/pi/opencv-3.4.1/release/3rdparty/tinydnn"
#cmake_download "/home/pi/opencv-3.4.1/.cache/tiny_dnn/adb1c512e09ca2c7a6faef36f9c53e59-v1.0.0a3.tar.gz" "https://github.com/tiny-dnn/tiny-dnn/archive/v1.0.0a3.tar.gz"
# Protocol "https" not supported or disabled in libcurl
# Closing connection -1

do_copy "boostdesc_bgm.i" "0ea90e7a8f3f7876d450e4149c97c74f" "https://raw.githubusercontent.com/opencv/opencv_3rdparty/34e4206aef44d50e6bbcd0ab06354b52e7466d26/boostdesc_bgm.i" "/home/pi/opencv-3.4.1/release/downloads/xfeatures2d"
#missing "/home/pi/opencv-3.4.1/release/downloads/xfeatures2d/boostdesc_bgm.i"
#cmake_download "/home/pi/opencv-3.4.1/.cache/xfeatures2d/boostdesc/0ea90e7a8f3f7876d450e4149c97c74f-boostdesc_bgm.i" "https://raw.githubusercontent.com/opencv/opencv_3rdparty/34e4206aef44d50e6bbcd0ab06354b52e7466d26/boostdesc_bgm.i"
# Protocol "https" not supported or disabled in libcurl
# Closing connection -1

do_copy "boostdesc_bgm_bi.i" "232c966b13651bd0e46a1497b0852191" "https://raw.githubusercontent.com/opencv/opencv_3rdparty/34e4206aef44d50e6bbcd0ab06354b52e7466d26/boostdesc_bgm_bi.i" "/home/pi/opencv-3.4.1/release/downloads/xfeatures2d"
#missing "/home/pi/opencv-3.4.1/release/downloads/xfeatures2d/boostdesc_bgm_bi.i"
#cmake_download "/home/pi/opencv-3.4.1/.cache/xfeatures2d/boostdesc/232c966b13651bd0e46a1497b0852191-boostdesc_bgm_bi.i" "https://raw.githubusercontent.com/opencv/opencv_3rdparty/34e4206aef44d50e6bbcd0ab06354b52e7466d26/boostdesc_bgm_bi.i"
# Protocol "https" not supported or disabled in libcurl
# Closing connection -1

do_copy "boostdesc_bgm_hd.i" "324426a24fa56ad9c5b8e3e0b3e5303e" "https://raw.githubusercontent.com/opencv/opencv_3rdparty/34e4206aef44d50e6bbcd0ab06354b52e7466d26/boostdesc_bgm_hd.i" "/home/pi/opencv-3.4.1/release/downloads/xfeatures2d"
#missing "/home/pi/opencv-3.4.1/release/downloads/xfeatures2d/boostdesc_bgm_hd.i"
#cmake_download "/home/pi/opencv-3.4.1/.cache/xfeatures2d/boostdesc/324426a24fa56ad9c5b8e3e0b3e5303e-boostdesc_bgm_hd.i" "https://raw.githubusercontent.com/opencv/opencv_3rdparty/34e4206aef44d50e6bbcd0ab06354b52e7466d26/boostdesc_bgm_hd.i"
# Protocol "https" not supported or disabled in libcurl
# Closing connection -1

do_copy "boostdesc_binboost_064.i" "202e1b3e9fec871b04da31f7f016679f" "https://raw.githubusercontent.com/opencv/opencv_3rdparty/34e4206aef44d50e6bbcd0ab06354b52e7466d26/boostdesc_binboost_064.i" "/home/pi/opencv-3.4.1/release/downloads/xfeatures2d"
#missing "/home/pi/opencv-3.4.1/release/downloads/xfeatures2d/boostdesc_binboost_064.i"
#cmake_download "/home/pi/opencv-3.4.1/.cache/xfeatures2d/boostdesc/202e1b3e9fec871b04da31f7f016679f-boostdesc_binboost_064.i" "https://raw.githubusercontent.com/opencv/opencv_3rdparty/34e4206aef44d50e6bbcd0ab06354b52e7466d26/boostdesc_binboost_064.i"
# Protocol "https" not supported or disabled in libcurl
# Closing connection -1

do_copy "boostdesc_binboost_128.i" "98ea99d399965c03d555cef3ea502a0b" "https://raw.githubusercontent.com/opencv/opencv_3rdparty/34e4206aef44d50e6bbcd0ab06354b52e7466d26/boostdesc_binboost_128.i" "/home/pi/opencv-3.4.1/release/downloads/xfeatures2d"
#missing "/home/pi/opencv-3.4.1/release/downloads/xfeatures2d/boostdesc_binboost_128.i"
#cmake_download "/home/pi/opencv-3.4.1/.cache/xfeatures2d/boostdesc/98ea99d399965c03d555cef3ea502a0b-boostdesc_binboost_128.i" "https://raw.githubusercontent.com/opencv/opencv_3rdparty/34e4206aef44d50e6bbcd0ab06354b52e7466d26/boostdesc_binboost_128.i"
# Protocol "https" not supported or disabled in libcurl
# Closing connection -1

do_copy "boostdesc_binboost_256.i" "e6dcfa9f647779eb1ce446a8d759b6ea" "https://raw.githubusercontent.com/opencv/opencv_3rdparty/34e4206aef44d50e6bbcd0ab06354b52e7466d26/boostdesc_binboost_256.i" "/home/pi/opencv-3.4.1/release/downloads/xfeatures2d"
#missing "/home/pi/opencv-3.4.1/release/downloads/xfeatures2d/boostdesc_binboost_256.i"
#cmake_download "/home/pi/opencv-3.4.1/.cache/xfeatures2d/boostdesc/e6dcfa9f647779eb1ce446a8d759b6ea-boostdesc_binboost_256.i" "https://raw.githubusercontent.com/opencv/opencv_3rdparty/34e4206aef44d50e6bbcd0ab06354b52e7466d26/boostdesc_binboost_256.i"
# Protocol "https" not supported or disabled in libcurl
# Closing connection -1

do_copy "boostdesc_lbgm.i" "0ae0675534aa318d9668f2a179c2a052" "https://raw.githubusercontent.com/opencv/opencv_3rdparty/34e4206aef44d50e6bbcd0ab06354b52e7466d26/boostdesc_lbgm.i" "/home/pi/opencv-3.4.1/release/downloads/xfeatures2d"
#missing "/home/pi/opencv-3.4.1/release/downloads/xfeatures2d/boostdesc_lbgm.i"
#cmake_download "/home/pi/opencv-3.4.1/.cache/xfeatures2d/boostdesc/0ae0675534aa318d9668f2a179c2a052-boostdesc_lbgm.i" "https://raw.githubusercontent.com/opencv/opencv_3rdparty/34e4206aef44d50e6bbcd0ab06354b52e7466d26/boostdesc_lbgm.i"
# Protocol "https" not supported or disabled in libcurl
# Closing connection -1

do_copy "vgg_generated_48.i" "e8d0dcd54d1bcfdc29203d011a797179" "https://raw.githubusercontent.com/opencv/opencv_3rdparty/fccf7cd6a4b12079f73bbfb21745f9babcd4eb1d/vgg_generated_48.i" "/home/pi/opencv-3.4.1/release/downloads/xfeatures2d"
#missing "/home/pi/opencv-3.4.1/release/downloads/xfeatures2d/vgg_generated_48.i"
#cmake_download "/home/pi/opencv-3.4.1/.cache/xfeatures2d/vgg/e8d0dcd54d1bcfdc29203d011a797179-vgg_generated_48.i" "https://raw.githubusercontent.com/opencv/opencv_3rdparty/fccf7cd6a4b12079f73bbfb21745f9babcd4eb1d/vgg_generated_48.i"
# Protocol "https" not supported or disabled in libcurl
# Closing connection -1

do_copy "vgg_generated_64.i" "7126a5d9a8884ebca5aea5d63d677225" "https://raw.githubusercontent.com/opencv/opencv_3rdparty/fccf7cd6a4b12079f73bbfb21745f9babcd4eb1d/vgg_generated_64.i" "/home/pi/opencv-3.4.1/release/downloads/xfeatures2d"
#missing "/home/pi/opencv-3.4.1/release/downloads/xfeatures2d/vgg_generated_64.i"
#cmake_download "/home/pi/opencv-3.4.1/.cache/xfeatures2d/vgg/7126a5d9a8884ebca5aea5d63d677225-vgg_generated_64.i" "https://raw.githubusercontent.com/opencv/opencv_3rdparty/fccf7cd6a4b12079f73bbfb21745f9babcd4eb1d/vgg_generated_64.i"
# Protocol "https" not supported or disabled in libcurl
# Closing connection -1

do_copy "vgg_generated_80.i" "7cd47228edec52b6d82f46511af325c5" "https://raw.githubusercontent.com/opencv/opencv_3rdparty/fccf7cd6a4b12079f73bbfb21745f9babcd4eb1d/vgg_generated_80.i" "/home/pi/opencv-3.4.1/release/downloads/xfeatures2d"
#missing "/home/pi/opencv-3.4.1/release/downloads/xfeatures2d/vgg_generated_80.i"
#cmake_download "/home/pi/opencv-3.4.1/.cache/xfeatures2d/vgg/7cd47228edec52b6d82f46511af325c5-vgg_generated_80.i" "https://raw.githubusercontent.com/opencv/opencv_3rdparty/fccf7cd6a4b12079f73bbfb21745f9babcd4eb1d/vgg_generated_80.i"
# Protocol "https" not supported or disabled in libcurl
# Closing connection -1

do_copy "vgg_generated_120.i" "151805e03568c9f490a5e3a872777b75" "https://raw.githubusercontent.com/opencv/opencv_3rdparty/fccf7cd6a4b12079f73bbfb21745f9babcd4eb1d/vgg_generated_120.i" "/home/pi/opencv-3.4.1/release/downloads/xfeatures2d"
#missing "/home/pi/opencv-3.4.1/release/downloads/xfeatures2d/vgg_generated_120.i"
#cmake_download "/home/pi/opencv-3.4.1/.cache/xfeatures2d/vgg/151805e03568c9f490a5e3a872777b75-vgg_generated_120.i" "https://raw.githubusercontent.com/opencv/opencv_3rdparty/fccf7cd6a4b12079f73bbfb21745f9babcd4eb1d/vgg_generated_120.i"
# Protocol "https" not supported or disabled in libcurl
# Closing connection -1

do_copy "face_landmark_model.dat" "7505c44ca4eb54b4ab1e4777cb96ac05" "https://raw.githubusercontent.com/opencv/opencv_3rdparty/8afa57abc8229d611c4937165d20e2a2d9fc5a12/face_landmark_model.dat" "/home/pi/opencv-3.4.1/release/share/OpenCV/testdata/cv/face/"
#missing "/home/pi/opencv-3.4.1/release/share/OpenCV/testdata/cv/face//face_landmark_model.dat"
#cmake_download "/home/pi/opencv-3.4.1/.cache/data/7505c44ca4eb54b4ab1e4777cb96ac05-face_landmark_model.dat" "https://raw.githubusercontent.com/opencv/opencv_3rdparty/8afa57abc8229d611c4937165d20e2a2d9fc5a12/face_landmark_model.dat"
# Protocol "https" not supported or disabled in libcurl
# Closing connection -1

do_copy "res10_300x300_ssd_iter_140000.caffemodel" "afbb6037fd180e8d2acb3b58ca737b9e" "https://raw.githubusercontent.com/opencv/opencv_3rdparty/b2bfc75f6aea5b1f834ff0f0b865a7c18ff1459f/res10_300x300_ssd_iter_140000.caffemodel" "/home/pi/opencv-3.4.1/samples/dnn/face_detector"
#missing "/home/pi/opencv-3.4.1/samples/dnn/face_detector/res10_300x300_ssd_iter_140000.caffemodel"
#cmake_download "/home/pi/opencv-3.4.1/.cache/dnn_face_detector/afbb6037fd180e8d2acb3b58ca737b9e-res10_300x300_ssd_iter_140000.caffemodel" "https://raw.githubusercontent.com/opencv/opencv_3rdparty/b2bfc75f6aea5b1f834ff0f0b865a7c18ff1459f/res10_300x300_ssd_iter_140000.caffemodel"
# Protocol "https" not supported or disabled in libcurl
# Closing connection -1

 

个人估计是访问GITHUB出错引起的。墙内无法访问,于是 参照https://blog.csdn.net/qq_30155503/article/details/79643403下载https://download.csdn.net/download/qq_30155503/10305922用FTP传到pi中解压

unzip opencv3_cmake_files.zip

进入opencv3_cmake_files文件夹,复制*.i的文件到/home/pi/opencv-3.4.1/release/downloads/xfeatures2d/文件夹

sudo cp -i *.i ../opencv-3.4.1/release/downloads/xfeatures2d/
cd ~/opencv-3.4.1/release/

make

 

[ 87%] Built target opencv_test_videostab
[ 87%] Built target opencv_xfeatures2d_pch_dephelp
[ 87%] Built target pch_Generate_opencv_xfeatures2d
[ 87%] Building CXX object modules/xfeatures2d/CMakeFiles/opencv_xfeatures2d.dir/src/boostdesc.cpp.o
/home/pi/opencv_contrib-3.4.1/modules/xfeatures2d/src/boostdesc.cpp:653:37: fatal error: boostdesc_bgm.i: 没有那个文件或目录
           #include "boostdesc_bgm.i"
                                     ^
compilation terminated.
modules/xfeatures2d/CMakeFiles/opencv_xfeatures2d.dir/build.make:428: recipe for target 'modules/xfeatures2d/CMakeFiles/opencv_xfeatures2d.dir/src/boostdesc.cpp.o' failed
make[2]: *** [modules/xfeatures2d/CMakeFiles/opencv_xfeatures2d.dir/src/boostdesc.cpp.o] Error 1
CMakeFiles/Makefile2:17493: recipe for target 'modules/xfeatures2d/CMakeFiles/opencv_xfeatures2d.dir/all' failed
make[1]: *** [modules/xfeatures2d/CMakeFiles/opencv_xfeatures2d.dir/all] Error 2
Makefile:146: recipe for target 'all' failed
make: *** [all] Error 2
问题依旧。换一下*.i文件的目录

sudo cp -i ~/opencv3_cmake_files/*.i ~/opencv_contrib-3.4.1/modules/xfeatures2d/src/

sudo make

暂时又可以跑了。

[ 98%] Building CXX object modules/stitching/CMakeFiles/opencv_stitching_pch_dephelp.dir/opencv_stitching_pch_dephelp.cxx.o
In file included from /home/pi/opencv-3.4.1/modules/stitching/include/opencv2/stitching.hpp:49:0,
                 from /home/pi/opencv-3.4.1/modules/stitching/src/precomp.hpp:59,
                 from /home/pi/opencv-3.4.1/release/modules/stitching/opencv_stitching_pch_dephelp.cxx:1:
/home/pi/opencv-3.4.1/modules/stitching/include/opencv2/stitching/detail/matchers.hpp:52:42: fatal error: opencv2/xfeatures2d/cuda.hpp: 没有那个文件或目录
 #  include "opencv2/xfeatures2d/cuda.hpp"
                                          ^
compilation terminated.
modules/stitching/CMakeFiles/opencv_stitching_pch_dephelp.dir/build.make:54: recipe for target 'modules/stitching/CMakeFiles/opencv_stitching_pch_dephelp.dir/opencv_stitching_pch_dephelp.cxx.o' failed
make[2]: *** [modules/stitching/CMakeFiles/opencv_stitching_pch_dephelp.dir/opencv_stitching_pch_dephelp.cxx.o] Error 1
CMakeFiles/Makefile2:21841: recipe for target 'modules/stitching/CMakeFiles/opencv_stitching_pch_dephelp.dir/all' failed
make[1]: *** [modules/stitching/CMakeFiles/opencv_stitching_pch_dephelp.dir/all] Error 2
Makefile:146: recipe for target 'all' failed
make: *** [all] Error 2
 

找不到文件,那么全部把opencv2/xfeatures2d/cuda.hpp的文件考到对应目录

 29%] Built target pch_Generate_opencv_phase_unwrapping
In file included from /home/pi/opencv-3.4.1/release/modules/stitching/opencv_stitching_pch_dephelp.cxx:1:0:
/home/pi/opencv-3.4.1/modules/stitching/src/precomp.hpp:91:42: fatal error: opencv2/xfeatures2d/cuda.hpp: 没有那个文件或目录
 #  include "opencv2/xfeatures2d/cuda.hpp"
                                          ^
compilation terminated.
modules/stitching/CMakeFiles/opencv_stitching_pch_dephelp.dir/build.make:54: recipe for target 'modules/stitching/CMakeFiles/opencv_stitching_pch_dephelp.dir/opencv_stitching_pch_dephelp.cxx.o' failed
make[2]: *** [modules/stitching/CMakeFiles/opencv_stitching_pch_dephelp.dir/opencv_stitching_pch_dephelp.cxx.o] Error 1
CMakeFiles/Makefile2:21841: recipe for target 'modules/stitching/CMakeFiles/opencv_stitching_pch_dephelp.dir/all' failed
make[1]: *** [modules/stitching/CMakeFiles/opencv_stitching_pch_dephelp.dir/all] Error 2
make[1]: *** 正在等待未完成的任务....
[ 29%] [ 29%] Built target pch_Generate_opencv_photo
Built target pch_Generate_opencv_test_phase_unwrapping
[ 29%] Built target gen_opencv_python_source
Makefile:146: recipe for target 'all' failed
make: *** [all] Error 2
 

找不到文件,那么全部把opencv2/xfeatures2d/cuda.hpp的文件考到对应目录

找资料顺便学了一条新指令,用4个核去编译带 -j4就可以了,不然编译很慢。

sudo make -j4

PI3 B+ 编译opencv 3.4.1出错_第2张图片

这时候卡住了,其实还是在运行的,睡一觉起来看见已经完成了

PI3 B+ 编译opencv 3.4.1出错_第3张图片

sudo make install

sudo ldconfig
测试

pi@raspberrypi:~/opencv-3.4.1/release $ python
Python 2.7.13 (default, Nov 24 2017, 17:33:09) 
[GCC 6.3.0 20170516] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv2
>>> cv2.__version__
'3.4.1'
>>> 

说明安装成功了。

总结一下,由于github被封,所有opencv文件都要自己从CSDN下载,解压。编译出现的问题都是缺少文件或者路径不对,通过自行下载或者复制对应文件到对应路径解决。
 

你可能感兴趣的:(OPENCV)