A very powerful feature in Scorpion is to run the tools from a script.
img=GetImageMatr('Image') #get the image
ref=GetTool('Reference') #get the reference
org=ref.result #store the origin
blob=GetTool('Blob')
line=GetTool('Line')
res=GetTool('Count')
distance = GetTool('Distance')
no = 0
y0 = -50
dSum = 0
for i in range(16):
blob.execute(img) #execute blob at first candle
y = ref.getValue('Value_y')
cnt=blob.result['Count'] #get result cnt
if (cnt >= 1) :
no = no +1
line.execute(img)
distance.execute(img)
d = distance.getValue('Distance')
dSum = dSum +d
cx=blob.result['CenterOfGravity_x'] #get result x
y1=blob.result['CenterOfGravity_y'] #get result y
#print 'y1 : ',y1
res.setValue('Value',no) #update blobs found
ref.setValue('Value_y',y+50+y1) #offset to next candle
#offset to next candle
ref.execute(img) #recalculates reference
print i,y,cx,y1
y0 = y1
ref.result=org #restore origin result
meanDistance = GetTool('MeanDistance')
meanDistance.setValue('Value',dSum/no)