Assignment 5


Objective: Understanding of low-level graphics manipulation, 2-Dimensional data structures, dynamic data types
Description: In this assignment, you will be creating real-time video filters. You will be required to purchase (or borrow from someone) a camera, preferably a USB Intel or Logitech camera. When the user presses a key, this will trigger one of the filters, which will modify the video captured by the camera.
Background: You will be given most of the code for this project - enough so that you can run the program, and see what is displayed on the screen. In the code provided, there is a variable named 'dataPtr', which is an array of ARUint8's (discussed below). dataPtr is really a pointer to the information that was just captured by the camera. So the general algorithm is to change these values before they are written to the screen.
The ARUint8 data type is really just one byte, and a color is comprised of 4 of them: the blue component, the green component, the red component, and then an unused 'alpha' or transparency component. We call this BGRA. Component values range from 0-255.
An example of how to make the blue filter is to set the red and green components to 0, and leave the blue component alone. We will discuss how to implement the other filters in class.
For the sinusoidal distortion filters, you will essentially have a lookup array that is pre-calculated. The array determines how many pixels the current pixel needs to be shifted to the left or the right. For example, the outer pixels need to be shifted hardly at all, but the inner pixels need to be shifted a lot. Let's say that we have a magnification of 10, then:
| Slot | 0 | 1 | 2 | 3 | ... | middle | of | screen | ... | 316 | 317 | 318 | 319 |
| Amount of Shift | 0 | -1 | -1 | -2 | -9 | -9 | 9 | ... | 2 | 1 | 1 | 0 |
Once you have this information, you can create a distorted frame by copying values from the current video frame plus the offset!
You will also need to set up Visual Studio to change the include, lib, and source directories; without doing this, the code will not compile/run correctly. There will be a small lab coming soon to help you out.
Requirements: You will be required to write the following filters:
'o' - normal; no video manipulation occurs
'r' - Red filter: only red values are displayed
'b' - Blue filter: only blue values are displayed
'w' - Black and white only, like the first image displayed above
'g' - Greyscale; like an old black and white television
'n' - negative; an inversion of all colors; this is achieved by 'inverting' the values. 0's go to 255, 255's go to 0, 128 would go to 127, 100 would go to 155, etc...
m' - mirror image; the right side of the screen will be a reverse of the left side. Essentially only half of the screen will be real video, and the other half a mirror of it.
'h' - ghosting; the middle image above. This is accomplished by adding only 1/n amount of the current video frame to a 'history', then displaying that history.
'z' - horizontal sinusoidal distortion; this should stretch the image to the left and right;
'v' - vertical sinusoidal stretching; both the horizontal and vertical distortions can produce some pretty messed up images.
's' - both vertical and horizontal stretching
Extra Credit: For 0xe16 points, do the following:
'+' - magnifies the z, v, and s filters
'-' - de-magnifies the z, v, and s filters
Example:
Program Turnin: You will demo this in class.