Top Banner
1 © 2015 The MathWorks, Inc. Implementing Video Image Processing Algorithms on FPGA
43

Implementing Video Image Processing Algorithms on · PDF fileImplementing Video Image Processing Algorithms on FPGA. 2 ... full-frame source pixel-stream processing ... Altera IP Core

Mar 08, 2018

Download

Documents

phungdang
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Implementing Video Image Processing Algorithms on · PDF fileImplementing Video Image Processing Algorithms on FPGA. 2 ... full-frame source pixel-stream processing ... Altera IP Core

1© 2015 The MathWorks, Inc.

Implementing Video Image Processing

Algorithms on FPGA

Page 2: Implementing Video Image Processing Algorithms on · PDF fileImplementing Video Image Processing Algorithms on FPGA. 2 ... full-frame source pixel-stream processing ... Altera IP Core

2

Video Image Processing and Computer Vision

Computer Vision Feature matching, and extraction

Object detection and recognition

Object Tracking and motion estimation

Dynamic resolution scaling

Focus assessment

Video Image Processing Video in and out

Gamma correction

Color balancing

Noise removal

Image sharpening

Page 3: Implementing Video Image Processing Algorithms on · PDF fileImplementing Video Image Processing Algorithms on FPGA. 2 ... full-frame source pixel-stream processing ... Altera IP Core

3

Workflow for Video Image Processing

Concept Development

Algorithm Development

PrototypingArchitecture

designPrototyping

Chip design

Frame based

Image/Video Engineer

Pixel based

HW Engineer

Page 4: Implementing Video Image Processing Algorithms on · PDF fileImplementing Video Image Processing Algorithms on FPGA. 2 ... full-frame source pixel-stream processing ... Altera IP Core

4

Modeling video image processing systems

Pixel-streaming behavior

Code generation ready model

Prototyping and concept proofing

Technology independent code

Prototyping and Designing FPGA and ASIC

for video and image processing algorithms

Portable, readable and efficient IP Cores

Flexible architecture and controllable latency

FPGA-in-the-loop testing using ML and SL

as frame based test bench

Algorithm Designer

Hardware Engineer

Challenges in Design and Prototyping for

Video and Image

Page 5: Implementing Video Image Processing Algorithms on · PDF fileImplementing Video Image Processing Algorithms on FPGA. 2 ... full-frame source pixel-stream processing ... Altera IP Core

5

Vision HDL ToolboxDesign and prototype video image processing systems

Modeling hardware behavior of

the algorithms

– Pixel-based functions and blocks

– Conversion between frames and

pixels

– Standard and custom frame sizes

Prototyping algorithms on

hardware

– (With HDL Coder) Efficient and

readable HDL code

– (With HDL Verifier) FPGA-in-the-loop

testing and acceleration

Page 6: Implementing Video Image Processing Algorithms on · PDF fileImplementing Video Image Processing Algorithms on FPGA. 2 ... full-frame source pixel-stream processing ... Altera IP Core

6

Pixel Based Video Image Algorithms

Analysis & Enhancement

– Edge Detection, Median Filter

Conversions

– Chroma Resampling, Color-

Space Converter

– Demosaic Interpolator, Gamma

Corrector, Look-up Table

Filters

– Image Filter, Median Filter

Morphological Operations

– Dilation, Erosion,

– Opening, Closing

Statistics

– Histogram

– Image Statistics

I/O Interfaces

– Frame to Pixels, Pixels to

Frame, FIL versions

Utilities

– Pixel Control Bus Creator

– Pixel Control Bus Selector

Page 7: Implementing Video Image Processing Algorithms on · PDF fileImplementing Video Image Processing Algorithms on FPGA. 2 ... full-frame source pixel-stream processing ... Altera IP Core

7

A Complete Solution for Embedded Vision

Concept Development

Algorithm Development

PrototypingArchitecture

designPrototyping

Chip design

Frame based Pixel based

MATLAB

Vision HDL

Toolbox

MATLAB

Coder

HDL Coder

Fixed Pt

DesignerHDL Verifier

Image

Processing

Toolbox

Computer Vision

System Toolbox

Page 8: Implementing Video Image Processing Algorithms on · PDF fileImplementing Video Image Processing Algorithms on FPGA. 2 ... full-frame source pixel-stream processing ... Altera IP Core

8

A Complete Solution for Embedded Vision

Product Capabilities

Vision HDL Toolbox Design and simulate image processing, video, and

computer vision systems for FPGAs and ASICs

HDL Coder Provide RTL code and testbench generation

capability for the functions and blocks in Vision HDL

Toolbox

HDL Verifier Provide FPGA-in-the-loop capability for Vision HDL

Toolbox

Computer Vision

System Toolbox

