def data_uri_to_cv2_img(uri):
    encoded_data = uri.split(',')[1]
nparr = np.fromstring(encoded_data.decode('base64'), np.uint8)
img = cv2.imdecode(nparr, cv2.IMREAD_COLOR)
Read a base 64 encoded image from memory using OpenCv python library