Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the method of python application development in Linux embedded system?

2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article introduces the relevant knowledge of "what is the method of Linux embedded python application development". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

The platform demonstrated in this paper comes from ToradexColibri iMX6ARM embedded platform, which is a computer module platform based on NXP iMX6ARM processor and supporting single-core / dual-core Cortex-A9.

1. Prepare a). Colibri iMX6 ARM core version with ColibriEvaBoard carrier board, connect debug serial port UART1 to the development host to facilitate debugging.

Python and OpenCV components are not included in the default BSP of the Colibrii MX6 system. Users can install them online or recompile them based on the Ycoto/OpenEmbedded framework to generate BSP; with the required functions. We recommend the second method. Customized BSP is conducive to mass production programming.

. / commands related to online installation of Python and extension components

-

Root@colibri-imx6:~# opkg update

Root@colibri-imx6:~# opkg list | greppython

Root@colibri-imx6:~# opkg install python [optionally list additional packages...]

-

. / compiled based on the OpenEmbedded framework. For basic operations, please follow the instructions here. For files that need to be modified, please refer to the following. Refer to the image update method here.

. / local.conf file

Add the following to add the qtwebengine component to the generated image

-

IMAGE_INSTALL_append = "opencvpython3 python3-pip zbar"

PACKAGECONFIG_append_pn-opencv = "python3gstreamer"

-

two。 The test Python environment commands terminal execution on the development board.

-

Root@colibri-imx6:~# python3

Python 3.5.3 (default, Apr 11 2018 recorder 16 Apr 03VR 29)

[GCC 7.3.0] on linux

Type "help", "copyright", "credits" or "license" for moreinformation.

> import cv2

> cv2.version

'3.3.0While dev.'

-

The generated BSP contains Python3.5.3 and OpenCV 3.3. Because Python is an interpreted language and does not require pre-compilation, you can now learn Python development or run your existing Python programs directly on Colibri iMX6. But at this point you may encounter a problem where the Python module is not installed and you will not be able to run your own Python project.

3. One advantage of Python module installation. / Python is that module components can be downloaded and installed directly locally, which is also applicable to embedded devices. Since we have added python3-pip to OpenEmbedded/Yocto before, we can now install it with the pip command, such as imutils, which is the next component we need.

-

Root@colibri-imx6:~# pip3 install imutils

-

In addition to online installation, Python modules can also be compiled through offline cross-compilation. Zbar only supports python2 by default, and we need to install pyzbar to support python3 in our BSP.

First you need to install Linux SDK, which provides the required cross-compilers, header files, library files, and some basic compilation configuration files. It is also recommended to install the same version of Python as on BSP on the development computer.

-

Ben@ben-T430u:~$ cd/usr/local/oecore-x86_64

Ben@ben-T430u:~$.environment-setup-armv7at2hf-neon-angstrom-linux-gnueabi

Ben@ben-T430u:~CFLAGS-I$SDKTARGETSYSROOT/usr/bin/python3.5m "

Ben@ben-T430u:~$ exportHOSTPYTHON=/usr/local/bin/python3.5

Ben@ben-T430u:~$ $HOSTPYTHON setup.py build

Ben@ben-T430u:~$ $HOSTPYTHON setup.pybdist_egg

-

Copy the compiled pyzbar-0.1.7-py3.5.egg to the development board and install it using easy_install-3.5

-

Root@colibri-imx6:~# easy_install-3.5pyzbar-0.1.7-py3.5.egg

Processing pyzbar-0.1.7-py3.5.egg

Creating/usr/lib/python3.5/site-packages/pyzbar-0.1.7-py3.5.egg

Extracting pyzbar-0.1.7-py3.5.egg to / usr/lib/python3.5/site-packages

Adding pyzbar 0.1.7 to easy-install.pthfile

Installing read_zbar.py script to / usr/bin

Installing read_zbar script to / usr/bin

-

In addition, OpenEmbedded also provides a large number of Python-related components that can be easily integrated into BSP.

At this point, we have completed the construction of the Python environment on the development board, and all the required builds have been installed. Below we will demonstrate the recognition of barcodes and QR code pictures through several Python projects, as well as real-time reading of QR codes on USB cameras.

4. PyZbar barcode and QR code read. / identify barcode on still picture

-

Root@colibri-imx6:~#./barcode_scanner_image.py-I barcode1.png

-

. / identify the QR code on a still picture

-

Root@colibri-imx6:~#./barcode_scanner_image.py-I QR-tdx.png

-

. / recognize the QR code in real time through the USB camera

-

Root@colibri-imx6:~#./barcode_scanner_video.py-o rec.csv

This is the end of the content of "what is the method of Linux embedded python application development". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report