Provide frame based computer vision functions and

blocks as well as image and video I/O capability

Image Processing

Toolbox

Provide image processing and analysis functions

Page 9: Implementing Video Image Processing Algorithms on · PDF fileImplementing Video Image Processing Algorithms on FPGA. 2 ... full-frame source pixel-stream processing ... Altera IP Core

9

Model-Based Design For Embedded VisionFrom Concept to Production

• Automate regression testing

• Detect design errors

• Support certification and standards

• Generate efficient code

• Explore and optimize

implementation tradeoffs

• Build behavioral model for fast

simulation and testing

• Convert to prototype model for

targeting hardware

INTEGRATION

IMPLEMENTATION

DESIGN

TE

ST

& V

ER

IFIC

AT

ION

RESEARCH REQUIREMENTS

ARM FPGA

VHDL, VerilogC, C++

Testbench & Algorithms

Behavioral Model

Prototype Model

Page 10: Implementing Video Image Processing Algorithms on · PDF fileImplementing Video Image Processing Algorithms on FPGA. 2 ... full-frame source pixel-stream processing ... Altera IP Core

10

Shorter implementation time by 48% (total project 33%)

Reduced FPGA prototype development schedule by 47%

Shorter design iteration cycle by 80%

ROI: Customer Adoption Of Model-Based DesignTime spent on FPGA implementation

1st FPGA Prototype 2nd FPGA Prototype

1st FPGA Prototype

Page 11: Implementing Video Image Processing Algorithms on · PDF fileImplementing Video Image Processing Algorithms on FPGA. 2 ... full-frame source pixel-stream processing ... Altera IP Core

11

Demo: Enhanced Edge Detection

Read

Image

from

File

Add

noiseMedian

Filter

Edge

Detect

Video

Display

Frame

To

Pixel

Pixel

To

Frame

Test bench Design

Page 12: Implementing Video Image Processing Algorithms on · PDF fileImplementing Video Image Processing Algorithms on FPGA. 2 ... full-frame source pixel-stream processing ... Altera IP Core

12

Enhanced Edge Detection

Page 13: Implementing Video Image Processing Algorithms on · PDF fileImplementing Video Image Processing Algorithms on FPGA. 2 ... full-frame source pixel-stream processing ... Altera IP Core

13

Streaming Pixel InterfaceFull Frame vs Pixel Stream

full-frame source full-frame sink pixel-stream processing

Page 14: Implementing Video Image Processing Algorithms on · PDF fileImplementing Video Image Processing Algorithms on FPGA. 2 ... full-frame source pixel-stream processing ... Altera IP Core

14

Streaming Pixel InterfaceFull Frame vs Pixel Stream

full-frame source full-frame sink pixel-stream processing

Page 15: Implementing Video Image Processing Algorithms on · PDF fileImplementing Video Image Processing Algorithms on FPGA. 2 ... full-frame source pixel-stream processing ... Altera IP Core

16

Frame To Pixels and Pixels To Frame

Page 16: Implementing Video Image Processing Algorithms on · PDF fileImplementing Video Image Processing Algorithms on FPGA. 2 ... full-frame source pixel-stream processing ... Altera IP Core

17

Examples: Starting Points for Your Models

Page 17: Implementing Video Image Processing Algorithms on · PDF fileImplementing Video Image Processing Algorithms on FPGA. 2 ... full-frame source pixel-stream processing ... Altera IP Core

18

Image FilteringKeywords: Median Filter, Image Filter, PSNR

Page 18: Implementing Video Image Processing Algorithms on · PDF fileImplementing Video Image Processing Algorithms on FPGA. 2 ... full-frame source pixel-stream processing ... Altera IP Core

19

Gamma Correction ExampleKeywords: Gamma, PSNR

Page 19: Implementing Video Image Processing Algorithms on · PDF fileImplementing Video Image Processing Algorithms on FPGA. 2 ... full-frame source pixel-stream processing ... Altera IP Core

20

Histogram EqualizationKeywords: Histogram, Linear Equalization, External Frame Delay

0 255 0 255

Page 20: Implementing Video Image Processing Algorithms on · PDF fileImplementing Video Image Processing Algorithms on FPGA. 2 ... full-frame source pixel-stream processing ... Altera IP Core

21

Edge Detection and Image OverlayKeywords: Sobel, Align Video, Alpha Mix, PSNR

Page 21: Implementing Video Image Processing Algorithms on · PDF fileImplementing Video Image Processing Algorithms on FPGA. 2 ... full-frame source pixel-stream processing ... Altera IP Core

22

Edge Detection with Impaired FrameKeywords: Sobel, Align Video, Alpha Mix, PSNR

