Lab2 Tutorial

20
ECE 354 Lab 2: Capturing and Displaying Lab 2: Capturing and Displaying Digital Image ECE Department: University of Massachusetts, Amherst

description

display image

Transcript of Lab2 Tutorial

Page 1: Lab2 Tutorial

ECE 354354

Lab 2: Capturing and Displaying Lab 2: Capturing and Displaying Digital Image

ECE Department: University of Massachusetts, Amherst

Page 2: Lab2 Tutorial

Big Picture IntroductionBig Picture Introduction

Understand the existing SOPC builder setup with new modification

Capturing image using camera Storing the captured image in the frame buffer Display the image on a CRT monitor with the use of a VGA p y g

controller Perform simple image processing Primarily written in C code

2ECE 354

Page 3: Lab2 Tutorial

Additional HardwareAdditional Hardware

TRDB_D5M Digital CameraS i l C t d Serial Connector and Cable

CRT MonitorCRT Monitor

3ECE 354

Page 4: Lab2 Tutorial

Skills to learnSkills to learn

Integrate code with preexisting code Integrate code with preexisting code Understanding previously written code Connect to a device that you did not design Writing a communication protocol to somebody else’s

specifications

4ECE 354

Page 5: Lab2 Tutorial

Steps taken to complete projectSteps taken to complete project

Begin by looking over camera documentation Understand SOPC builder setup given Understand SOPC builder setup given Write a C program to capture data into FIFO buffer C program to transfer data from FIFO to flash memory

f Gain knowledge of how the DE2_NIOS_HOST_MOUSE_VGA project displays an image to the CRT monitor

Use that knowledge to display your image Finally have fun performing image processing

5ECE 354

Page 6: Lab2 Tutorial

Lab2 SetupLab2 Setup

[1] TRDB_D5M_Userguide http://www.terasic.com.tw/attachment/archive/281/TRDB_D5M_UserGuide.pdf

[1]

6ECE 354

p _ _ p

Page 7: Lab2 Tutorial

Overview of DE2 NIOS HOST MOUSE VGA projectOverview of DE2_NIOS_HOST_MOUSE_VGA project

Implements a monochrome display, with a preloaded image, where the user can draw on it with a mousewhere the user can draw on it with a mouse

USB mouse should be connected USB HOST port CRT monitor should be connected to the VGA port

You will integrate your code so that the project displays the You will integrate your code so that the project displays the image received from digital camera

7ECE 354

Page 8: Lab2 Tutorial

SOPC builder setup:SOPC builder setup: Based on DE2_NIOS_HOST_MOUSE_VGA The program code is stored in SRAM memorye p og a code s sto ed S e o y Parallel Input/output interface(PIO) for LED, switches Camera Avalon Interface(Camera_IF) helps in transferring

image data image data The dedicated SDRAM is used as a frame buffer that holds

a single frame of video at the time. The SDRAM is controlled and accessed by using the four The SDRAM is controlled and accessed by using the four-

port controller hardware Controller can be used to read or write to the SDRAM

through its four FIFO buffersthrough its four FIFO buffers. Flash controller is used tocontrol the data transfer to flash

memoryVGA t ll di l i d t t VGA

8ECE 354

VGA controller displaying data on to VGA

Page 9: Lab2 Tutorial

Block diagram of Terasic camera systemBlock diagram of Terasic camera system

TRDB_D5M_Userguide http://www.terasic.com.tw/attachment/archive/281/TRDB_D5M_UserGuide.pdf

9ECE 354

Page 10: Lab2 Tutorial

Hardware Modules for this LabHardware Modules for this Lab

SDRAM-Multiport Controller:Thi d l i i 4 t SDRAM t llThis module is a generic 4 port SDRAM controller.

