Up | General | Buttons | Setup | Visualisation | Results | ExecuteCmd

 

  

 
ExecuteCmd
The executeCmd tool interface is available in most Scorpion tools. This enables selected operations to be performed from a Python script. An overall description is given here; refer to each tool's help page for details and available commands.

Command format

ok,ret = <tool>.executeCmd('<command>','<parameter>=<value>;...')
ok,ret = <tool>.executeCmd('<command>;<parameter>=<value>;...')

<command> and <parameter>, and also <value> if it contains an object name (e.g., ROI) are case insensitive.

Common commands

The SET and GET commands have a standard format; see the examples below. "SOURCE", "DESTINATION" and  "CLIPBOARD" are reserved words, case insensitive.

Common objects

ROI - all image tools supports SET/GET ROI but some multi ROI tools may need additional parameters. The easiest way of getting format is by python statement "print ExecuteCmd('GET','OBJECT=<objectname>')"

Format of command may vary for different tools.

GET;OBJECT=ROI
SET;OBJECT=ROI;VALUE=<tool dependant>

CENTER - used by at least all tools supporting attachable templates, used to set center and angle (if angle supported).

Format of command

GET;OBJECT=CENTER
SET;OBJECT=CENTER;VALUE=((x,y,angle),) 
or  SET;OBJECT=CENTER;VALUE=((x,y),)

Return value

This is always a tuple, where the first element indicates success (1) or failure (0). The second element depends of the tool type and command.

Availability

The interface is always available, but note the following: When the tool's configuration dialogue is open, changes made to the tool from the executeCmd interface may be lost when the dialogue is closed. If you press OK or Apply, the changes are overwritten with the configurations dialogue's data. (ROI settings are always remembered.)


Example1: # Set ROI

tool = GetTool('Combiner') #Get a handle to an ImageCombiner tool
#Set ROI of tool
tool.executeCmd('Set','object=ROI;value=100,100,50,50')


Example2: # Set ROI from clipboard

tool = GetTool('Combiner') #Get a handle to an ImageCombiner tool
#Set ROI of tool using user defined points on clipboard
tool.executeCmd('Set','object=roi;source=clipboard')


Example3: # Copy Polygon ROI to clipboard

tool = GetTool('Combiner') #Get a handle to an ImageCombiner tool
res,ROI=tool.executeCmd('GET','OBJECT=ROI') # get tool's roi
res=tool.executeCmd('Get;OBJECT=ROI;destination=clipboard')


Example4: # Execute a tool specific command - Add a reference image

tool = GetTool('Combiner') #Get a handle to an ImageCombiner tool
tool.executeCmd('ADDIMAGE')


Example4: # Run a Toolbox on all centers located by a Blob4 instance

ring = GetTool('VerifyRing')
img = GetImageMatr('Image')
center = GetResultValue('tf3.AllCenters')
for pos in center:
  ring.executeCmd('SET','OBJECT=CENTER;VALUE=((%.4f,%.4f,0))' % (pos[0],pos[1]))
  ring.execute(img)
  

More examples - Example 33 - Changing the ROI of a tool

 

 

Scorpion Vision Version XII : Build 646 - Date: 20170225
Scorpion Vision Software® is a registered trademark of Tordivel AS.
Copyright © 2000 - 2017 Tordivel AS.