ubuntu raspberry pi 3b+ 上的 Opencv 构建过程错误

ubuntu raspberry pi 3b+ 上的 Opencv 构建过程错误

你好,我需要一些帮助,我试图在 python 3.7 中安装 opencv,但我在互联网上发现它不受支持,所以你必须从头开始构建它。

我遵循了本教程这里我可以成功地将其构建到 100%,直到出现错误。

在此处输入图片描述

[100%] Building CXX object modules/python2/CMakeFiles/opencv_python2.dir/__/src2                                                                                        /cv2.cpp.o
/home/ubuntu/opencv-4.1.2/build/modules/python_bindings_generator/pyopencv_gener                                                                                        ated_types_content.h: In function ‘PyObject* pyopencv_cv_FileNode_at(PyObject*,                                                                                         PyObject*, PyObject*)’:
/home/ubuntu/opencv-4.1.2/build/modules/python_bindings_generator/pyopencv_gener                                                                                        ated_types_content.h:7784:47: warning: implicitly-declared ‘cv::FileNode& cv::Fi                                                                                        leNode::operator=(const cv::FileNode&)’ is deprecated [-Wdeprecated-copy]
 7784 |         ERRWRAP2(retval = _self_->operator[](i));
      |                                               ^
/home/ubuntu/opencv-4.1.2/modules/python/src2/cv2.cpp:110:5: note: in definition                                                                                         of macro ‘ERRWRAP2’
  110 |     expr; \
      |     ^~~~
In file included from /home/ubuntu/opencv-4.1.2/modules/core/include/opencv2/cor                                                                                        e.hpp:60,
                 from /home/ubuntu/opencv-4.1.2/build/modules/python_bindings_ge                                                                                        nerator/pyopencv_generated_include.h:1,
                 from /home/ubuntu/opencv-4.1.2/modules/python/src2/cv2.cpp:32:
/home/ubuntu/opencv-4.1.2/modules/core/include/opencv2/core/persistence.hpp:511:                                                                                        5: note: because ‘cv::FileNode’ has user-provided ‘cv::FileNode::FileNode(const                                                                                         cv::FileNode&)’
  511 |     FileNode(const FileNode& node);
      |     ^~~~~~~~
/home/ubuntu/opencv-4.1.2/build/modules/python_bindings_generator/pyopencv_gener                                                                                        ated_types_content.h: In function ‘PyObject* pyopencv_cv_FileNode_getNode(PyObje                                                                                        ct*, PyObject*, PyObject*)’:
/home/ubuntu/opencv-4.1.2/build/modules/python_bindings_generator/pyopencv_gener                                                                                        ated_types_content.h:7826:54: warning: implicitly-declared ‘cv::FileNode& cv::Fi                                                                                        leNode::operator=(const cv::FileNode&)’ is deprecated [-Wdeprecated-copy]
 7826 |         ERRWRAP2(retval = _self_->operator[](nodename));
      |                                                      ^
/home/ubuntu/opencv-4.1.2/modules/python/src2/cv2.cpp:110:5: note: in definition                                                                                         of macro ‘ERRWRAP2’
  110 |     expr; \
      |     ^~~~
In file included from /home/ubuntu/opencv-4.1.2/modules/core/include/opencv2/cor                                                                                        e.hpp:60,
                 from /home/ubuntu/opencv-4.1.2/build/modules/python_bindings_ge                                                                                        nerator/pyopencv_generated_include.h:1,
                 from /home/ubuntu/opencv-4.1.2/modules/python/src2/cv2.cpp:32:
/home/ubuntu/opencv-4.1.2/modules/core/include/opencv2/core/persistence.hpp:511:                                                                                        5: note: because ‘cv::FileNode’ has user-provided ‘cv::FileNode::FileNode(const                                                                                         cv::FileNode&)’
  511 |     FileNode(const FileNode& node);
      |     ^~~~~~~~
