Skip to content

Commit

Permalink
Add test image data and view.py
Browse files Browse the repository at this point in the history
  • Loading branch information
tomba committed Aug 23, 2024
1 parent 0c30fd5 commit c850ea2
Show file tree
Hide file tree
Showing 13 changed files with 77 additions and 0 deletions.
Binary file added tests/data/test-640-480-BG16.bin.gz
Binary file not shown.
Binary file added tests/data/test-640-480-BG24.bin.gz
Binary file not shown.
Binary file added tests/data/test-640-480-BX24.bin.gz
Binary file not shown.
Binary file added tests/data/test-640-480-NV12.bin.gz
Binary file not shown.
Binary file added tests/data/test-640-480-NV21.bin.gz
Binary file not shown.
Binary file added tests/data/test-640-480-RG16.bin.gz
Binary file not shown.
Binary file added tests/data/test-640-480-RG24.bin.gz
Binary file not shown.
Binary file added tests/data/test-640-480-RX24.bin.gz
Binary file not shown.
Binary file added tests/data/test-640-480-UYVY.bin.gz
Binary file not shown.
Binary file added tests/data/test-640-480-XB24.bin.gz
Binary file not shown.
Binary file added tests/data/test-640-480-XR24.bin.gz
Binary file not shown.
Binary file added tests/data/test-640-480-YUYV.bin.gz
Binary file not shown.
77 changes: 77 additions & 0 deletions tests/view.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
#!/usr/bin/python3

import os
import gzip
import sys

import numpy as np
from PyQt6.QtCore import Qt
from PyQt6 import QtWidgets

from pixutils import PixelFormats
from pixutils.conv.qt import data_to_pix
from pixutils.fourcc_str import str_to_fourcc

TEST_PATH = os.path.dirname(os.path.abspath(__file__))

def main():
qApp = QtWidgets.QApplication(sys.argv)

# Some formats are not supported yet

fmts = [
#'BG16',
'BG24',
#'BX24',
'NV12',
#'NV21',
#'RG16',
'RG24',
#'RX24',
'UYVY',
'XB24',
'XR24',
'YUYV',
]

#fmts = [ 'YUYV' ]

w = 640
h = 480

for fourccstr in fmts:
try:
fmt = PixelFormats.find_drm_fourcc(str_to_fourcc(fourccstr))
except StopIteration:
print(f'fourcc {fourccstr} not supported')
continue

print(f'Showing {fmt} ({fourccstr})')

bytesperline = 0 #fmt.stride(w)

fname = f'{TEST_PATH}/data/test-{w}-{h}-{fourccstr}.bin.gz'

with gzip.open(fname, 'rb') as f:
data_in = np.frombuffer(f.read(), dtype=np.uint8)

# Note: the yuv test images are in bt601 limited
options = {
'range': 'limited',
'encoding': 'bt601',
}

pix = data_to_pix(fmt, w, h, bytesperline, data_in, options)

pix = pix.scaled(w * 2, h * 2, Qt.AspectRatioMode.KeepAspectRatio,
Qt.TransformationMode.FastTransformation)

label = QtWidgets.QLabel()
label.setWindowTitle(fourccstr)
label.setPixmap(pix)
label.showMaximized()

qApp.exec()

if __name__ == '__main__':
main()

0 comments on commit c850ea2

Please sign in to comment.