Docsity

FPGA-based Industrial Image Processing: A Project Report, Study Guides, Projects, Research of Electrical and Electronics Engineering

Toggle sidebar
bg1
FPGA Based Industrial Image
Processing November 8, 2006
ECE - 501 - Fall 2006 1
FPGA based industrial
FPGA based industrial
image processing
image processing
Submitted
Submitted -
-November 2006
November 2006
Arpit Jain
Arpit Jain
Electrical and Computer Engineering
Electrical and Computer Engineering
University of Tennessee, Knoxville
University of Tennessee, Knoxville
Project Report (in lieu of thesis)
Introduction :
The project is Vhdl implementation part of the Design Of Custom Image Capture
Card for Textile Quality Inspection. The project is undertaken in complement with
Thesis work of Mr. Mohammed Imran Sharafat and is intended to be utilized in for
Image capture and control Card in Textile Quality Inspection Equipments. One of
the tests performed is to measures the color, reflectance and trash (count and area)
contents of the cotton. This requires a custom color sensing and image acquisition
system. This project is the design implementation of the capture control and
communication part of the complete system.
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e

Partial preview of the text

Download FPGA-based Industrial Image Processing: A Project Report and more Study Guides, Projects, Research Electrical and Electronics Engineering in PDF only on Docsity!

Processing

FPGA based industrial FPGA based industrial

image processingimage processing

SubmittedSubmitted -- November 2006November 2006

Arpit JainArpit Jain

Electrical and Computer EngineeringElectrical and Computer Engineering

University of Tennessee, KnoxvilleUniversity of Tennessee, Knoxville

Project Report (in lieu of thesis)

Introduction : The project is Vhdl implementation part of the Design Of Custom Image Capture Card for Textile Quality Inspection. The project is undertaken in complement with Thesis work of Mr. Mohammed Imran Sharafat and is intended to be utilized in for Image capture and control Card in Textile Quality Inspection Equipments. One of the tests performed is to measures the color, reflectance and trash (count and area) contents of the cotton. This requires a custom color sensing and image acquisition system. This project is the design implementation of the capture control and communication part of the complete system.

Processing

November 8, 2006 2

Overview Overview

„„ Capturing an Image of Cotton to measure its qualityCapturing an Image of Cotton to measure its quality „„^ Calculation of trash content and compositionCalculation of trash content and composition „„ Calibration and control of Analog(Calibration and control of Analog( Bt.656Bt.656 ) Camera and flash) Camera and flash „„^ Implementation of Real-Implementation of Real-time conversion and controltime conversion and control algorithm on FPGAalgorithm on FPGA „„ Communication to host PC over USB 2.0Communication to host PC over USB 2. „„ Different from Commercially available capture cards.Different from Commercially available capture cards.

The whole system can be divided into three main units i) A Color, reflectance and Image sensor called Color-Head, ii) A Frame Grabber Card and iii) A PC running the application Software to acquire and Process the data.

This Project is intended to be the FPGA implementation of Frame Capture ( from a Bt. Composite video data form camera), Convert to the required Image format, and Communicate it to the Host PC via USB 2.0. The implementation is to be done on Xilinx Spartan 3 Series of FPGAs. The language used for HDL entry of the design is VHDL. For PC side Utility Microsoft Windows Based .NET framework s used. And for kiel Assembler is used for 8051 programming (USB controller).

The project is different from Commercially available capture cards as we need to have a propriety data transfre system to and from the Capture card.

Processing

November 8, 2006 4

Project details Project details

„„ Legacy design -Legacy design-

„„ based on now obsolete ISA busbased on now obsolete ISA bus

„„ Slow communication speedSlow communication speed

„„^ No Processing on board (FPGA only for control)No Processing on board (FPGA only for control)

„„ PC dependent systemPC dependent system

„„ New DesignNew Design

„„ Based on faster and more powerful Xilinx Spartan3® FPGABased on faster and more powerful Xilinx Spartan3® FPGA

„„ USB 2.0 based communication channel (up to 480 Mbps)USB 2.0 based communication channel (up to 480 Mbps)

„„^ Intelligent algorithms implemented on FPGAIntelligent algorithms implemented on FPGA

„„ Based on now common USB bus (PC independent)Based on now common USB bus (PC independent)

