Up | Events | Commands | Python API | Using References | Release Notes

 

  

 
Using References

Scorpion ImageX has some simple drawing methods for applying overlay graphics to the image, typically this is done in the OnImage event.

Default all coordinates are specified in pixel coordinates but by applying reference systems to the control, drawing methods can give coordinates relative to a reference systems origo. A reference system is a 3x3 matrix defining image scale, origo, rotation and perspective. In addition the control can use a calibration file to correct for lens distortion, lens magnification and camera magnification.

Setting Calibration

SetCalib(filename)

Filename is name of a Scorpion Calibrator tool calibration file (file extension .cal). If the calibration file don't exist or no filename is given the calibration is removed from the control.

Setting Reference System

SetReference(name,reference)

Name is the name of the reference since the control can have multiple reference systems defined. If any draw method refers to a non existing reference the coordinates defaults to pixels.

The reference is a 3x3 tuple in form ((m11,m12,m13),(m21,m22,m33),(m31,m32,m33)). The matrix itself is not easy to construct but Scorpion have support for creating references by the python tool class.

Creating reference systems from Scorpion.

The python tool class in Scorpion may be used for reference creation. The tool class has two properties, refSys and childRefSys, input and output reference system respectively. By examine these properties for various tools in a Scorpion profile  

Example:

OnInit

SetCalib('c:\\profiles\\demo\\calibrator.cal')                  #set the calibration file
SetReference('UPLEFT',((1,0,0),(0,1,0),(0,0,1)))            #defines reference MM, default pixel coordinates
SetReference('CENTER',((1,0,0),(0,1,0),(-240,-320,1))) #origo in center of VGA, pixel coordinates

OnImage

DrawRect('UPLEFT',10,10,620,460,'red')  #draws a rectangle
DrawMarker('CENTER',0,0,'red',4,4)        #draws a marker '*' in center of image
DrawRect('CENTER',-10,-10,20,20,'red')  #draws a rectangle in center of image

Transferring reference system from Scorpion Vision Software using files

cal=GetTool('Calibrator')    #get the calibrator tool
line=GetTool('FindLine')      #get the linefinder tool
f=file('refsys.py','w+')
f.write("SetReference('REF'," + str(cal.childRefSys) + ")\n"
f.write("SetReference('LINE'," + str(line.childRefSys) + ")\n"
f.close()

 

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