O'Reilly logo

OpenCV 2 Computer Vision Application Programming Cookbook by Robert Laganière

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Using the Strategy pattern in algorithm design

The objective of the Strategy design pattern is to encapsulate an algorithm into a class. This way it becomes easier to replace a given algorithm by another one, or to chain several algorithms together in order to build a more complex process. In addition, this pattern facilitates the deployment of an algorithm by hiding as much of its complexity as possible behind an intuitive programming interface.

Getting ready

Let's say we want to build a simple algorithm that will identify all of the pixels in an image which have a given color. The algorithm has then to accept an image and a color as input and returns a binary image showing the pixels having the specified color. The tolerance with which we want ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required