Processing a single video frame
Now we begin to learn the methods of processing video. Values of pixels in the current video frame can be read in a way similar to the one in ofImage
, using access to its pixel array data:
unsigned char *getPixels()
Also, here is the
getPixelRef()
method, which returns a reference to a pixel array of the current frame, represented by a special class ofPixels
.
Tip
Note that the ofImage
class has getPixelRef()
too and can be used in a similar way.
It is easy to get the pixel color using pixels.getColor( x, y )
, which returns the ofColor
value of pixel ( x,y )
. Compared to directly working with pixels data using getPixels()
, it is a relatively slow operation, but is more simple and convenient. Note, ofPixels
has useful properties such as getWidth()
and getHeight()
that are used for getting the width and height, and also the channels
value, which holds the number of channels in the image (1
, 3
, or 4
).
The vertical lines image example
See the example where we read the...