This Design is based on an older ISA bus based Card [1] by Stefan Widemann (ECE dapt UTk, Masters thesis – 1998). Due to the slow processing power, Obselete components and keen need to introduce intelligent real time processing on board level this new project has been undertaken. The !6 bit ISA bus based host computers for industrial use are costly as compared to other commercially available ones. The Communication protocol is obsolete and needs to fitted into specified PC slots. The Speed is slow and no intelligence is mounted on the board level. It is also hard to maintain and service.

Processing

November 8, 2006 5

System Diagram System Diagram

SRAM

U S B

This is a block diagram of the whole system where the intended Image capture card will fit in. the Industrial Color head ( the Analog Video Camera , flash, color sensor and casing) will provide the video input to the Frame Grabber card. The flash is controlled by the frame grabber card. The card will process and transfer the data to the PC via USB.

Processing

November 8, 2006 7

FPGA Modules FPGA Modules

Various modules implemented in the FPGA are as shown. The highlighted ones and the top level state machine are part of this project.

Processing

November 8, 2006 8

The main state machine The main state machine

RESET

RESET= '0'

Capture = '1' (^) I2C_Done = '1'

@ELSE

SAA7113_Done = '1'

@ELSE

USB_Done = '1' @ELSE

Contd_VGA_Displ

IDLE MEM_WE = 'Z'MEM_RD = 'Z'

Initialize_I2C Trigger_I2C

Trigger_Video_in MEM <=SAA

Wait_for_1_frame Trigger_7113 = '1'

Trigger_USB Trigger_USB= '1'

Wait_for_USB_Frm

State diagram for Top Level Finite State Machine. State1 – Idle Here the System is ready and in the reset state

State 2 – Initialize I2C. This is the first state where the I2C module (by M I Sharafat) is triggered, in this module the Video Input Processor is initialized using I2C single channel serial bus. The internal registers Of I2C are set to get the digitized data in the desired format. (720 X 480 pixels) + encoded Horizontal and vertical syncs, End of Video and Start of Video Signals The data is in YCbCr 4:2:2 (Bt.601) digital format and is interlaced

State 3 – Trigger Video Input Processor After the Video Input Processor is initialized the memory is connected to it for writing purpose and we wait for the next start of Frame

State 4 – Wait for Single Frame The 7113 interface module starts capturing the data from the start of frame and writes it to a De-interlaced form in memory.

State 5 – Trigger USB After Completion of the Frame capture the memory write Is disabled and memory is read by the USB interfacing module and is fed to the Cypress USB controller IC line by line (720 pixels each ).

State – Cont_VGA After the USB is fed with the correct data (1 full frame of image) then this debug module is called which continuously displays the memory contents into a optional VGA monitor This is End state and FSM come out only when RESET (another capture command is given).

Processing

November 8, 2006 10

SAA7113 Video Input ProcessorSAA7113 Video Input Processor

„„^ 9 bit Digital video output9 bit Digital video output

„ Standard ITU 656 YUV

format

„„ Multi format support (Multi format support ( NTSCNTSC

/PAL/PAL ))

„„^ Automatic control ofAutomatic control of

„„ gaingain „„ Anti aliasingAnti aliasing „„ white peakwhite peak

„ I2C-bus controlled

The Philips SAA7113 Video input processor is programmed ( using I2C protocol) to give the data in following format. Each horizontal line contains 1716 Bytes of data. Out of which first 276 bytes are the horizontal synchronization porches. The marked start and End of video codes are unique as they start with FF – 00 – 00 then contains the Synchronization information[3]. The effective 1440 bytes are divided into blocks of 4 bytes each representing 2 pixels. The 4 bytes have 2 luminance values (for each pixel) and 1 chrominance value (obtained using Cb and Cr Bytes) this chrominance vale Is distributed to both the pixels.

Processing

November 8, 2006 11

Block diagram of 7113 capture part Block diagram of 7113 capture part

FPGA Video decoder module 8 bit video data

Code Detector

Memory Address Generator

H-Sync V-Sync Field (interlacing)

Data to Memory

Address to Memory

Memory Write Enable

512 KB X 32 Bit SRAM (total 2Mb Ram)

Memory Chip Select Memory Output Enable

As shown the Memory address and Enable signals are generated by this module depending on the video decoded data. As we De-interlace the pixel data as well as discard the vertical and Horizontal sync parts.

