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.

Since version 5.0, the new Results control (located in the panel at the bottom-right of the program window) allows you to continuously keep track of the values returned by the currently selected filter(s) as well as perform quick real-time Pass/Fail analyses based on the criterion described within the Limits parser. If this control is not visible you may enable it through View » Results)

In the image below you can see that at the ScanMultipleStripes filter, 4 stripes were scanned on 7 out of 8 inspections, meaning that in 7 out of 8 images the number of bottles displayed was 4. Try inserting your own values into the parser and see what kind of results you will be receiving. Hover your cursor over the question mark in order to find out what other kinds of criteria can be parsed into the Limits box.

Solution (FIS)

  1. Add EnumerateImages filter to ACQUIRE section to load images from files.

  2. Add ScanMultipleStripes filter to PROCESS section.

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

  4. In ScanMultipleStripes filter set the following parameters:

  5. Expand outStripes output of ScanMultipleStripes filter. Choose Count property output.

  6. Click on the ScanMultipleStripes filter and go to the results control (results control was described in Hints section of this tutorial). Check in out.Stripes.Count and enter 4 in the Limits column.

  7. Add DrawStrings_MultiColor filter to draw the number of bottles. Set inLocations parameter to any suitable location within the input image. Connect outStripes.Count to inStrings and outStripes.Count.Status to inColorIds.

Macrofilter Main

Further Readings