mirror of
https://github.com/iperov/DeepFaceLive
synced 2025-08-20 05:23:23 -07:00
code release
This commit is contained in:
parent
b941ba41a3
commit
a902f11f74
354 changed files with 826570 additions and 1 deletions
25
xlib/qt/gui/from_np.py
Normal file
25
xlib/qt/gui/from_np.py
Normal 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
|
Loading…
Add table
Add a link
Reference in a new issue