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

Scorpion 3D Stinger wins Innovator Award

Tordivel wins the Vision System Design Innovator Award for 2016 for Scorpion 3D Stinger for Robot Vision. 

Scorpion 3D Stinger for Robot Vision identifies and locates any part in 3D with sub-pixel accuracy. The system features one or more Scorpion Stinger 3D Cameras, each of which consists of two cameras (VGA to 5MPixel), a number of projector options, and an algorithm to locate 3D features.

Read more @ Vision System Design

Scorpion Vision Training in Oslo 18. – 20. March 2015

Fly in to the best machine vision training and learn from the experts behind Scorpion Vision Software®. Learn how to build complete Scorpion Compact Vision systems with our Scorpion 2D and 3D Stinger cameras.

The course is based on the newest Scorpion Vision Software® release X including Stereo Vision and 3D Robot Vision. Attend one, two or all three days.
Invitation March2015

Invitation pdf-format

Scorpion Vision Version XI is here!

Scorpion Download X.I

Scorpion Vision XI Download

We are proud to announce that Scorpion Version XI build 572 is available. The release contains the aggregated updates since Scorpion Version X was released in October 2012 more than two years ago.

This major release of Scorpion Vision Software has many new features and possibilities.

  • Compatible with latest Scorpion 2D and 3D Stinger hardware
  • Faster image processing and more tools supporting multi-core processing
    • Many tools has prefiltering option
  • Improved OpenCV 2.4.9 and Python 2.7 support
    • The move to Pythons improves the ability to use 3rd party libraries
  • Updates Scorpion Tool Components – STC
    • Components for 3D Calibration, dense 3D image generation and more
    • Updated image filtering components
    • Support for 3D Factory Calibration
  • Improved Scorpion Camera Drivers for Sony and Basler GigE Cameras
    • First version of  port based making it easier to switch cameras.

The release will support the upcoming OpenCV 3.0 when released in 2015.

Read more about upgrading to Scorpion Vision XI

Locating Multiple Circles with the “new” CircleSegmentor

Locating circles is a classic challenge in machine vision. On the LinkedIn group “Computer Vision” – Axel Laurent posted the following :

“I would like to divide this image in several sub-images where in each sub-image containt a circular object. I used hough transformed to detect the circal object center and then I used watershed to segment the image but due to the importance of noise that doesn’t work”. 

Raw Image

Original Raw Image

A heated discussion – 59 posts are received so far –  started immediately and I posted a solution to the post based on the Scorpion Vision tool CircleSegmentor.

We have since then upgraded CircleSegmentor one of the major tools in Scorpion Vision Software with a new powerful clustering step based on kMeans method – this increased the robustness and in some cases tripled the speed of our fine point and click solution.

1. Extract Canny Edge from the Image after median filter m9

The following images shows canny edges after median filtering – this shows that it is possible to focus on two “circles” the inner dark circle or the larger grey circle.

Canny Edge Extration after m9 median filtering

Canny Edge Extration after m9 median filtering

Circle Segmentor Gradients Setup Tab

The setup dialog shows the Prefilter performing median filtering on the image and the Canny Edge detection parameters.

Gradient Setup

Gradient Setup

3. Ransac RawCenter Extraction

The next step in CircleSegmentor circle detection is to estimate the circle clusters or rawmatches with a Ransac algorithm where we use the diameter and the edge angle to estimate circle center candidates – these are shown in blue. The setup is defined in the Search Setting in the Gradient Tab – see above.

Ransac Raw Centers Candidates

Ransac Raw Centers Candidates

4. Multistage kMeans Clustering 

The next and new feature is to cluster the rawmatches and calculate a cluster center of gravities – COGs. The advantage of the clustering is to qualify the centers by rawmatch density or a user specified cost function – thus avoiding timeconsuming circle model validations.

Multistage kMeans Clustering

Multistage kMeans Clustering

Clusters configuration

The cluster configuration is shown below:

Cluster configuration tab

Cluster configuration tab

Cluster Zoom

The cluster zoom shows how the convex hull selects the primary cluster based on density and calculates a pretty good center of gravity.

Clusters Zoom

Clusters Zoom

5.  Final Circle Match based on Cluster COG

The final step is to iterate the located clusters. For each cluster the center of gravity is used as a starting point for circle matching. A circle model is defined and matched with the PolygonMatch algorithm thats fits the edge points to a circle with sub-pixel accuracy. Circle 7 and 14 shows that the algorithm handles occlusion.

Locates all circles with sub pixel accuracy and handles occlusion

Locates all circles with sub pixel accuracy and handles occlusion

It is fast – 17 circles in 100 ms on a quad-core laptop computer.

Read more

Video – AH Feeder – flexible robot picking

AH Feeder is the name of AH Automation’s robot cell picking parts. The product is developed to fit into existing production environments and to quickly get a user and cost-effective automation solution for otherwise time-consuming handling.

Read more…

Scorpion Compact Vision Training in UK 26th-27th February 2013

Fly in to the best machine vision training  and learn from the experts behind Scorpion Vision Software®.  Learn how to build complete and compact machine vision systems with our Scorpion 2D and 3D Stinger cameras. Read more about Scorpion Compact Vision Systems.

Scorpion Compact Vision Family

The course is based on the newest Scorpion Vision Software® release 10.2 including state of the art Stereo Vision and 3D Robot Vision.

Venue :  Mitsubishi Electric – Traveller Lane, Hatfield – Hertfordshire AL10 8XB – United Kingdom

Click to get the agenda and register