Aurora Visio Studio TOP » 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 (AVS)
-
Add EnumerateImages filter to ACQUIRE section to load images from files.
-
Add ScanMultipleStripes filter to PROCESS section.
-
Open the path editor for the parameter inScanPath and set the path as in the picture below:
-
In ScanMultipleStripes filter set the following parameters:
-
inStripeScanParams.StripePolarity to value Dark because caps are darker than the background,
-
inStripeScanParams.MinStripeWidth to 45 because the width is approximately equal to this value (it can be measured with a ruler from the top toolbar).
-
-
Expand outStripes output of ScanMultipleStripes filter. Choose Count property output.
-
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.
-
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
その他の資料
- 1D Edge Detection - The article explaining how edge detection filters work.