extractor: added ability to re-extract dst faces with transferring all necessary meta data

This commit is contained in:
iperov 2019-03-18 00:43:07 +04:00
parent 00e56299c4
commit b03d62a29b

View file

@ -163,17 +163,30 @@ class ExtractSubprocessor(Subprocessor):
output_file = '{}_{}{}'.format(str(self.output_path / filename_path.stem), str(face_idx), '.jpg')
face_idx += 1
landmarks=face_image_landmarks.tolist()
source_filename = filename_path.name
source_landmarks = image_landmarks.tolist()
source_rect = rect
if src_dflimg is not None:
#if extracting from dflimg just copy it in order not to lose quality
#if extracting from dflimg copy it in order not to lose quality
output_file = str(self.output_path / filename_path.name)
shutil.copy ( str(filename_path), str(output_file) )
#and transfer data
source_filename = src_dflimg.get_source_filename()
mat = src_dflimg.get_image_to_face_mat()
if mat is not None:
image_to_face_mat = mat
source_landmarks = LandmarksProcessor.transform_points (landmarks, image_to_face_mat, True)
else:
cv2_imwrite(output_file, face_image, [int(cv2.IMWRITE_JPEG_QUALITY), 85] )
DFLJPG.embed_data(output_file, face_type = FaceType.toString(self.face_type),
landmarks = face_image_landmarks.tolist(),
source_filename = filename_path.name,
source_rect= rect,
source_landmarks = image_landmarks.tolist()
DFLJPG.embed_data(output_file, face_type=FaceType.toString(self.face_type),
landmarks=landmarks,
source_filename=source_filename,
source_rect=source_rect,
source_landmarks=source_landmarks,
image_to_face_mat=image_to_face_mat
)
result.append (output_file)