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.

Image of three valves

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

  • PreCornerFilter image using  the STC-0011-ImageFilter
  • 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
  • Create the ClusterArea for each Cluster – STC-0100-PolygonCreator2D
  • Display the ClusterArea
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.


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

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
The filter string to precorner filter an image

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


FindCornerCandidates using the Blob4 tool

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

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.

The clustering is fast – typical 1 ms

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

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

The STC support %1i tool indexing that extract the index from the toolname Cluster1

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

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


Display the 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 –

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