The main topics you may need in this lab are:
Your goal for this lab is to create at least 5 different filters that each modifies the display image in a noticeable way. As part of this assigmentment you will create a menu that can add and remove filters on the fly, as the VideoStream window is shown.
A Video filter can be thought of as a transformation on a videostream much in the same way that previous labs have manipulated pixels of still images. You construct a filter by creating an algorthm that acts as a set of instructions or math to be followed by all the pixels of a video stream in the same way you would right an algorithm to tranform an image
Read the provided example of InvertFilter through and make sure you understand what is happening. You can use this code as a basis for contructing your own filters.
You'll notice the keyword class. A class is an expanded concept of a data structure: instead of holding only data, like an integer would a class can hold both data and functions. An object is an instantiation of a class. In terms of variables, a class would be the type, and an object would be the variable. VideoStream vs is the class and it creates a variable vs which is an instance of the class VideoStream. We won't get into this in any more detail in this course but it's a very useful and diverse programing concept.
As you can see, Invet Filter takes a video and flips it usid down by moving the pixels one at a time.
class InvertFilter: public Filter { public: virtual void filter(Picture * image) { int height = getHeight(image); int width = getWidth(image); Pixel temp; for(int h = 0; h < height/2; h++) { for(int w = 0; w < width; w++) { temp = getPixel(image,w,h); setPixel(image,w,h, getPixel(image,w,(height-1)-h)); setPixel(image,w,(height-1)-h,temp); } } } };
To Add a filter to the VideoStream Object, use the addFilter Command.
For example:VideoStream vs(robot,1); vs.startStream(); InvertFilter * inv = new InvertFilter(); vs.addFilter(inv);
To remove a filter, use vs.delFilter(int index).
To remove all filters, call vs.delFilter(0) for as many times as filter's you've added using vs.addFilter().
Your job is to create a menu that allows you to choose to apply 6 video filters, 5 you define and the InverseFilter as well as clearing all the active filters. To do this you must use a switch case statment. It would aslo be a good idea to have a variable to track how many filters you have applied.
Your Filters must be reasonably unique. You can, for example, have a fliter that shades everything green, and another that exchanges red and blue intensities, but not one that simply tints everything blue.
Good ideas for filters include:
1) Add ObamIcon Filter 2) Add Invert Filter 3) Add LightMask Filter 4) Add Red Hue Filter 5) Add Black & White Filter 6) Clear Filters 0) Exit