Closedown
This commit is contained in:
@@ -12,24 +12,33 @@ def in_roi(x,y):
|
||||
return math.hypot(x-roi_radius, y-roi_radius) < roi_radius
|
||||
|
||||
|
||||
def integrate (ips):
|
||||
def integrate(ips):
|
||||
aux = None
|
||||
for i in range(len(ips)):
|
||||
if i==0:
|
||||
aux = new_image(roi[2], roi[3], image_type="float", title = "sum", fill_color = None)
|
||||
op_image(aux, ips[i], "add", float_result=True, in_place=True)
|
||||
op_const(aux, "divide", len(ips), in_place=True)
|
||||
op_image(aux, ips[i], "add", float_result=True, in_place=True)
|
||||
return aux
|
||||
|
||||
def average (ips):
|
||||
aux = integrate(ips)
|
||||
op_const(aux, "divide", len(ips), in_place=True)
|
||||
return aux
|
||||
|
||||
|
||||
def get_image(samples = 1):
|
||||
def grab_frames(samples):
|
||||
frames = []
|
||||
for i in range(samples):
|
||||
ip = load_image(img.image)
|
||||
aux = sub_image(ip, roi[0], roi[1], roi[2], roi[3])
|
||||
grayscale(aux)
|
||||
frames.append(aux)
|
||||
return integrate(frames)
|
||||
return frames
|
||||
|
||||
def average_frames(samples = 1):
|
||||
return average(grab_frames(samples))
|
||||
|
||||
def integrate_frames(samples = 1):
|
||||
return integrate(grab_frames(samples))
|
||||
|
||||
|
||||
img.backgroundEnabled=False
|
||||
@@ -38,7 +47,7 @@ led_ctrl2.write(0.0)
|
||||
time.sleep(0.1)
|
||||
img.waitNext(100)
|
||||
|
||||
background = get_image(5)
|
||||
background = average_frames(5)
|
||||
#img.setBackground(background.getBufferedImage())
|
||||
#img.captureBackground(1,0)
|
||||
#show_panel(img.backgroundImage)
|
||||
@@ -49,7 +58,7 @@ led_ctrl1.write(0.40)
|
||||
led_ctrl2.write(0.40)
|
||||
time.sleep(0.1)
|
||||
img.waitNext(100)
|
||||
image = get_image(5)
|
||||
image = average_frames(5)
|
||||
|
||||
op_image(image, background, "subtract", float_result=True, in_place=True)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user