It uses two FIFO buffers for inputs (writing) and two FIFO buffers for outputs. The FIFO buffers two FIFO buffers for outputs. The FIFO buffers are made using Altera MegaFunctions and are 16 bit wide and can hold up to 512 words of this size In this system the SDRAM controller is used size. In this system the SDRAM controller is used as a frame buffer to hold a single picture frame

Flash Controller VGA controller Camera Avalon Interface module

10ECE 354

Page 11: Lab2 Tutorial

To get started with the labTo get started with the lab Run the DE2_NOIS_MOUSE_VGA_project present in the

project folder given to you Run SOPC builder and understand each of the components

added and configuration present Hardware component files are present under IP folderp p

• It contains SDRAM_4 port controller components• Camera Avalon Interface

Software components are present under the software folderSoftware components are present under the software folder• Hello_led_0 has all the required software component files• Some part of code is given in this project which is present in

file hello led.ce e o_ ed c

11ECE 354

Page 12: Lab2 Tutorial

Information for C programInformation for C program

C code to capture camera data and store it in frame buffer Picture taken at 640x480 has 3 data per pixel times 8 bits Picture taken at 640x480 has 3 data per pixel times 8 bits

(at least) each, this would mean a total of 7,372800Mbit or 921,6 Kbyte

So efficient storage design required So efficient storage design required Recommended C code function

• Camera Capture( l ) d f l h• Copying RGB(pixels) data from FIFO to Flash memory

• Using flash memory to store the pixel data before transferring to VGA output

Program space memory is less (SRAM).Avoid unnecessary buffers. Write programs as efficient as possible

12ECE 354

Page 13: Lab2 Tutorial

Readout modes: D5M cameraReadout modes: D5M camera

The Terasic D5M camera supports a function called :called :

1. binning -This function reduces the resolution of the image by averaging pixels togetherg y g g p g

2. Skipping - reduces the output resolution ith t ff ti th fi ld f i It d thi b without affecting the field-of-view. It does this by

not sampling entire rows and columns of pixels. A skip 2X mode skips one of pixels for every pair p p p y pof output.

13ECE 354

Page 14: Lab2 Tutorial

Displaying image through VGA controllerDisplaying image through VGA controller

Look through VGA.h for VGA functionsVGA functions

Write C code similar to that shown below that calls functions from VGA.h calls functions from VGA.h to display each pixel

It is your job to come up with an equation to check with an equation to check each pixel in your receive buffer

14ECE 354

Page 15: Lab2 Tutorial

Additional informationAdditional information

The image should be 2-bit gray scale with a resolution of 640x480640x480

Uncompressed image I recommend starting with the smallest image resolution

and work from thereand work from there

15ECE 354

Page 16: Lab2 Tutorial

Image ProcessingImage Processing

It is required that you implement two forms of image processing image processing

Recommendations include:• Add timestamp onto imagep g• Counter to keep track of number of pictures taken• Rotate, mirror, invert image• Simple edge detection (challenging)• Simple edge detection (challenging)• Detect changes in images (challenging)

16ECE 354

Page 17: Lab2 Tutorial

References for software and hardware design in Lab2References for software and hardware design in Lab2

I recommend looking over section II of the NIOS II Software Developer’s Handbook

Go through project titled- Embedded Demonstrator for Video g p jPresentation and Manipulation by Cato Marwell Jonasse (Google it) to get clear insight on hardware description for this project(You can go through chapter 9 specifically)( g g p p y)

DE2_NIOS_HOST_MOUSE_VGA project

NIOS II Software Developer’s Handbook• http://www.altera.com/literature/lit-nio2.jsp

17ECE 354

Page 18: Lab2 Tutorial

Where does this project lead?Where does this project lead?

Next lab will be on the topic sending data over a network• Sending image between DE2 boards• Sending image between DE2 boards• Don’t worry if you have not taken computer networking

18ECE 354

Page 19: Lab2 Tutorial

Questions and CommentsQuestions and Comments

19ECE 354

Page 20: Lab2 Tutorial

Back up

20ECE 354