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 Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • 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
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • 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
Eye On Intelligence Challenge
  • Challenges & Projects
  • Design Challenges
  • Eye On Intelligence Challenge
  • More
  • Cancel
Eye On Intelligence Challenge
Blog Person Detection with yolo #5 Eye on With USB Camera in Pynq Virtual Environment
  • Blog
  • Forum
  • Documents
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Eye On Intelligence Challenge to participate - click to join for free!
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: fyaocn
  • Date Created: 15 Nov 2024 6:30 AM Date Created
  • Views 448 views
  • Likes 2 likes
  • Comments 1 comment
  • Eye on Intelligence Challenge
Related
Recommended

Person Detection with yolo #5 Eye on With USB Camera in Pynq Virtual Environment

fyaocn
fyaocn
15 Nov 2024

#5 Eye on With USB Camera in Pynq Virtual Environment

Table of Contents

  • 1 Image Process and Video Capture with USB camera
  • 2 Test Pynq I2C overlay with Pmod ALS light sensor
  • 3 USB camera for Video and Image
  • 4 Yolo and Person Detection
  • 5 Summary

1 Image Process and Video Capture with USB camera

Arty Z7 supported image capture and video process with two options, one for Pynq Overlay HDMI video in and HDMI video out, the other is USB endpoint support for USB cameras.

With video capture, Arty Z7 is eye on to detect thing around, with intelligence added on.

2 Test Pynq I2C overlay with Pmod ALS light sensor

Prepare the Digilent Pmod ALS1 light sensor, this is I2C sensor data peripheral,

image

Connected with PMOD A with Silkprint mark JA

image

Power up the Arty Z7, and login the jupyter interface,open the PMOD light sensor notebook

image

Download base overlay. 

from pynq.overlays.base import BaseOverlay
base = BaseOverlay("base.bit")

Read single luminance value

from pynq.lib.pmod import Grove_Light
from pynq.lib.pmod import PMOD_GROVE_G4

lgt = Grove_Light(base.PMODA,PMOD_GROVE_G4)

sensor_val = lgt.read()
print(sensor_val)

Plot the light intensity over time

import time
%matplotlib inline
import matplotlib.pyplot as plt

lgt.set_log_interval_ms(100)
lgt.start_log()
# Change input during this time
time.sleep(10)
r_log = lgt.get_log()

plt.plot(range(len(r_log)), r_log, 'ro')
plt.title('Grove Light Plot')
min_r_log = min(r_log)
max_r_log = max(r_log)
plt.axis([0, len(r_log), min_r_log, max_r_log])
plt.show()

image

This is demonstration for how Pynq overlay got data from peripheral.

3 USB camera for Video and Image

Connecting the USB camera with Arty Z7 board.

image

This video get image from linux command in "!" prefix, and the image is process with python Image library,

from PIL import Image as PIL_Image

orig_img_path = 'data/webcam.jpg'
!fswebcam  --no-banner --save {orig_img_path} -d /dev/video0 2> /dev/null

img = PIL_Image.open(orig_img_path)
img

Capture the image

image

put it in black-white

bw_img = img.convert("L")
bw_img

rotate the image in 45 degree

image

This is how the it works with image capture from usb camera.

If there is HDMI-camera, there is another image capture solution with HDMI in, as,

from pynq.overlays.base import BaseOverlay
from pynq.lib.video import *

base = BaseOverlay("base.bit")
hdmi_in = base.video.hdmi_in
hdmi_out = base.video.hdmi_out

4 Yolo and Person Detection

Yolo isreal-time object detection and image segmentation model. The latest version is YOLO11. It is built on cutting-edge advancements in deep learning and computer vision, offering unparalleled performance in terms of speed and accuracy. For edge intelligence, earlier version is more applicable. Model like  yolo3, yolo4 are still widely used. YOLOv3: This is the third version of the You Only Look Once (YOLO) object detection algorithm

image

After installation the code is easy as

from ultralytics import YOLO

# Load a COCO-pretrained YOLOv3n model
model = YOLO("yolov3n.pt")

# Display model information (optional)
model.info()

# Train the model on the COCO8 example dataset for 100 epochs
results = model.train(data="coco8.yaml", epochs=100, imgsz=640)

# Run inference with the YOLOv3n model on the 'bus.jpg' image
results = model("path/to/bus.jpg")

The pynq-dpu can support yolo3 in model zoo, it is comiled into xmodel file format to loaded for DPU to process it.

5 Summary

in summary, with usb camera, the eye for Arty Z7 is open for intelligence applications.

  • Sign in to reply
  • DAB
    DAB 7 months ago

    Nice update.

    • 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