Recent Changes - Search:


Robotics I Fall 2007

Robotics II Spring 2007

Robotics I Fall 2006

Vision Servoing Laboratories

FPGA-Based Vision


LabVIEW Embedded


Site Admin

edit SideBar

Lab 6: Vision


We talked about the YUV color space. We also looked at the visible spectrum of light, considering short wavelengths (indigo) through long wavelengths (red). We came to a hypothesis that the CMOS camera consists of alternating pixels that detect "amount of blue" (U+Y) and "amount of red" (V+Y).

This was supported by the YUV-to-RGB formulas, in which red is based on luminance (brightness) plus a factor of V, and blue is luminance plus a factor of U.


  • OV7260 sample project is on the Share Drive, at Please make a local copy onto your work machine.
  • When you build the project, make sure to add the external library file in the project manager, LabVIEW Camera Test/OV7620/for LabVIEW/libov7620/Debug/libov7620.dlb. You'll have to change the file dialog filter to allow all files (*.*) for this file to be visible.
  • Build and run the project. LED2 should flash, indicating frame grabs. Each flash-on and flash-off represents one frame grab.
  • To see the image in Visual DSP, do File:Load Program, and find the DXE file (Visual DSP executable) created by LabVIEW. Then go into Debug:Run (or hit F5) to run the program. After the 10 second white-balance, the LED should start flashing, indicating the code is running.
  • Hit halt, and the file "device.c" should come up. Scroll all the way to the bottom and insert a breakpoint at the final "return 0" statement. Run the program; it should halt at the breakpoint.
  • Click the "glasses" icon, which will bring up the Expressions window. In the function lv_adi_dev_WaitBuffer, go into the case statement for ADI_DEV_2D, highlight the variable "p2DBuffer", and drag it to the Expressions window.
  • Expand it open, find the ellipses bracket, and then find the value of the "Data" field. Copy the address.
  • Now, go to View:Debug Windows:Image Viewer, and a configuration window will pop up. Insert (paste) the address at the Start Address field. Change the pixel format to UYVY. Width is 320 and Height is 240. Select "Update at Halt" in Options. Hit OK.
  • Finally, run the program again. When the code hits the breakpoint, the Image Viewer should update with your image.

The Challenge

In the OV7620 test, the heart of the code is:

After the VI _BF Device Get Buffer u16, the image data is available as a LabVIEW array of 320x240 pixels. Each pixel is a 16-bit unsigned integer where one byte is either U or V and the other byte is Y. These words alternate, so each row consists of 160 UY words and 160 VY words; i.e.:

  UY VY UY VY etc for 240 total words.

The challenge is to write LabVIEW code that interprets the image data in the LabVIEW array and does something useful based on it. Look for the text "Process Buffer Here."

You may want to start by simply displaying a bit of this data as numbers to make sure things are working.


Note from Mark & Zack about color format in memory: Each pixel is represented by 16 bits. The MOST SIGNIFICANT 8 bits hold the intensity data, the Y. So to process using the Y data, use the Upper half of the byte. A good set of tools is Functions Palette > Advanced > Data Manipulation, specifically Split and Join numbers.

Note from Mark: To see a custom buffer from labview, follow these instructions. This page will show how to find a custom labview array in VisualDSP to display in the ImageViewer.

Note from Zack: This seems to be a good resource for mapping YUV to RGB. For those interested, there is also a way to get Hue from RGB.
Converting between RGB and CMY, YIQ, YUV

Improvements to speed:

	Make sure that the caches are enabled in the Build Options menu.
	When possible, use shift registers as they prevent to copying and freeing of large data arrays.
	Don't do your calculation on every data member.  Decimate the array by every A elements in both the X and Y direction.
		Make sure this is done in two dimensions, otherwise there will be an unneccesary density of points in one direction.
	Disable Parallel execution (advice From Andrew Chandler)

dec·i·mate (děs'ə-māt') Pronunciation Key
tr.v. dec·i·mat·ed, dec·i·mat·ing, dec·i·mates

   1. To destroy or kill a large part of (a group).
2. Usage Problem
a. To inflict great destruction or damage on: The fawns decimated my rose bushes.
b. To reduce markedly in amount: a profligate heir who decimated his trust fund.
3. To select by lot and kill one in every ten of.
Edit - History - Print - Recent Changes - Search
Page last modified on October 05, 2007, at 06:15 PM