LoginSignup
1
0

More than 1 year has passed since last update.

Python OpenCV で sRGB -> YUV に変換するメモ

Last updated at Posted at 2022-05-24

sRGB -> YUV に Python で OpenCV あたりで変換したい.
画像サイズ大きいので高速処理したい.

ネット上では YUV -> RGB ばかりでつらい :cry:

YUV

いろいろフォーマットあります.

https://hk.interaction-lab.org/firewire/yuv.html
https://www.klab.com/jp/blog/tech/2016/1054828175.html

通常は 420(8bit) あたりでしょうか

OpenCV color conversion

YUV420(IV12)

COLOR_RGB2YUV_I420 でいけます!

NV12

cv2 では直接はサポートしていないです :cry:

とりあえずぺろっと処理する.

画像サイズが 2 の倍数でないとエラーになりますのでご注意ください.

理想は一旦 COLOR_RGB2YUV あたりで変換して, その後 U, V を interleave で入れ替えるでしょうか.

colorspace

T.B.W.

おまけ(ffmpeg)

fmmpeg でも PNG などを YUV に変換できます!

NV12 の場合は

ffmpeg で -pix_fmt nv12

(バグ(?)なのか yuv420p は 420i として処理される)

1
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
1
0