Page 22: Implementing Video Image Processing Algorithms on · PDF fileImplementing Video Image Processing Algorithms on FPGA. 2 ... full-frame source pixel-stream processing ... Altera IP Core

23

Multi-Zone MeteringKeywords: ROI, Image Statistics, Mean

Source Mask Selected ROI

Page 23: Implementing Video Image Processing Algorithms on · PDF fileImplementing Video Image Processing Algorithms on FPGA. 2 ... full-frame source pixel-stream processing ... Altera IP Core

24

MATLAB Code

10X more concise

HDL Coder

HDL

Coder

60% reduction in time to produce a

working prototype

Reference: mathworks.com/company/user_stories/FLIR-Accelerates-Development-of-Thermal-Imaging-FPGA.html

FLIR Systems

Provides VHDL and Verilog

code generation for MATLAB

and Simulink

Page 24: Implementing Video Image Processing Algorithms on · PDF fileImplementing Video Image Processing Algorithms on FPGA. 2 ... full-frame source pixel-stream processing ... Altera IP Core

25

HDL Products Key Features

Code Generation– Target-independent HDL Code

– IEEE 1376 compliant VHDL®

– IEEE 1364-2001 compliant Verilog®

Verification– Generate HDL test-bench

– Co-simulate with ModelSim and Incisive

Design automation– Synthesize using integrated Xilinx and

Altera synthesis tool interface

– Optimize for area-speed

– Program Xilinx and Altera boards

MATLAB® and Simulink®

Algorithm and System Design

Link for ModelSim

FPGA ASIC

HDL

Veri

fy

HDL Coder

HDL Verifier

FPGA ASIC

HDL

Veri

fy

Gen

era

te

Page 25: Implementing Video Image Processing Algorithms on · PDF fileImplementing Video Image Processing Algorithms on FPGA. 2 ... full-frame source pixel-stream processing ... Altera IP Core

26

HDL Coder : Key Features and Options

Simulink

– Streaming

– Sharing

– Line buffers as RAMs

– RAM Fusion

– Architecture Flattening

MATLAB

– RAM Mapping

– Loop Streaming

– Resource Sharing

– CSD/FCSD

Simulink

– Input/Output pipelining

– Distributed Pipelining

– Hierarchical Dist. Pipelining

– Constrained Pipelining

– Back-Annotation

MATLAB

– Input/Output pipelining

– Distributed pipelining

– Loop Unrolling

Automatic Delay Balancing

Validation model generation

Area Optimizations Speed Optimizations

Validation and Verification

Page 26: Implementing Video Image Processing Algorithms on · PDF fileImplementing Video Image Processing Algorithms on FPGA. 2 ... full-frame source pixel-stream processing ... Altera IP Core

27

Hardware Design Solution:HDL Workflow Advisor

Create FPGA project

Run P&R

--and--

Annotate timing information

Automated workflow

from model to FPGA Implementation

& Timing Analysis

Page 27: Implementing Video Image Processing Algorithms on · PDF fileImplementing Video Image Processing Algorithms on FPGA. 2 ... full-frame source pixel-stream processing ... Altera IP Core

28

Critical Path highlighting:

Visual representation of critical path in your model

Easier to identify bottlenecks of your model

Identifying the critical pathIntegrating with P&R Timing Analysis

Page 28: Implementing Video Image Processing Algorithms on · PDF fileImplementing Video Image Processing Algorithms on FPGA. 2 ... full-frame source pixel-stream processing ... Altera IP Core

29

Meeting Timing ConstraintDistributed Pipelining

Page 29: Implementing Video Image Processing Algorithms on · PDF fileImplementing Video Image Processing Algorithms on FPGA. 2 ... full-frame source pixel-stream processing ... Altera IP Core

30

Distributed PipeliningSpeed Optimization

Distributed pipelining (model retiming)

Automatic delay compensation where needed

Constrained retiming gives you more influence

Page 30: Implementing Video Image Processing Algorithms on · PDF fileImplementing Video Image Processing Algorithms on FPGA. 2 ... full-frame source pixel-stream processing ... Altera IP Core

31

Clock-Rate Pipelining

Clock-Rate Pipelining

Exposes latency budget

Page 31: Implementing Video Image Processing Algorithms on · PDF fileImplementing Video Image Processing Algorithms on FPGA. 2 ... full-frame source pixel-stream processing ... Altera IP Core

32

Supported Targets

Critical Path Estimation

hdlset_param(model, ‘CriticalPathEstimation’, {‘on’|’off’})Generate

HDL code

Critical path highlighted

on generated model

Page 32: Implementing Video Image Processing Algorithms on · PDF fileImplementing Video Image Processing Algorithms on FPGA. 2 ... full-frame source pixel-stream processing ... Altera IP Core

33

Meeting Resource ConstraintArea Optimization

