scripts/attention_analyzer.py
def overlay(bg,fg):
    """
    Overlay attention over the video frame
    """
    src_rgb = fg[..., :3].astype(numpy.float32) / 255.
    src_alpha = fg[..., 3].astype(numpy.float32) / 255.
    dst_rgb = bg[..., :3].astype(numpy.float32) / 255.
    dst_alpha = bg[..., 3].astype(numpy.float32) / 255.

    out_alpha = src_alpha + dst_alpha * (1. - src_alpha)
    out_rgb = (src_rgb * src_alpha[..., None] + dst_rgb * dst_alpha[..., None] * (1. - src_alpha[..., None])) / out_alpha[..., None]

    out = numpy.zeros_like(bg)
    out[..., :3] = out_rgb * 255
    out[..., 3] = out_alpha * 255

    return out

    Overlay attention over the video frame
    
Overlay attention over the video frame
Overlay attention over the video frame
def overlay(bg,fg):
    src_rgb = fg[..., :3].astype(numpy.float32) / 255.
    src_alpha = fg[..., 3].astype(numpy.float32) / 255.
    dst_rgb = bg[..., :3].astype(numpy.float32) / 255.
    dst_alpha = bg[..., 3].astype(numpy.float32) / 255.
    out_alpha = src_alpha + dst_alpha * (1. - src_alpha)
    out_rgb = (src_rgb * src_alpha[..., None] + dst_rgb * dst_alpha[..., None] * (1. - src_alpha[..., None])) / out_alpha[..., None]
    out = numpy.zeros_like(bg)
    out[..., :3] = out_rgb * 255
    out[..., 3] = out_alpha * 255
    return out
def overlay ( bg , fg ) : src_rgb = fg [ ... , : 3 ] . astype ( numpy . float32 ) / 255. src_alpha = fg [ ... , 3 ] . astype ( numpy . float32 ) / 255. dst_rgb = bg [ ... , : 3 ] . astype ( numpy . float32 ) / 255. dst_alpha = bg [ ... , 3 ] . astype ( numpy . float32 ) / 255. out_alpha = src_alpha + dst_alpha * ( 1. - src_alpha ) out_rgb = ( src_rgb * src_alpha [ ... , None ] + dst_rgb * dst_alpha [ ... , None ] * ( 1. - src_alpha [ ... , None ] ) ) / out_alpha [ ... , None ] out = numpy . zeros_like ( bg ) out [ ... , : 3 ] = out_rgb * 255 out [ ... , 3 ] = out_alpha * 255 return out
Overlay attention over the video frame
Overlay attention over the video frame
"""
    Overlay attention over the video frame
    """
bg
fg