【问题标题】:Encoding a String data structure from video frame to Unicode in Python在 Python 中将字符串数据结构从视频帧编码为 Unicode
【发布时间】:2018-12-03 18:33:44
【问题描述】:

我正在尝试转换大型字符串数据结构(从 OpenCV 捕获的视频帧)。

下面是我获取相机帧数据(数据字符串)的地方,然后将其编码为 un​​icode utf-8 数据:

frame = camera.get_frame() frame_data = unicode(frame, "utf-8")

我目前遇到的错误

UnicodeDecodeError: 'utf8' code can't decode byte 0xff in position 0: invalid start byte

我是否正确地假设这是可以做到的?如果是这样,我将如何解决这个错误?

【问题讨论】:

    标签: python string opencv unicode utf-8


    【解决方案1】:

    我想通了 - 我最终将 camera.get_frame() 中的代码从

    retval, image = self.image.read()
    data = cv.imencode('.jpg', image)[1]tostring()
    

    retval, image = self.image.read()
    retval, buffer = cv.imencode('.jpg', image)
    jpg_as_text = base64.b64encode('.jpg', image)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-07-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-10-17
      • 1970-01-01
      相关资源
      最近更新 更多