X

XX

XX

X

XMUX DEMUX

SCHEDULING

Page 33: Implementing Video Image Processing Algorithms on · PDF fileImplementing Video Image Processing Algorithms on FPGA. 2 ... full-frame source pixel-stream processing ... Altera IP Core

34

Hardware Design Solution:Resource Sharing and Streaming

Page 34: Implementing Video Image Processing Algorithms on · PDF fileImplementing Video Image Processing Algorithms on FPGA. 2 ... full-frame source pixel-stream processing ... Altera IP Core

35

Resource Sharing and StreamingArea Optimization

Easily share multipliers and identical subsystems

Direct feedback through resource utilization report

Prove correctness through validation models

Page 35: Implementing Video Image Processing Algorithms on · PDF fileImplementing Video Image Processing Algorithms on FPGA. 2 ... full-frame source pixel-stream processing ... Altera IP Core

36

Traceability Between Model and Code

Page 36: Implementing Video Image Processing Algorithms on · PDF fileImplementing Video Image Processing Algorithms on FPGA. 2 ... full-frame source pixel-stream processing ... Altera IP Core

37

Resource Utilization Estimation

Page 37: Implementing Video Image Processing Algorithms on · PDF fileImplementing Video Image Processing Algorithms on FPGA. 2 ... full-frame source pixel-stream processing ... Altera IP Core

38

Integrating Legacy HDL CodeHDL Supported Blocks Integrate legacy HDL code

in Simulink using black

boxes

Configure the interface to

legacy HDL code

HDL Verifier is a special

black box

Page 38: Implementing Video Image Processing Algorithms on · PDF fileImplementing Video Image Processing Algorithms on FPGA. 2 ... full-frame source pixel-stream processing ... Altera IP Core

39

Vivado IP Core Generation

Generate sharable and re-usable

Vivado IP core from MATLAB/

Simulink HDL Workflow Advisor

Support AXI4 interfaces to

connect FPGA IP core to Zynq

ARM processor

Generate IP core report as IP

Product Guide

Programmable Logic IP Core

Algorithm

from

MATLAB/

Simulink

AXI4-Lite

Accessible

Registers

AXI4External

Ports

Page 39: Implementing Video Image Processing Algorithms on · PDF fileImplementing Video Image Processing Algorithms on FPGA. 2 ... full-frame source pixel-stream processing ... Altera IP Core

40

Vivado IP Integrator Support for ZynqR2014b

Programmable Logic IP Core

Algorithm

from

MATLAB/

Simulink

AXI4-Lite

Accessible

Registers

AXI4External

Ports

Integrate Xilinx Vivado IP

Integrator tool flow into HDL

Workflow Advisor

Insert the generated IP core into

Vivado Zynq system design

Build and Program Zynq board

Page 40: Implementing Video Image Processing Algorithms on · PDF fileImplementing Video Image Processing Algorithms on FPGA. 2 ... full-frame source pixel-stream processing ... Altera IP Core

41

Altera IP Core Generation + QSys IntegrationR2014b

Generate sharable and re-usable Altera

IP from MATLAB/ Simulink HDL WFA

Support AXI4 interfaces to connect FPGA

IP to Altera SoC ARM processor

Generate IP core report as IP Data Sheet

QSys integration for rapid prototyping

Page 41: Implementing Video Image Processing Algorithms on · PDF fileImplementing Video Image Processing Algorithms on FPGA. 2 ... full-frame source pixel-stream processing ... Altera IP Core

42

Backup

Page 42: Implementing Video Image Processing Algorithms on · PDF fileImplementing Video Image Processing Algorithms on FPGA. 2 ... full-frame source pixel-stream processing ... Altera IP Core

43

VHT CVST

Image

Processing

Pixel based Frame based

Workflow System prototyping Algorithm design

Algorithms Image filtering

Color space conversion

Edge detection

Statistics & histogram

Morphological operations

(Most of the VHT algorithms, plus)

Object detection & tracking

Feature extraction and matching

Stereo vision

Camera calibration

Image registration

I/O Frame-to-pixel

Pixel-to-frame

FIL

File I/O

Video display

Code gen HDL (with HDL Coder) C (with ML Coder or SL Coder)

CVST and VHT, complimentary productsProduct details

Page 43: Implementing Video Image Processing Algorithms on · PDF fileImplementing Video Image Processing Algorithms on FPGA. 2 ... full-frame source pixel-stream processing ... Altera IP Core

44

MBD Workflow for Embedded Vision (video)

MBD workflow

1. Build behavior model with CVST blocks and simulate

2. Build prototyping model with VHT blocks and simulate

3. Generate HDL code using HDL Coder

4. Run HDL code on FPGA and run testbench in SL (FIL)