Processing

November 8, 2006 13

About Connected component About Connected component

analysisanalysis

„„^ Algorithm.Algorithm.

„„ Initialize a content addressable memory for storing the labels (Initialize a content addressable memory for storing the labels (L) andL) and their addresses or label numbers (K).their addresses or label numbers (K). „„ Iterate through the image from left to right and top to bottom.Iterate through the image from left to right and top to bottom. „„ For every pixel select the label numbers (Ks) corresponding to eFor every pixel select the label numbers (Ks) corresponding to eightight neighborhood of the image. (say M,N,O,P)neighborhood of the image. (say M,N,O,P) „„ Out of these labels numbers (Ks) select the lowest Label numberOut of these labels numbers (Ks) select the lowest Label number (say(say M is smallest of them) and assign this number to Label Image pixM is smallest of them) and assign this number to Label Image pixelel corresponding to current pixel.corresponding to current pixel. „„^ Also change the content (say m, n, o, and p) of these LabelAlso change the content (say m, n, o, and p) of these Label number/address (M, N, O, P) to with the content of the minimumnumber/address (M, N, O, P) to with the content of the minimum label number (m).label number (m). „„ Continue the process for each pixel in the image.Continue the process for each pixel in the image.

The Algorithm is implemented using a 4 byte memory block. The labels are created into the FPGA as registers. And the labeled image is written back into another part of the SRAM. Then finally the maximum label is selected and the labeled image is discarded (as only the no of components and not there shapes is important.

Processing

November 8, 2006 14

Counting connected components Counting connected components

Original image converted to binary form Separating background from fore ground

Labeled image – Counting number of connected component

As shown the Labeled image is initially in binary format. (0 for background and 255 for foreground) the memory is read from left to right line by line. Each new foreground pixel is checked for neighboring pixels labels. If more than one labels are found in the neighborhood ( as for the 4th^ pixel in 4th^ line of the above image) then the minimum of the two labels are selected and the all labels are replaced by it. This process completes the labeling in one pass using content addressable memory (where memory address are pointed through their contents). The hardware implementation is hard to verify for correctness but gives desired accuracy for intended cotton images.

Processing

November 8, 2006 16

RTL diagram RTL diagram

Processing

November 8, 2006 17

Calculation of trash Calculation of trash

„„^ Measured as area percentage of Trash (twigs /Measured as area percentage of Trash (twigs / leafs) per Square inchleafs) per Square inch

„„ Calculated over binary Image in FPGACalculated over binary Image in FPGA

„„ State machine -State machine-

@ELSE ADDR = MAX_ADDR

Trigger

Check_if_done

Compare Background_CountTrash_Count

Read_Next_Pixel

STATE Compute

The state machine is as shown. It goes through the image and keeps two counters for background and foreground each. These data is passed on through USB to host for division as floating point calculations are costly in time and space on FPGA.

Processing

November 8, 2006 19

Cypress EZ- Cypress EZ-USB FX2 USB ControllerUSB FX2 USB Controller

The IC Used in this project for bus Controller is a Cypress EZ-USB chip. It has a microcontroller, FIFOs, Automatic Glue Logic manager (GPIF) and general communication ports. We have used two 8 bit ports for input and output data transfer purpose respectively. (port B – IN and Port D- Out). The Slave FIFO mode is used and 8051 just acts as the data enable and FIFO controller. The FIFO takes in parallel data byte and are strobe externally by FPGA. The FIFO is setup to automatically commit a line of 720 pixels to the Host thereby removing direct handshaking and error checking between FPGA and Host PC.

Processing

November 8, 2006 20

USB Enumeration & Re- USB Enumeration & Re-enumerationenumeration

The another Advantage of Using Cypress IC is there Re-enumeration technique. As shown the first process (device enumeration) takes place for every USB device on being connected to a host. While doing this the device is recognized as a general data storage device and the driver transfer the firmware (to 8051) to the device. Once the firmware is received the device does initiates a soft-disconnect. So even though the device is connected physically to the host PC the host PC sees it to be disconnected and then re connected (as a new device). This is called re- enumeration. Now in the second time the device identifies itself as the true device. (as now it has the required Firmware). In this way the need for having the firmware stored on the hardware is obviated.