removing dflimg image_to_face_mat

This commit is contained in:
iperov 2019-03-18 14:42:10 +04:00
parent 5d819e3e83
commit 7c1ea1a617
3 changed files with 5 additions and 22 deletions

View file

@ -177,32 +177,21 @@ class ExtractSubprocessor(Subprocessor):
if self.debug_dir is not None: if self.debug_dir is not None:
LandmarksProcessor.draw_rect_landmarks (debug_image, rect, image_landmarks, self.image_size, self.face_type, transparent_mask=True) LandmarksProcessor.draw_rect_landmarks (debug_image, rect, image_landmarks, self.image_size, self.face_type, transparent_mask=True)
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 src_dflimg is not None:
#if extracting from dflimg 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) output_file = str(self.output_path / filename_path.name)
if str(filename_path) != str(output_file): if str(filename_path) != str(output_file):
shutil.copy ( str(filename_path), str(output_file) ) 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: else:
output_file = '{}_{}{}'.format(str(self.output_path / filename_path.stem), str(face_idx), '.jpg') output_file = '{}_{}{}'.format(str(self.output_path / filename_path.stem), str(face_idx), '.jpg')
cv2_imwrite(output_file, face_image, [int(cv2.IMWRITE_JPEG_QUALITY), 85] ) cv2_imwrite(output_file, face_image, [int(cv2.IMWRITE_JPEG_QUALITY), 85] )
DFLJPG.embed_data(output_file, face_type=FaceType.toString(self.face_type), DFLJPG.embed_data(output_file, face_type=FaceType.toString(self.face_type),
landmarks=landmarks, landmarks=face_image_landmarks.tolist(),
source_filename=source_filename, source_filename=filename_path.name,
source_rect=source_rect, source_rect=rect,
source_landmarks=source_landmarks, source_landmarks=image_landmarks.tolist(),
image_to_face_mat=image_to_face_mat image_to_face_mat=image_to_face_mat
) )

View file

@ -225,6 +225,3 @@ class DFLJPG(object):
def get_source_filename(self): return self.dfl_dict['source_filename'] def get_source_filename(self): return self.dfl_dict['source_filename']
def get_source_rect(self): return self.dfl_dict['source_rect'] def get_source_rect(self): return self.dfl_dict['source_rect']
def get_source_landmarks(self): return np.array ( self.dfl_dict['source_landmarks'] ) def get_source_landmarks(self): return np.array ( self.dfl_dict['source_landmarks'] )
def get_image_to_face_mat(self):
mat = self.dfl_dict.get('image_to_face_mat', None)
return np.array(mat) if mat is not None else None

View file

@ -329,9 +329,6 @@ class DFLPNG(object):
def get_source_filename(self): return self.fcwp_dict['source_filename'] def get_source_filename(self): return self.fcwp_dict['source_filename']
def get_source_rect(self): return self.fcwp_dict['source_rect'] def get_source_rect(self): return self.fcwp_dict['source_rect']
def get_source_landmarks(self): return np.array ( self.fcwp_dict['source_landmarks'] ) def get_source_landmarks(self): return np.array ( self.fcwp_dict['source_landmarks'] )
def get_image_to_face_mat(self):
mat = self.fcwp_dict.get('image_to_face_mat', None)
return np.array(mat) if mat is not None else None
def __str__(self): def __str__(self):
return "<PNG length={length} chunks={}>".format(len(self.chunks), **self.__dict__) return "<PNG length={length} chunks={}>".format(len(self.chunks), **self.__dict__)