@stebest 挺简单的,给个示例吧 import numpy as np import cv2 as cv import io image_stream = io.BytesIO() image_stream.write(connection.read(image_len)) image_stream.seek(0) file_bytes = np.asarray(bytearray(image_stream.read()), dtype=np.uint8) img = cv.imdecode(file_bytes, cv.IMREAD_COLOR)
Python 这语言本来就不适用于直接对内存进行操作 建议换 C 或 Rust https://ffmpeg.org/doxygen/6.1/group__lavc__decoding.html#ga11e6542c4e66d3028668788a1a74217c 你可能想要这个方法