element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet & Tria Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • About Us
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      • Japan
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Vietnam
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Project14
  • Challenges & Projects
  • More
Project14
Blog PYNQ-Z2 Embedded Vision Workshop Session 3
  • Blog
  • Forum
  • Documents
  • Theme Suggestions
  • Polls
  • Members
  • More
  • Cancel
  • New
Join Project14 to participate - click to join for free!
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: ralphjy
  • Date Created: 4 Jun 2020 8:19 PM Date Created
  • Views 853 views
  • Likes 3 likes
  • Comments 1 comment
  • pynq-z2
  • pynq workshop
  • pynqhero
Related
Recommended

PYNQ-Z2 Embedded Vision Workshop Session 3

ralphjy
ralphjy
4 Jun 2020

This past Tuesday was the final session in the Pynq-Z2 workshop series.  This session completed the embedded vision project by adding an interface for an HDMI camera and using it to read barcodes.

 

The HDMI interface was was brought in as a hierarchical block called "frontend" which was exported from the base overlay.

 

Here is the upper level block diagram with the frontend block highlighted:

image

A closer look at the frontend block showing the camera interface IP dvi2rgb and the video timing and stream converter to support it:

image

 

The frontend block essentially replaced the TPG from the previous session.

 

Once the new bitstream was created, the BIT, TCL, and HWH files were transferred to the PYNQ-Z2 overlay directory.  In order to enable the reading of Barcodes a Python library 'zbar' needs to be installed also.

From a Jupyter terminal

  • apt-get install libzbar0
  • pip3 install pyzbar

 

I found some sample barcodes on the website https://internationalbarcodes.com/sample-images/ .  For purposes of testing I displayed the codes on a second monitor and captured that image with the camera.

Some of the barcodes that I tried didn't work so there may be a problem with the images on the website but here's one that did work:

image

 

The code added to the Jupyter notebook to capture the image and display the result:

image

You can see that my action camera has a fair amount of fish eye distortion that is very apparent with a closeup image.

 

The captured image is then written to a file img.jpg

image

 

The image is shown below - looks like the color conversion needs to be fixed.

image

 

The image is processed to convert it to grayscale and apply thresholding.

image

gray.jpg

image

thres.jpg

image

 

And finally the detection is run on the image and the barcode is printed if it is found and the image is written with the bounding box and barcode overlaid.

image

 

final.jpg

image

 

So, another fun and useful workshop.  Homework is to try to extend the functionality of the overlay.  And the final project is to come up with our own embedded vision project.

 

I've started to try a few things but as always - the devil is in the details image.  Looks easy when Adam does it.  Hopefully I'll get the homework done this week and then on to figuring out a project to do.......

 

Note: to those of you paying attention - I just realized that I mixed up some of the images that I saved - I had a few different barcodes that worked.  And I may have adjusted the camera position a bit between barcodes. 

  • Sign in to reply
  • genebren
    genebren over 5 years ago

    That is pretty cool!  Good luck on your homework and then starting on your project.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube