Scorpion Vision XII – SMARTscript is Dynamic Configuration

scorpionxii-64x64In this post we describe another important element in the Scorpion Vision framework were we want to explain that

 Python SMARTscript is Dynamic Configuration

Scripting supplements the ease of point & click configuration to develop more accurate, robust and smarter 2D and 3D machine vision solutions.

This example, SDP-0147 DynamicResultPythonScript, uses an image of three valves. The image is from an old and simple 2D robot vision solution. The example is made to be an inspiration for Scorpion Vision developers.

is-2016-0020-precornerfilter_input
Image of three valves

The example shows how a simple script can do the following operations:

  • PreCornerFilter image using  the STC-0011-ImageFilter 4.1.0.52
  • FindCornerCandidates using the Blob4 tool
  • Display the filter image using a color palette.
  • Cluster the candidates using a smart python script
  • Display the clusters and the results using the STC-0013-DisplayResult 2.2.0.28
  • Create the ClusterArea for each Cluster – STC-0100-PolygonCreator2D 1.0.0.5
  • Display the ClusterArea
is-2016-0020-cluster_result_2
The updated PythonScript tool support dynamic results – the cluster results is shown

This is the 4th post in series of Scorpion Vision Software important tool improvements included in upcoming – Scorpion Vision XII.

Python makes Scorpion an Open Flexible Development Platform

Python is an integral part of Scorpion Vision Software. It makes Scorpion Vision an open, extendable and flexible development platform for the most advanced machine vision solutions.

Easy to import major Open-Source libraries like OpenCV 3, Numpy and SciPy.

is-2016-0020-cluster_opensource

The Zen of Python (PEP 20), which includes aphorisms such as:[45]

  • Beautiful is better than ugly
  • Explicit is better than implicit
  • Simple is better than complex
  • Complex is better than complicated
  • Readability counts

PreCornerFilter image using  the STC-0011-ImageFilter 4.1.0.52

The ImageFilter Scorpion Tool Component is very useful. The filter string does the following:

  • m3 – median filter image block size 3
  • p11,0.0005 – precornerfilter image with size 11 and scale 0.0005
  • X normalises the image
is-2016-0020-precornerfilter
The filter string to precorner filter an image

The image below shows the input image and the filtered image with a color palette.

is-2016-0020-pythonfilterresult

FindCornerCandidates using the Blob4 tool

The Blob4 tool locates the strongest peaks from the precorner filter to find corner candidates

is-2016-0020-blob4-intensitysort
New option to sort Blob4 result by intensity value

Cluster the candidates using a Smart Script

The core clustering uses a KDTree from Scipy to cluster all corner candidates. The script locates the largest cluster – removes repeatably the candidates in the largest cluster MaxIterations times and clusters again.

is-2016-0020-cluster_corescript_2
The clustering is fast – typical 1 ms

Display the clusters and the results using the STC-0013-DisplayResult 2.2.0.28

The DisplayResult displays the cluster string C1=(3,(315.7,334.2),11) in the image.

is-2016-0020-stc-dynamiclinking
The STC support %1i tool indexing that extract the index from the toolname Cluster1

Create the ClusterArea for each Cluster – STC-0100-PolygonCreator2D 1.0.0.5

The polygon creator uses the result from ClusterScript to create a polygon describing the cluser area.

is-2016-0020-polygoncreator

Display the ClusterArea

is-2016-0020-clusterarea
The Cluster Area shown – inside the Blob visualises all the corner candidates

Scorpion Tools in Action

The following Scorpion Tools and STCs, Scorpion Tool Components, are used in the demo profile SDP-0147 DynamicResultPythonScript – 1.0.0.5

  • PreCornerFilter – STC-0011-ImageFilter 4.1.0.52
  • FindCornerCandidates – Tool 87 – Blob4
  • ClusterScript – Tool 3 – PythonScript
  • ClusterN – STC-0013-DisplayResult 2.2.0.28
  • CircleN – STC-0100-PolygonCreator2D 1.0.0.5
is-2016-0020-cluster_script_2
The complete ClusterScript that defines the datamodel and performs clustering using the Spatial module in SciPy