Read a base64 encoded image from memory using OpenCv python library

前端 未结 3 1333
梦谈多话
梦谈多话 2020-12-05 07:38

I\'m working on an app that to do some facial recognition from a webcam stream. I get base64 encoded data uri\'s of the canvas and want to use it to do something like this:<

3条回答
  •  北海茫月
    2020-12-05 08:36

    This is my solution for python 3.7 and without using PIL

    import base64
    
    def readb64(uri):
       encoded_data = uri.split(',')[1]
       nparr = np.fromstring(base64.b64decode(encoded_data), np.uint8)
       img = cv2.imdecode(nparr, cv2.IMREAD_COLOR)
       return img
    

    i hope that this solutions works for all

提交回复
热议问题