This chapter will demonstrate the built-in functions of OpenCV for Processing IDE. The code for each  example (for Processing IDE) is provided at the bottom of the screenshots. You can try these features and use them in many different applications depending on your imagination.


Let's start by having a look at these features and built-in functions. 

Brightness and Contrast

Adjust the brightness and contrast of colour and grey images.

Code: BrightnessContrast.pde


Filter Images

Basic filtering operations on images: threshold, blur, and adaptive thresholds.

Code: FilterImages.pde


Find Contours

Find contours in images and calculate polygon approximations of the contours (i.e., the closest straight line that fits the contour).

Code: FindContours.pde

Find Edges

Three different edge-detection techniques: Canny, Scharr, and Sobel.

Code: FindEdges.pde

Find Lines


Find straight lines in the image using Hough line detection.

Code: HoughLineDetection.pde

Brightest Point


Find the brightest point in an image.

Code: BrightestPoint.pde

Region of Interest


Assign a sub-section (or Region of Interest) of the image to be processed.

Code: RegionOfInterest.pde

Image Difference


Find the difference between two images in order to subtract the background or detect a new object in a scene.

Code: ImageDiff.pde

Dilation and Erosion


Thin (erode) and expand (dilate) an image in order to close holes. These are known as "morphological" operations.

Code: DilationAndErosion.pde

Background Subtraction


Detect moving objects in a scene. Use background subtraction to distinguish background from foreground and contour tracking to track the foreground objects.

Code: BackgroundSubtraction.pde

Working with Colour Images


Demonstration of what you can do colour images in OpenCV (threshold, blur, etc) and what you can't (lots of other operations).

Code: WorkingWithColorImages.pde

Colour Channels


Separate a colour image into red, green, blue or hue, saturation, and value channels in order to work with the channels individually.

Code: ColorChannels.pde

Find Histogram


Demonstrates use of the findHistogram() function and the Histogram class to get and draw histograms for grayscale and individual colour channels.

Code: FindHistogram.pde

Hue Range Selection


Detect objects based on their colour. Demonstrates the use of HSV colour space as well as range-based image filtering.

Code: HueRangeSelection.pde



An example of the process involved in calibrating a camera.

Code: CalibrationDemo.pde

Histogram Skin Detection


Detecting skin in an image based on colours in a region of colour space. Warning: uses un-wrapped OpenCV objects and functions.

Code: HistogramSkinDetection.pde

Depth from Stereo


An advanced example. Calculates depth information from a pair of stereo images. Warning: uses un-wrapped OpenCV objects and functions.

Code: DepthFromStereo.pde

Warp Perspective


Un-distort an object that's in perspective.

Code: WarpPerspective.pde

Marker Detection


An in-depth advanced example. Detect a CV marker in an image, warp perspective, and detect the number stored in the marker. Many steps in the code. Uses many un-wrapped OpenCV objects and functions.

Code: MarkerDetection.pde

Morphology Operations


Open and close an image, or do more complicated morphological transformations.


© 2019 Creoqode