code release

This commit is contained in:
iperov 2021-07-23 17:34:49 +04:00
commit a902f11f74
354 changed files with 826570 additions and 1 deletions

25
xlib/qt/gui/from_np.py Normal file
View file

@ -0,0 +1,25 @@
import numpy as np
from PyQt6.QtGui import *
from xlib.image import ImageProcessor
def QPixmap_from_np(image : np.ndarray):
ip = ImageProcessor(image).to_uint8()
N,H,W,C = ip.get_dims()
if N > 1:
raise ValueError(f'N dim must be == 1')
if C == 1:
format = QImage.Format.Format_Grayscale8
elif C == 3:
format = QImage.Format.Format_BGR888
elif C == 4:
format = QImage.Format.Format_ARGB32
else:
raise ValueError(f'Unsupported channels {C}')
image = ip.get_image('HWC')
q_image = QImage(image.data, W, H, W*C, format)
q_pixmap = QPixmap.fromImage(q_image)
return q_pixmap