mirror of
https://github.com/iperov/DeepFaceLive
synced 2025-08-20 05:23:23 -07:00
increase preview rendering performance
This commit is contained in:
parent
035029bdd6
commit
24e1312234
5 changed files with 47 additions and 50 deletions
|
@ -19,7 +19,7 @@ class QBCFaceAlignViewer(lib_qt.QXCollapsibleSection):
|
|||
preview_width=256,):
|
||||
|
||||
self._preview_width = preview_width
|
||||
self._timer = lib_qt.QXTimer(interval=8, timeout=self._on_timer_8ms, start=True)
|
||||
self._timer = lib_qt.QXTimer(interval=16, timeout=self._on_timer_16ms, start=True)
|
||||
self._backed_weak_heap = backed_weak_heap
|
||||
self._bc = bc
|
||||
self._bcd_id = None
|
||||
|
@ -33,7 +33,7 @@ class QBCFaceAlignViewer(lib_qt.QXCollapsibleSection):
|
|||
(info_label, Qt.AlignmentFlag.AlignCenter),
|
||||
]) )
|
||||
|
||||
def _on_timer_8ms(self):
|
||||
def _on_timer_16ms(self):
|
||||
top_qx = self.get_top_QXWindow()
|
||||
if not self.is_opened() or (top_qx is not None and top_qx.is_minimized() ):
|
||||
return
|
||||
|
@ -50,12 +50,12 @@ class QBCFaceAlignViewer(lib_qt.QXCollapsibleSection):
|
|||
for face_mark in bcd.get_face_mark_list():
|
||||
face_align = face_mark.get_face_align()
|
||||
if face_align is not None:
|
||||
face_align_image_name = face_align.get_image_name()
|
||||
face_image = bcd.get_image (face_align.get_image_name())
|
||||
if face_image is not None:
|
||||
source_to_aligned_uni_mat = face_align.get_source_to_aligned_uni_mat()
|
||||
|
||||
source_to_aligned_uni_mat = face_align.get_source_to_aligned_uni_mat()
|
||||
|
||||
if all_is_not_None(face_align_image_name):
|
||||
face_image = bcd.get_image(face_align_image_name).copy()
|
||||
h,w = face_image.shape[:2]
|
||||
self._layered_images.add_image(face_image)
|
||||
|
||||
face_ulmrks = face_align.get_face_ulandmarks_by_type(FaceULandmarks.Type.LANDMARKS_468)
|
||||
if face_ulmrks is None:
|
||||
|
@ -71,11 +71,8 @@ class QBCFaceAlignViewer(lib_qt.QXCollapsibleSection):
|
|||
aligned_uni_rect = face_mark_rect.transform(source_to_aligned_uni_mat)
|
||||
aligned_uni_rect.draw(lmrks_layer, (0,0,255,255) )
|
||||
|
||||
|
||||
self._layered_images.add_image(face_image)
|
||||
self._layered_images.add_image(lmrks_layer)
|
||||
|
||||
h,w = face_image.shape[0:2]
|
||||
|
||||
self._info_label.setText(f'{w}x{h}')
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ class QBCFaceSwapViewer(lib_qt.QXCollapsibleSection):
|
|||
bc : backend.BackendConnection,
|
||||
preview_width=256,):
|
||||
self._preview_width = preview_width
|
||||
self._timer = lib_qt.QXTimer(interval=8, timeout=self._on_timer_8ms, start=True)
|
||||
self._timer = lib_qt.QXTimer(interval=16, timeout=self._on_timer_16ms, start=True)
|
||||
|
||||
self._backed_weak_heap = backed_weak_heap
|
||||
self._bc = bc
|
||||
|
@ -31,7 +31,7 @@ class QBCFaceSwapViewer(lib_qt.QXCollapsibleSection):
|
|||
super().__init__(title=L('@QBCFaceSwapViewer.title'), content_layout=main_l)
|
||||
|
||||
|
||||
def _on_timer_8ms(self):
|
||||
def _on_timer_16ms(self):
|
||||
top_qx = self.get_top_QXWindow()
|
||||
if not self.is_opened() or (top_qx is not None and top_qx.is_minimized() ):
|
||||
return
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
import numpy as np
|
||||
from localization import L
|
||||
from PyQt6.QtCore import *
|
||||
from PyQt6.QtGui import *
|
||||
from PyQt6.QtWidgets import *
|
||||
from resources.fonts import QXFontDB
|
||||
from xlib import image as lib_image
|
||||
from xlib import qt as lib_qt
|
||||
|
||||
from ... import backend
|
||||
|
@ -12,7 +14,7 @@ class QBCFinalFrameViewer(lib_qt.QXCollapsibleSection):
|
|||
def __init__(self, backed_weak_heap : backend.BackendWeakHeap,
|
||||
bc : backend.BackendConnection,
|
||||
preview_width=256):
|
||||
self._timer = lib_qt.QXTimer(interval=8, timeout=self._on_timer_8ms, start=True)
|
||||
self._timer = lib_qt.QXTimer(interval=16, timeout=self._on_timer_16ms, start=True)
|
||||
|
||||
self._backed_weak_heap = backed_weak_heap
|
||||
self._bc = bc
|
||||
|
@ -27,7 +29,7 @@ class QBCFinalFrameViewer(lib_qt.QXCollapsibleSection):
|
|||
], spacing=0)
|
||||
super().__init__(title=L('@QBCFinalFrameViewer.title'), content_layout=main_l)
|
||||
|
||||
def _on_timer_8ms(self):
|
||||
def _on_timer_16ms(self):
|
||||
top_qx = self.get_top_QXWindow()
|
||||
if not self.is_opened() or (top_qx is not None and top_qx.is_minimized() ):
|
||||
return
|
||||
|
@ -42,18 +44,15 @@ class QBCFinalFrameViewer(lib_qt.QXCollapsibleSection):
|
|||
self._layered_images.clear_images()
|
||||
|
||||
merged_frame_name = bcd.get_merged_frame_name()
|
||||
|
||||
merged_frame_image = bcd.get_image(merged_frame_name)
|
||||
|
||||
if merged_frame_name is not None and merged_frame_image is not None:
|
||||
if merged_frame_image is not None:
|
||||
if merged_frame_image.dtype != np.uint8:
|
||||
merged_frame_image = lib_image.ImageProcessor(merged_frame_image).to_uint8().get_image('HWC')
|
||||
|
||||
self._layered_images.add_image(merged_frame_image)
|
||||
|
||||
h,w = merged_frame_image.shape[0:2]
|
||||
|
||||
if merged_frame_name is not None:
|
||||
self._info_label.setText(f'{merged_frame_name} {w}x{h}')
|
||||
else:
|
||||
self._info_label.setText(f'{w}x{h}')
|
||||
self._info_label.setText(f'{merged_frame_name} {w}x{h}')
|
||||
|
||||
|
||||
def clear(self):
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import numpy as np
|
||||
from localization import L
|
||||
from PyQt6.QtCore import *
|
||||
from PyQt6.QtGui import *
|
||||
|
@ -12,7 +13,7 @@ class QBCFrameViewer(lib_qt.QXCollapsibleSection):
|
|||
def __init__(self, backed_weak_heap : backend.BackendWeakHeap,
|
||||
bc : backend.BackendConnection,
|
||||
preview_width=256):
|
||||
self._timer = lib_qt.QXTimer(interval=8, timeout=self._on_timer_8ms, start=True)
|
||||
self._timer = lib_qt.QXTimer(interval=16, timeout=self._on_timer_16ms, start=True)
|
||||
|
||||
self._backed_weak_heap = backed_weak_heap
|
||||
self._bc = bc
|
||||
|
@ -26,7 +27,7 @@ class QBCFrameViewer(lib_qt.QXCollapsibleSection):
|
|||
])
|
||||
super().__init__(title=L('@QBCFrameViewer.title'), content_layout=main_l)
|
||||
|
||||
def _on_timer_8ms(self):
|
||||
def _on_timer_16ms(self):
|
||||
top_qx = self.get_top_QXWindow()
|
||||
if not self.is_opened() or (top_qx is not None and top_qx.is_minimized() ):
|
||||
return
|
||||
|
@ -45,10 +46,8 @@ class QBCFrameViewer(lib_qt.QXCollapsibleSection):
|
|||
frame_image = bcd.get_image(frame_name)
|
||||
|
||||
if frame_image is not None:
|
||||
self._layered_images.add_image(frame_image)
|
||||
|
||||
h,w = frame_image.shape[0:2]
|
||||
|
||||
self._layered_images.add_image (frame_image)
|
||||
h,w = frame_image.shape[:2]
|
||||
if frame_name is not None:
|
||||
self._info_label.setText(f'{frame_name} {w}x{h}')
|
||||
else:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue