野火EBF6ULL开发板配置python图像处理环境

  • 平台:野火EBF6ULL开发板

  • 系统:Debian 

  • Debian:imx6ull-lubancat-carp-console-armhf-2022-02-10.img

  • 目标Python版本:Python3.7

    注意:此处的操作是在野火EBF6ULL开发板上(运行的是Debian系统),而非虚拟机。

首先 使用apt命令更新索引包

sudo apt-get update
sudo apt-get -y upgrade

手动安装python3

sudo apt-get -y install python3

查看是否安装成功

python3 -v

//出现以下内容表示安装成功
python 3.7.3

安装pip包管理工具

sudo apt-get -y install python3-pip

验证安装是否成功

pip3 --version

//出现以下内容表示安装成功
pip 18.1 from /usr/lib/python3/dist-packages/pip (python 3.7)

安装相关依赖

sudo apt-get install -y build-essential

sudo apt-get install -y cmake

sudo apt-get install -y pkg-config

sudo apt-get install -y libilmbase23

sudo apt-get install -y libilmbase-dev

sudo apt-get install -y libopenexr23

sudo apt-get install -y libgstreamer1.0-0

sudo apt-get install -y libjpeg-dev

sudo apt-get install -y libtiff5-dev

sudo apt-get install -y libpng-dev

sudo apt-get install -y libavcodec58

sudo apt-get install -y libavformat58

sudo apt-get install -y libswscale5

sudo apt-get install -y git

sudo apt-get install -y wget

sudo apt-get install -y libjasper-dev

安装需要的python包

//安装numpy
wget https://cloud.embedfire.com/software/packages/numpy-1.18.5.zip
pip3 install numpy-1.18.5.zip
//安装python-opencv
wget https://cloud.embedfire.com/software/packages/opencv_python-3.4.6.27-cp37-cp37m-linux_armv7l.whl

pip3 install opencv_python-3.4.6.27-cp37-cp37m-linux_armv7l.whl

测试环境是否配置成功

测试代码

#检测光斑圆心代码

import cv2
import numpy as np

img = cv2.imread('D:/opencv/yuan/2.png')
GrayImage = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)  # 灰度化
th1 = cv2.GaussianBlur(GrayImage, (5, 5), 0)
th2 = cv2.adaptiveThreshold(th1, 255, cv2.ADAPTIVE_THRESH_MEAN_C, cv2.THRESH_BINARY, 7, 5)
kernel = np.ones((5, 5), np.uint8)  # 创建全一矩阵,数值类型设置为uint8
erosion = cv2.erode(th1, kernel, iterations=1)  # 腐蚀处理
dilation = cv2.dilate(erosion, kernel, iterations=1)  # 膨胀处理
circles = cv2.HoughCircles(dilation, cv2.HOUGH_GRADIENT, 1, 100, param1=200, param2=30, minRadius=5,
                           maxRadius=400)
print(circles)
circles = np.uint16(np.around(circles))

print(circles)
P = circles[0]  # 去掉circles数组一层外括号
for i in P:
    # 画出外圆
    cv2.circle(img, (i[0], i[1]), i[2], (0, 150, 0), 2)  # 第二参数()内是圆心坐标,第三参数是半径,第四参数()内是颜色,第五参数是线条粗细
    # 画出圆心
    cv2.circle(img, (i[0], i[1]), 2, (0, 0, 255), 3)
    X = int(i[0])
    Y = int(i[1])
    print("圆心坐标为:", (X, Y))
野火EBF6ULL开发板配置python图像处理环境_第1张图片 例子用的图像
#出现结果,则表明运行成功

[[[640.5 360.5  41.1]]]
[[[640 360  41]]]
圆心坐标为: (640, 360)

 如果报错

提示:ImportError: libcblas.so.3: cannot open shared object file: No such file or directory

解决方法,安装依赖

sudo apt-get install libcblas-dev
sudo apt-get install libhdf5-dev
sudo apt-get install libhdf5-serial-dev
sudo apt-get install libatlas-base-dev
sudo apt-get install libjasper-dev 
sudo apt-get install libqtgui4 
sudo apt-get install libqt4-test

你可能感兴趣的:(debian,arm,python)