当前位置:网站首页>Teach you how to realize pynq-z2 bar code recognition
Teach you how to realize pynq-z2 bar code recognition
2022-06-27 14:38:00 【Snow fish】
I am a Snow fish , a FPGA lovers , The research direction is FPGA Architecture exploration and SOC Design .
Official account 【 Integrated circuit design tutorial 】, Pull you in “IC Design communication group ”.
1. Preface
It took nearly a week to realize a two-dimensional code recognition , In this article, I will introduce in detail the pit I have walked through during this period , The code is attached at the end of the text , If you are in urgent need, just turn to the end
2. linux To configure
To achieve this project , First solve the following problems Three main points , It really wastes a lot of time
2.1 solve pynq Connected to the Internet
pynq There are many online tutorials , But I did it for a long time . First, at home , I use

The method shown , And then success ping Internet access In school, this method could not solve , I've tried many methods on the Internet that can't be solved ( Maybe I'm too good ), Finally, after re burning the image for several times, I found : Connect the network cable directly to the router in the dormitory Connect to the Internet ...

For details on how to change the download source into an image source, please refer to other blogs
2.2 solve pyzbar Library Download
This library is recommended for download
pip3 install pyzbarThe installation path of this library should also be noted , Type... On the command line
pip3 show pyzbarMine is here :

<center> chart 2.2.1. pyzbar The location of </center>
Many say , Below zbar Let me use it
sudo apt-get install python-zbarobtain , Why not pip3, because pip3 Downloading this always reports an error , Even if it's
pip3 upgrade Not good either. , No pip3 Version problem . my linux The mirror is v2.3 Version of , I don't know that we all adopt v2.5 Or is it better to be higher

<center> chart 2.2.2. zbar The location of </center>
2.3 solve jupyter Import library
2.3.1 First, explain the origin of the problem
I found the use of
pip3 install pillowPIL stay jupyter You can import , But it cannot be imported pyzbar Again, I found that on the command line, I entered python3 after , You can import pyzbar, But cannot import zbar

<center> chart 2.3.1. python3 Import pyzbar success , Import zbar You don't succeed </center>
I type... On the command line pyhton Unable to import... Found under the interpreter pyzbar, But you can import zbar And that got my attention , Finally I found out that pip3 To the pyzbar There is a separate storage path ,apt-get Empathy As for why python and python3 Cannot import the same package Then we have to
import syssys.pathUse sentences to observe , Found inconsistent reference paths . I think I know the crux :

<center> chart 2.3.2. A less smooth explanation </center>
$\color{#FF3030}{ The scarlet letter }$ Not very smooth , Translate into People words Namely : jupyter To set up for Support quoting Storage pyzbar The path of the package

2.3.2 Method 1 :
<center> Modify environment variables </center>
explain , Here's a quote :
Article source address : https://blog.csdn.net/c20081052/article/details/79715132
Linux There are three ways to set environment variables under , One for the current terminal , One for the current user , One for all users : One : For the current terminal : Enter... In the current terminal :export PATH=$PATH:< Your path to join > However, the above method is only applicable to the current terminal , Once the current terminal is closed or in another terminal , It doesn't work .
export NDK_ROOT=/home/jiang/soft/Android-ndk-r8e It can only be used at the current terminal . Two : For the current user : In the user's home directory, there is a .bashrc Hidden files , You can add... To this file PATH The settings are as follows :
$ gedit ~/.bashrcJoin in :
export PATH=< Your path to join >:$PATHIf you want to join multiple paths , as long as :
export PATH=< The path you want to join 1>:< The path you want to join 2>: ...... :$PATHEach path should be separated by a colon .
This will take effect every time you log in
add to PYTHONPATH The same is true of , stay .bashrc Add
export PYTHONPATH=/home/zhao/setup/caffemaster/python:/home/zhao/setup/mypy:$PYTHONPATH After saving, input... At the terminal $ source ~/.bashrc Make environment variables effective immediately
3、 ... and : For all users :
$ sudo gedit /etc/profile Join in :
export PATH=< The path you want to join >:$PATH That's all right. . The input terminal :echo $PATH You can view the environment variables
Be careful , After modifying the environment variables , Except that the first method takes effect immediately , The second and third method should take effect immediately , Sure source ~/.bashrc Or log out and log in again !
End of reference
2.3.3 Method 2 :
<center> Add statements to your code </center>
import syssys.pathsys.path.append('/home/xilinx/.local/lib/python3.6/site-packages')sys.path Yes view jupyter Library lookup path for , Can view your jupyter Whether the path of your package is included Generally speaking, library import fails for this reason ——jupyter The library path This is the way to set the extra reference path :
sys.path.append('')Please refer to this article : https://www.cnblogs.com/mandy-study/p/7735801.html
3. Provide code
# Key identification code barcodes = decode(image)def decode (image,barcodes): # loop over the detected barcodes for barcode in barcodes: # extract the bounding box location of the barcode and draw the # bounding boxr surrounding the barcode on the image (x, y, w, h) = barcode.rect cv2.rectangle(image, (x, y),(x + w,y + h), (255, 0, 0), 5) # the barcode data is a bytes object so if we want to draw it on # our output image wre need to convert it to a string first barcodeData = barcode.data.decode("utf-8") barcodeType = barcode.type # draw the barcode data and barcode type on the image text ="{} ({})". format(barcodeData,barcodeType) cv2.putText(image,text,(x, y - 10), cv2.FONT_HERSHEY_SIMPLEX,.8, (255, 0, 0), 2) # print the barcode type and data to the terminal print("[INFO] Found {} barcode: {}".format(barcodeType,barcodeData)) plt.figure(figsize=(10,10)) plt.imshow(image) plt.show() # Decoding barcodesdecode(image,barcodes)final result , I found that the frame didn't fit very well , It may be the problem of taking photos . But the result of identification is completely correct

For the complete code, please refer to the connection : https://download.csdn.net/download/weixin_44360347/15816188
Open is .ipynb Format .
- More technical articles and learning materials , Please pay attention to my official account :【 Integrated circuit design tutorial 】
- The whole platform is unified :【 Snow fish 】
边栏推荐
- Handling methods for NVIDIA deepstream running delay, jamming and crash
- Why must Oracle cloud customers self test after the release of Oracle cloud quarterly update?
- Julia1.1 installation instructions
- 直播app运营模式有哪几种,我们该选择什么样的模式?
- Brief reading of dynamic networks and conditional computing papers and code collection
- Interview question: rendering 100000 data solutions
- 【业务安全03】密码找回业务安全以及接口参数账号修改实例(基于metinfov4.0平台)
- 简析国内外电商的区别
- CAS之比较并交换
- SFINAE
猜你喜欢

NAACL 2022 | TAMT:通过下游任务无关掩码训练搜索可迁移的BERT子网络

海量数据!秒级分析!Flink+Doris构建实时数仓方案

American chips are hit hard again, and another chip enterprise after Intel will be overtaken by Chinese chips

Lei Jun lost another great general, and liweixing, the founding employee of Xiaomi No. 12, left his post. He once had porridge to create Xiaomi; Intel's $5.4 billion acquisition of tower semiconductor

Pychart installation and setup

【OS命令注入】常见OS命令执行函数以及OS命令注入利用实例以及靶场实验—基于DVWA靶场

CCID Consulting released the database Market Research Report on key application fields during the "14th five year plan" (attached with download)

直播app运营模式有哪几种,我们该选择什么样的模式?

巧用redis实现点赞功能,它不比mysql香吗?

Getting to know cloud native security for the first time: the best guarantee in the cloud Era
随机推荐
注解学习总结
Redis master-slave replication, sentinel mode, cluster cluster
[an Xun cup 2019]attack
Principle Comparison and analysis of mechanical hard disk and SSD solid state disk
OpenSSF安全计划:SBOM将驱动软件供应链安全
At a time of oversupply of chips, China, the largest importer, continued to reduce imports, and the United States panicked
简析国内外电商的区别
How to change a matrix into a triple in R language (i.e. three columns: row, col, value)
Dynamic Networks and Conditional Computation论文简读和代码合集
力扣 第 81 场双周赛
Is flutter easy to learn? How to learn? The most complete introduction and actual combat of flutter in history. Take it away without thanks~
Abnormal analysis of pcf8591 voltage measurement data
my. INI file configuration
volatile与JMM
Bidding announcement: Oracle all-in-one machine software and hardware maintenance project of Shanghai R & D Public Service Platform Management Center
522. 最长特殊序列 II / 剑指 Offer II 101. 分割等和子集
事务的四大特性
Use GCC to generate an abstract syntax tree "ast" and dump it to Dot file and visualization
Redis 主从复制、哨兵模式、Cluster集群
Using redis skillfully to realize the like function, isn't it more fragrant than MySQL?