-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
77 additions
and
0 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |