Aurora Visio Studio TOP » Program Examples » Coins

Coins

目的

Devise an algorithm which will count the money amount visible on a video frame.

Input

The single video file with contains coins on the white background. Video is stored in AVI format.

Output

Amount of money visible on a single video frame.

ヒント

Aurora Vision Studio offers a convenient way to perform off-line inspection with images stored as single files or as a video file. To read video file, the ReadVideo filter must be used. To store camera frames for further off-line inspection, use the WriteVideo filter.

In many cases background of images are still and only objects under inspection are introduced to the inspection scene. To extract background from image, the SubtractImages may be used. But the most useful filter is the ThresholdToRegion_Relative which selects region pixels by analyzing intensity difference between them.

To avoid loading background image in every iteration the first video frame should be saved to an external AVDATA file. Image will be loaded only once, while whole program is loaded from file.

Obtaining coin values can be performed by analyzing theirs diameters. In the video there are two kinds of coins. First with diameter around 40 pixels and second about 50 pixels. After coins extraction the found region must be split into separate coins and then classified using one of region features.

To compose more complex string, the Formulas can be used.

接続のラベル付けについては こちらを参照ください。

Solution (AVS)

  1. Add the ReadVideo filter to project and perform single program iteration. Drop it in the ACQUIRE section.

  2. Add the DelayByPeriod filter to the same section. Set the inTime to 25 to slightly reduce the speed of the video.

  3. Save the first video frame to the AVDATA file..

    • Right click on the outImage output and use "Export to AVDATA file...",
    • Select destination directory and a file name.
  4. Add the ThresholdToRegion_Relative and connect to it the output of the ReadVideo.

    The image below shows the region after the thresholding.

  5. Split the region into separate blobs using the SplitRegionIntoBlobs. Remove all regions that not fits the coin area.

  6. Add the ClassifyRegions and select classifying feature to DiameterLength. Select classifying range to (40, 50). Now on the outAccepted output we have all regions of smaller coins (1 eurocent). We can label that output SmallCoins. On the outAbove output we have regions of the bigger coins. Label it as BigCoins.

  7. Expand the outAccepted and the outAbove and add the Count output. Label them SmallCount and BigCount.

  8. Add the Empty formula to program and create:

    • Output outAmount of type Integer and compute amount:

      Amount = SmallCount + BigCount * 5

    • Output outMessage of type String and create there an output message:

      Message = toString(Amount) + " euro cent(s)"

  9. Add the DrawStrings_SingleColor and draw outMessage on the input image.

  10. Add the inImage to a new preview window.

Macrofilter Main extracts coins from video frames and calculates visible money amount.

使用したフィルタ

アイコン 名前 説明
ClassifyRegions Use this filter when you have an array of regions and you want to select some of them for further processing.
DelayByPeriod Suspends the program workflow for inTime milliseconds relative to the end of the filter's last invoke time.
DrawStrings_SingleColor Draws strings (text) on an image with a single color.
ReadVideo Reads a frame sequence from a video file.
ThresholdToRegion_Relative Thresholds an image with a different threshold value for each pixel (inBaseImage(x, y) + inValue).
SplitRegionIntoBlobs オブジェクトが互いに接触していない場合に、領域を個々のオブジェクトにセグメント化します。

その他の資料

  • Blob Analysis - ブロブ分析手法について詳しく説明します。
  • 数式 - 数式の使用に関する詳細情報です。