load an icon from the data directory

def mp_icon(filename):
    '''load an icon from the data directory'''
    # we have to jump through a lot of hoops to get an OpenCV image
    # when we may be in a package zip file
    try:
        import pkg_resources
        name = __name__
        if name == "__main__":
            name = "MAVProxy.modules.mavproxy_map.mp_tile"
        stream = pkg_resources.resource_stream(name, "data/%s" % filename).read()
        raw = np.fromstring(stream, dtype=np.uint8)
    except Exception:
        try:
            stream = open(os.path.join(__file__, 'data', filename)).read()
            raw = np.fromstring(stream, dtype=np.uint8)
        except Exception:
            #we're in a Windows exe, where pkg_resources doesn't work
            import pkgutil
            raw = pkgutil.get_data( 'MAVProxy', 'modules//mavproxy_map//data//' + filename)
    img = cv2.imdecode(raw, cv2.IMREAD_COLOR)
    return img