def findFire(data):
    '''Locates the brightest area in the frame by applying a differential
        gaussian filter and creating a byte array light vs dark. The centroid
        of the light region is found and returned as the location of the fire'''
    data = GaussianBlur(data,(3,3),2)
    mask = zeros(data.shape)
    mask[data > (data.mean() + data.max())/2.] = 1
    mom = moments(mask)
    try:
        x, y = mom['m10']/mom['m00'], mom['m01']/mom['m00']
    except ZeroDivisionError:
        x, y = nan, nan
    return x, y
示例#2
0
def findFire(data):
    '''Locates the brightest area in the frame by applying a differential
        gaussian filter and creating a byte array light vs dark. The centroid
        of the light region is found and returned as the location of the fire'''
    data = GaussianBlur(data,(3,3),2)
    mask = zeros(data.shape)
    mask[data > (data.mean() + data.max())/1.5] = 1
    mom = moments(mask)
    imwrite('mask{0}{1}{2}.bmp'.format(mom['m00'],mom['m02'],mom['m20']),mask)
    if mom['m00']:
        x, y = mom['m10']/mom['m00'], mom['m01']/mom['m00']
    else:
        x, y = nan, nan
    return x, y