StreamOutput: additional output modes

This commit is contained in:
iperov 2021-08-06 20:42:11 +04:00
parent 9342ada240
commit 639ceb3597
2 changed files with 28 additions and 6 deletions

View file

@ -35,11 +35,14 @@ class StreamOutput(BackendHost):
def get_control_sheet(self) -> 'Sheet.Host': return super().get_control_sheet()
class SourceType(IntEnum):
ALIGNED_FACE = 0
SWAPPED_FACE = 1
MERGED_FRAME = 2
SOURCE_FRAME = 0
ALIGNED_FACE = 1
SWAPPED_FACE = 2
MERGED_FRAME = 3
SOURCE_N_MERGED_FRAME = 4
ViewModeNames = ['@StreamOutput.SourceType.ALIGNED_FACE', '@StreamOutput.SourceType.SWAPPED_FACE', '@StreamOutput.SourceType.MERGED_FRAME']
ViewModeNames = ['@StreamOutput.SourceType.SOURCE_FRAME', '@StreamOutput.SourceType.ALIGNED_FACE', '@StreamOutput.SourceType.SWAPPED_FACE',
'@StreamOutput.SourceType.MERGED_FRAME', '@StreamOutput.SourceType.SOURCE_N_MERGED_FRAME']
class StreamOutputWorker(BackendWorker):
@ -198,7 +201,9 @@ class StreamOutputWorker(BackendWorker):
view_image = None
if source_type == SourceType.MERGED_FRAME:
if source_type == SourceType.SOURCE_FRAME:
view_image = bcd.get_image(bcd.get_frame_name())
elif source_type == SourceType.MERGED_FRAME:
view_image = bcd.get_image(bcd.get_merged_frame_name())
elif source_type == SourceType.ALIGNED_FACE:
@ -219,6 +224,13 @@ class StreamOutputWorker(BackendWorker):
view_image = bcd.get_image(face_swap.get_image_name())
break
elif source_type == SourceType.SOURCE_N_MERGED_FRAME:
source_frame = ImageProcessor(bcd.get_image(bcd.get_frame_name())).to_ufloat32().get_image('HWC')
merged_frame = bcd.get_image(bcd.get_merged_frame_name())
view_image = np.concatenate( (source_frame, merged_frame), 1 )
if view_image is not None:
buffered_frames.add_buffer( bcd.get_frame_timestamp(), view_image )

View file

@ -682,6 +682,11 @@ class Localization:
'ru-RU' : 'Исходный*Знаменитость',
'zh-CN' : '源脸*目标脸'},
'StreamOutput.SourceType.SOURCE_FRAME':{
'en-US' : 'Source frame',
'ru-RU' : 'Исходный кадр',
'zh-CN' : 'Source frame(没有翻译)'},
'StreamOutput.SourceType.ALIGNED_FACE':{
'en-US' : 'Aligned face',
'ru-RU' : 'Выровненное лицо',
@ -697,4 +702,9 @@ class Localization:
'ru-RU' : 'Склеенный кадр',
'zh-CN' : '合成后的画面'},
'StreamOutput.SourceType.SOURCE_N_MERGED_FRAME':{
'en-US' : 'Source and merged frame',
'ru-RU' : 'Исходный и склеенный кадр',
'zh-CN' : 'Source and merged frame(没有翻译)'},
}