1

我正在尝试从原始视频文件(YUV422 8 位编码)中提取帧,但就我所见,我需要将数据放入 aUMat()但我无法使用缓冲区中的数据创建一个。我首先将数据转换为

fb = np.frombuffer

但我不知道如何继续。如果我只是将新数组与

cv2.cvtColor(um, cv2.COLOR_YUV2BGR_Y422)

我得到None了,但试图用它制作 UMat 我得到一个错误: um = cv2.UMat(height, width, cv2.CV_8UC2, db)

TypeError: UMat() takes at most 2 arguments (4 given)

完整代码:

    width = 1824
    height = 942
    pixels_per_frame = width * height
    with open('my_video.1', 'rb') as video:
        header = video.read(16) #passing the initial header info
        while True:
            frame_byte = video.read(pixels_per_frame * 2)
            # print(frame_byte.hex())
            if frame_byte == b"":
                break
            fb = np.frombuffer(frame_byte, dtype=np.uint8)
            um = cv2.UMat(height, width, cv2.CV_8UC2, fb)

            frame = cv2.cvtColor(um , cv2.COLOR_YUV2BGR_Y422)
            cv2.imshow("Image", frame )
            cv2.waitKey(100) ```

4

0 回答 0