S3 Zeta使用python和opencv

Posted ka布

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了S3 Zeta使用python和opencv相关的知识,希望对你有一定的参考价值。

一、为SDK的Buildroot打上下面的补丁

diff --git a/package/opencv/Config.in b/package/opencv/Config.in
index c046baa..6cb6183 100644
--- a/package/opencv/Config.in
+++ b/package/opencv/Config.in
@@ -119,7 +119,12 @@ config BR2_PACKAGE_OPENCV_LIB_PHOTO
     help
       Include opencv_photo module into the OpenCV build.
 
-comment "opencv_python module requires numpy which is not yet available."
+config BR2_PACKAGE_OPENCV_LIB_PYTHON
+    bool "python"
+    depends on BR2_PACKAGE_PYTHON
+    help
+      Include opencv_python module into the OpenCV build.
+      No python example is installed.
 
 config BR2_PACKAGE_OPENCV_LIB_STITCHING
     bool "stitching"
diff --git a/package/opencv/opencv.mk b/package/opencv/opencv.mk
old mode 100644
new mode 100755
index 947589b..b00f293
--- a/package/opencv/opencv.mk
+++ b/package/opencv/opencv.mk
@@ -58,7 +58,6 @@ OPENCV_CONF_OPTS += \\
     -DBUILD_opencv_objdetect=$(if $(BR2_PACKAGE_OPENCV_LIB_OBJDETECT),ON,OFF) \\
     -DBUILD_opencv_ocl=OFF \\
     -DBUILD_opencv_photo=$(if $(BR2_PACKAGE_OPENCV_LIB_PHOTO),ON,OFF) \\
-    -DBUILD_opencv_python=OFF \\
     -DBUILD_opencv_stitching=$(if $(BR2_PACKAGE_OPENCV_LIB_STITCHING),ON,OFF) \\
     -DBUILD_opencv_superres=$(if $(BR2_PACKAGE_OPENCV_LIB_SUPERRES),ON,OFF) \\
     -DBUILD_opencv_ts=$(if $(BR2_PACKAGE_OPENCV_LIB_TS),ON,OFF) \\
@@ -138,7 +137,6 @@ OPENCV_CONF_OPTS += \\
 OPENCV_CONF_OPTS += \\
     -DBUILD_JASPER=OFF \\
     -DBUILD_JPEG=OFF \\
-    -DBUILD_NEW_PYTHON_SUPPORT=OFF \\
     -DBUILD_OPENEXR=OFF \\
     -DBUILD_PNG=OFF \\
     -DBUILD_TIFF=OFF \\
@@ -235,6 +233,22 @@ else
 OPENCV_CONF_OPTS += -DWITH_V4L=OFF -DWITH_LIBV4L=OFF
 endif
 
+ifeq ($(BR2_PACKAGE_OPENCV_LIB_PYTHON),y)
+OPENCV_CONF_OPTS += \\
+    -DBUILD_opencv_python=ON \\
+    -DBUILD_NEW_PYTHON_SUPPORT=ON \\
+    -DPYTHON_EXECUTABLE=$(HOST_DIR)/usr/bin/python2                               \\
+    -DPYTHON_INCLUDE_DIR=$(STAGING_DIR)/usr/include/python$(PYTHON_VERSION_MAJOR) \\
+    -DPYTHON_LIBRARY=$(STAGING_DIR)/usr/lib/libpython$(PYTHON_VERSION_MAJOR).so   \\
+    -DPYTHON_NUMPY_INCLUDE_DIR=$(STAGING_DIR)/usr/lib/python$(PYTHON_VERSION_MAJOR)/site-packages/numpy/core/include \\
+    -DPYTHON_NUMPY_VERSION=$(PYTHON_NUMPY_VERSION)
+OPENCV_DEPENDENCIES += python python-numpy
+else
+OPENCV_CONF_OPTS += \\
+    -DBUILD_opencv_python=ON \\
+    -DBUILD_NEW_PYTHON_SUPPORT=OFF
+endif
+
 # Installation hooks:
 define OPENCV_CLEAN_INSTALL_DOC
     $(RM) -fr $(TARGET_DIR)/usr/share/OpenCV/doc

二、配置Buildroot

执行cout && make menuconfig进入Buildroot界面,以下图:

按照下面的顺序选择opencv

Target packages  --->
    Libraries  --->
        Graphics  --->
            opencv-2.4  --->

按照下面的顺序选择python

Target packages  --->
    Interpreter languages and scripting  --->
        python

opencv及python的子包视实际情况进行选择。

三、编译、生成固件

执行croot && zmake all

 

以上是关于S3 Zeta使用python和opencv的主要内容,如果未能解决你的问题,请参考以下文章

使用Python+opencv+k-means根据扫描图片计算叶片面积

将图像从 opencv 上传到 s3 存储桶

c ++ opencv中的等价matlab代码

如何使用 django (python) 和 s3 上传文件?

为使用 OpenCV 的 C++ 代码编写 Python 绑定

python 使用Python,OpenCV和Tesseract OCR引擎使用10行代码绕过Captcha