In file included from /home/ubuntu/opencv-4.1.2/modules/python/src2/cv2.cpp:166                                                                                         :
/home/ubuntu/opencv-4.1.2/build/modules/python_bindings_generator/pyopencv_gener                                                                                        ated_types_content.h: In static member function ‘static bool PyOpenCV_Converter<                                                                                        cv::FileNode>::to(PyObject*, cv::FileNode&, const char*)’:
/home/ubuntu/opencv-4.1.2/build/modules/python_bindings_generator/pyopencv_gener                                                                                        ated_types_content.h:8182:20: warning: implicitly-declared ‘cv::FileNode& cv::Fi                                                                                        leNode::operator=(const cv::FileNode&)’ is deprecated [-Wdeprecated-copy]
 8182 |             dst = *dst_;
      |                    ^~~~
In file included from /home/ubuntu/opencv-4.1.2/modules/core/include/opencv2/cor                                                                                        e.hpp:60,
                 from /home/ubuntu/opencv-4.1.2/build/modules/python_bindings_ge                                                                                        nerator/pyopencv_generated_include.h:1,
                 from /home/ubuntu/opencv-4.1.2/modules/python/src2/cv2.cpp:32:
/home/ubuntu/opencv-4.1.2/modules/core/include/opencv2/core/persistence.hpp:511:                                                                                        5: note: because ‘cv::FileNode’ has user-provided ‘cv::FileNode::FileNode(const                                                                                         cv::FileNode&)’
  511 |     FileNode(const FileNode& node);
      |     ^~~~~~~~
/home/ubuntu/opencv-4.1.2/build/modules/python_bindings_generator/pyopencv_gener                                                                                        ated_types_content.h: In function ‘PyObject* pyopencv_cv_FileStorage_getFirstTop                                                                                        LevelNode(PyObject*, PyObject*, PyObject*)’:
/home/ubuntu/opencv-4.1.2/build/modules/python_bindings_generator/pyopencv_gener                                                                                        ated_types_content.h:8250:56: warning: implicitly-declared ‘cv::FileNode& cv::Fi                                                                                        leNode::operator=(const cv::FileNode&)’ is deprecated [-Wdeprecated-copy]
 8250 |         ERRWRAP2(retval = _self_->getFirstTopLevelNode());
      |                                                        ^
/home/ubuntu/opencv-4.1.2/modules/python/src2/cv2.cpp:110:5: note: in definition                                                                                         of macro ‘ERRWRAP2’
  110 |     expr; \
      |     ^~~~
In file included from /home/ubuntu/opencv-4.1.2/modules/core/include/opencv2/cor                                                                                        e.hpp:60,
                 from /home/ubuntu/opencv-4.1.2/build/modules/python_bindings_ge                                                                                        nerator/pyopencv_generated_include.h:1,
                 from /home/ubuntu/opencv-4.1.2/modules/python/src2/cv2.cpp:32:
/home/ubuntu/opencv-4.1.2/modules/core/include/opencv2/core/persistence.hpp:511:                                                                                        5: note: because ‘cv::FileNode’ has user-provided ‘cv::FileNode::FileNode(const                                                                                         cv::FileNode&)’
  511 |     FileNode(const FileNode& node);
      |     ^~~~~~~~
/home/ubuntu/opencv-4.1.2/build/modules/python_bindings_generator/pyopencv_gener                                                                                        ated_types_content.h: In function ‘PyObject* pyopencv_cv_FileStorage_getNode(PyO                                                                                        bject*, PyObject*, PyObject*)’:
/home/ubuntu/opencv-4.1.2/build/modules/python_bindings_generator/pyopencv_gener                                                                                        ated_types_content.h:8292:54: warning: implicitly-declared ‘cv::FileNode& cv::Fi                                                                                        leNode::operator=(const cv::FileNode&)’ is deprecated [-Wdeprecated-copy]
 8292 |         ERRWRAP2(retval = _self_->operator[](nodename));
      |                                                      ^
/home/ubuntu/opencv-4.1.2/modules/python/src2/cv2.cpp:110:5: note: in definition                                                                                         of macro ‘ERRWRAP2’
  110 |     expr; \
      |     ^~~~
