0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

【Python】UYVY形式のバイナリファイルをRGB画像に変換

Posted at

プログラム

import numpy as np
import cv2
from pathlib import Path

file_list = []

for file in file_list:
    # (height, width, 2)の形にreshape
    yuv_array = np.fromfile(file, np.uint8).reshape([1200, 1920, 2])
    bgr = cv2.cvtColor(yuv_array, cv2.COLOR_YUV2BGR_UYVY)
    cv2.imwrite(str(Path(file).with_suffix('.jpg')), bgr)

bgr = cv2.cvtColor(yuv_array, cv2.COLOR_YUV2BGR_UYVY)cv2.COLOR_YUV2BGR_UYVY部分をバイナリファイルの形式に合わせれば、他のYUV形式に応用可能。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?