Skip to content

Functions for reading and decoding the data of frames in NV21 format.

License

MIT, MIT licenses found

Licenses found

MIT
LICENSE
MIT
LICENSE.txt
Notifications You must be signed in to change notification settings

denisovap2013/nv21

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

nv21

Functions for reading and decoding the data of frames in NV21 format.

Basically it wraps the cv2-based conversion with some check in order to avoid some confusing cv2 errors.

Available functions

  • nv21_to_rgb
  • read_nv21_from_file
  • yuv_to_nv21

Example

import cv2
import matplotlib.pyplot as plt  # do not forget to install `matplotlib` first

import nv21


# Check the "data" folder of this repository.
img = cv2.imread('./data/example.png')[..., ::-1]  # to RGB
h, w = img.shape[:2]

nv21_data = nv21.yuv_to_nv21(
    cv2.cvtColor(img, cv2.COLOR_RGB2YUV)
)

restored_img = nv21.nv21_to_rgb(nv21_data, w, h)

# Draw results
plt.subplot(1, 3, 1)
plt.axis('off')
plt.imshow(img)

plt.subplot(1, 3, 2)
plt.axis('off')
plt.imshow(nv21_data, cmap='gray')

plt.subplot(1, 3, 3)
plt.axis('off')
plt.imshow(restored_img)

plt.show()

About

Functions for reading and decoding the data of frames in NV21 format.

Resources

License

MIT, MIT licenses found

Licenses found

MIT
LICENSE
MIT
LICENSE.txt

Stars

Watchers

Forks

Packages

No packages published

Languages