In 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.

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

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 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

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

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.

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.

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.
Display the ClusterArea

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

You must be logged in to post a comment.