In file included from /home/ubuntu/opencv-4.1.2/modules/core/include/opencv2/cor                                                                                        e.hpp:60,
                 from /home/ubuntu/opencv-4.1.2/build/modules/python_bindings_ge                                                                                        nerator/pyopencv_generated_include.h:1,
                 from /home/ubuntu/opencv-4.1.2/modules/python/src2/cv2.cpp:32:
/home/ubuntu/opencv-4.1.2/modules/core/include/opencv2/core/persistence.hpp:511:                                                                                        5: note: because ‘cv::FileNode’ has user-provided ‘cv::FileNode::FileNode(const                                                                                         cv::FileNode&)’
  511 |     FileNode(const FileNode& node);
      |     ^~~~~~~~
/home/ubuntu/opencv-4.1.2/build/modules/python_bindings_generator/pyopencv_gener                                                                                        ated_types_content.h: In function ‘PyObject* pyopencv_cv_FileStorage_root(PyObje                                                                                        ct*, PyObject*, PyObject*)’:
/home/ubuntu/opencv-4.1.2/build/modules/python_bindings_generator/pyopencv_gener                                                                                        ated_types_content.h:8401:49: warning: implicitly-declared ‘cv::FileNode& cv::Fi                                                                                        leNode::operator=(const cv::FileNode&)’ is deprecated [-Wdeprecated-copy]
 8401 |         ERRWRAP2(retval = _self_->root(streamidx));
      |                                                 ^
/home/ubuntu/opencv-4.1.2/modules/python/src2/cv2.cpp:110:5: note: in definition                                                                                         of macro ‘ERRWRAP2’
  110 |     expr; \
      |     ^~~~
In file included from /home/ubuntu/opencv-4.1.2/modules/core/include/opencv2/cor                                                                                        e.hpp:60,
                 from /home/ubuntu/opencv-4.1.2/build/modules/python_bindings_ge                                                                                        nerator/pyopencv_generated_include.h:1,
                 from /home/ubuntu/opencv-4.1.2/modules/python/src2/cv2.cpp:32:
/home/ubuntu/opencv-4.1.2/modules/core/include/opencv2/core/persistence.hpp:511:                                                                                        5: note: because ‘cv::FileNode’ has user-provided ‘cv::FileNode::FileNode(const                                                                                         cv::FileNode&)’
  511 |     FileNode(const FileNode& node);
      |     ^~~~~~~~

我正在运行的操作系统这里

我在 Raspberry pi 3b+ 上运行 Ubuntu Server

ubuntu@ubuntu:~/opencv-4.1.2/build$ uname -a Linux ubuntu
5.3.0-1017-raspi2 #19-Ubuntu SMP Thu Jan 16 18:25:50 UTC 2020 aarch64 aarch64 aarch64 GNU/Linux

这是我遇到的错误:

这是我遇到的错误,它被终止了

    c++: fatal error: Killed signal terminated program cc1plus
compilation terminated.
make[2]: *** [modules/python2/CMakeFiles/opencv_python2.dir/build.make:63: modules/python2/CMakeFiles/opencv_python2.dir/__/src2/cv2.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:9267: modules/python2/CMakeFiles/opencv_python2.dir/all] Error 2
make: *** [Makefile:163: all] Error 2
ubuntu@ubuntu:~/opencv-4.1.2/build$

希望得到一些帮助,谢谢。

答案1

我做了大量研究并找到了解决方案,因为没有人能够回答我的问题,所以我认为我可以在这里发布解决方案......

我使用这个自动脚本在我的 raspberry pi 中构建和安装 opencv ^_^,你可以下载它这里

在此处输入图片描述

如果您在构建过程中遇到困难,您可以随时尝试以下代码:

代码:

sudo dd if=/dev/zero of=/swapfile bs=64M count=16
sudo mkswap /swapfile
sudo swapon /swapfile

After compiling, you may wish to

Code:
sudo swapoff /swapfile
sudo rm /swapfile

参考 :这里

相关内容