You are here: Start » Tutorial Exercises » Bottle Inspector Part 1: Counting Bottles (bottles_1_counting)

Bottle Inspector Part 1: Counting Bottles (bottles_1_counting)

Aim

Prepare a program that returns the number of bottles found in the provided images.

Input

A set of images with bottles. The bottle count may vary but the maximal number of bottles is 4.

Images are stored in bottles directory.

Output

An image with the bottle count printed on it.

Hints

The bottle tops can be viewed as darker regions on the brighter background. The profile below shows the transitions of brightness values along a selected scan path. We want to detect the objects that start with a bright-to-dark transition and end with an opposite one.

The ScanMultipleStripes filter can be used for this purpose.

Solution (AVS)

  1. Add an EnumerateImages filter to load images from files.

  2. Add a ScanMultipleStripes filter.

  3. Open the path editor for the parameter inScanPath and set the path as in the picture below:

  4. In the ScanMultipleStripes filter set the following parameters:

  5. Expand the outStripes output of the ScanMultipleStripes filter and show its Count property.

  6. Add a DrawStrings_SingleColor filter to draw the bottle number. Set its inLocations parameter to any suitable location within the input image.

Macrofilter Main