The methods calculates the coverage of the color "glue" within the
points. Below the glue on the pins on the chips are verified. The points are
stored in an ExternalPolygon tools.
#moving a color matcher along the path defined in a polygon
img = GetImageMatr('Top')
points = eval(GetValue('glue_pinspolygons.Polygon[1]'))
name = 'glue_pins_cm'
coverage = ProcessCM(img,name,points)
SetValue('Coverage.glue_pins',coverage)
Example 1: Calculate the coverage
of a color # img - name of image
# name - name of color matcher
# points - path
def ProcessCM(img,name,points):
cm= GetTool(name)
ref = GetTool(name+'_ref')
count = 0
for pt in points:
try:
#print 'ProcessCM - ',pt
SetValue(name+'_ref.Value_x',pt[0])
SetValue(name+'_ref.Value_y',pt[1])
ref.execute(img)
cm.execute(img)
if cm.getValue('Color') == 'glue':
count = count +1
DrawMarker(name+'_ref',0,0,'Red',8,18)
except:
pass
if len(points) > 0:
return count * 100 / len(points)
else :
return 0
|