ScorpionOpenCV key features
- uses on Scorpion Arrlib structures
ScorpionOpenCV is a Scorpion encapsulation of OpenCV 1.1, primarily filter functions. These filters are a valuable part of OpenCV that is a part of the Scorpion Vision Software framework.
ScorpionOpenCV is multithreaded while standard OpenCV 1.1 single threaded. Working with large images the performance gain is significant.
The following methods are implemented:
ScorpionOpenCV works on Scorpion Arrlib’s data structures, there is no need for transferring Scorpion structures to Numpy as for standard OpenCV. The python module ScorpionOpenCV.py is distributed with the Scorpion Vision installer and is located in the Python sub-folder.
Scorpion Vision supports a image filter command strings to perform image filtering to an image, either pre-filter or post-filter. These filters was first invented in the STC-0011-ImageFilter. This is STC or Scorpion Tool Components.
The filter commands strings make it easy to create customs filter where parameter settings and filter sequence are defined by command string.
c40,200,3m3 # canny followed by a median smooth filter
These filters are supported by various tools like TemplateFinder3 and ColorSegmentor.
The filter format is given by a command string where filter type is given by a single letter followed by one or more parameters.
Multiple filters can be combined in any sequence. Some filters are optimized by threading, this applies mainly for larger images (>VGA) and may be tuned due to image size, filter aperture and no of cpu’s.
The following subset of filters are supported by ScorpionOpenCV imageFilter command.
|Dilate||d<iterations=1><,threads=n> # example - d2|
|Erode||e<iterations=1><,threads=n> # example - e4|
|Close||C<iterations=4><,threads=n>,# example - C2|
|Open||O<iterations=4><,threads=n> # example - O4|
|Laplace||l<aperture=3><,threads=n>, # example - l3|
|Normalize||N<aperture=21><,scale=255><,percentile=50><,threads=n> percentile is currently fixed at 50 but has to be specified if threads is to be specified|
|Threads||‘|’<threads> no of threads used for following commands, ‘|’ - PIPE chacter. All functions uses by default 4 threads|
Example 1: Canny and erode, using 8 threads for erode
Example 2: Image blur
Example 3: Adaptive Threshold
Example 4: Normalize image
Example 1 - Using imageFilter inside a BaseTool
The example is from the Scorpion Vision Toolbox inside the BaseTool’s execute method.
It is required that the tool has implemented a data input configuration
- Filter # contains image filter string
- OutputImage # contains image filter destination image
def execute(self,image): # use self.name to get this tool instance # tool=GetTool(self.name) # image parameter is a python image matrix due to ROI # Return 1 for pass, 0 for fail import ScorpionOpenCV tool=GetBaseTool(self.name) #get this tool instance dst=image #allocate destination of same type and size - critical ScorpionOpenCV.imageFilter(tool.arrState,image,dst,tool.getString('Filter')) SetImageMatr(tool.getString('OutputImage'),dst) return 1