refactoring

This commit is contained in:
iperov 2019-02-10 21:40:58 +04:00
parent 854ab11de3
commit bda3fb3da1
2 changed files with 10 additions and 10 deletions

View file

@ -1,5 +1,4 @@
from .FaceType import FaceType from .FaceType import FaceType
from .DLIBExtractor import DLIBExtractor from .DLIBExtractor import DLIBExtractor
from .MTCExtractor import MTCExtractor from .MTCExtractor import MTCExtractor
from .LandmarksExtractor import LandmarksExtractor from .LandmarksExtractor import LandmarksExtractor
from .LandmarksProcessor import *

View file

@ -10,8 +10,9 @@ from utils import Path_utils
from utils.DFLJPG import DFLJPG from utils.DFLJPG import DFLJPG
from utils.cv2_utils import * from utils.cv2_utils import *
from utils import image_utils from utils import image_utils
import facelib
from facelib import FaceType from facelib import FaceType
import facelib from facelib import LandmarksProcessor
from nnlib import nnlib from nnlib import nnlib
from utils.SubprocessorBase import SubprocessorBase from utils.SubprocessorBase import SubprocessorBase
@ -318,22 +319,22 @@ class ExtractSubprocessor(SubprocessorBase):
image_landmarks = np.array(face[1]) image_landmarks = np.array(face[1])
if self.debug: if self.debug:
facelib.LandmarksProcessor.draw_rect_landmarks (debug_image, rect, image_landmarks, self.image_size, self.face_type) LandmarksProcessor.draw_rect_landmarks (debug_image, rect, image_landmarks, self.image_size, self.face_type)
if self.face_type == FaceType.MARK_ONLY: if self.face_type == FaceType.MARK_ONLY:
face_image = image face_image = image
face_image_landmarks = image_landmarks face_image_landmarks = image_landmarks
else: else:
image_to_face_mat = facelib.LandmarksProcessor.get_transform_mat (image_landmarks, self.image_size, self.face_type) image_to_face_mat = LandmarksProcessor.get_transform_mat (image_landmarks, self.image_size, self.face_type)
face_image = cv2.warpAffine(image, image_to_face_mat, (self.image_size, self.image_size), cv2.INTER_LANCZOS4) face_image = cv2.warpAffine(image, image_to_face_mat, (self.image_size, self.image_size), cv2.INTER_LANCZOS4)
face_image_landmarks = facelib.LandmarksProcessor.transform_points (image_landmarks, image_to_face_mat) face_image_landmarks = LandmarksProcessor.transform_points (image_landmarks, image_to_face_mat)
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 = face_image_landmarks.tolist(), landmarks = face_image_landmarks.tolist(),
yaw_value = facelib.LandmarksProcessor.calc_face_yaw (face_image_landmarks), yaw_value = LandmarksProcessor.calc_face_yaw (face_image_landmarks),
pitch_value = facelib.LandmarksProcessor.calc_face_pitch (face_image_landmarks), pitch_value = LandmarksProcessor.calc_face_pitch (face_image_landmarks),
source_filename = filename_path.name, source_filename = filename_path.name,
source_rect= rect, source_rect= rect,
source_landmarks = image_landmarks.tolist() source_landmarks = image_landmarks.tolist()
@ -360,10 +361,10 @@ class ExtractSubprocessor(SubprocessorBase):
image = cv2.addWeighted (self.original_image,1.0,self.text_lines_img,1.0,0) image = cv2.addWeighted (self.original_image,1.0,self.text_lines_img,1.0,0)
view_rect = (np.array(self.rect) * self.view_scale).astype(np.int).tolist() view_rect = (np.array(self.rect) * self.view_scale).astype(np.int).tolist()
view_landmarks = (np.array(self.landmarks) * self.view_scale).astype(np.int).tolist() view_landmarks = (np.array(self.landmarks) * self.view_scale).astype(np.int).tolist()
facelib.LandmarksProcessor.draw_rect_landmarks (image, view_rect, view_landmarks, self.image_size, self.face_type) LandmarksProcessor.draw_rect_landmarks (image, view_rect, view_landmarks, self.image_size, self.face_type)
if self.param['rect_locked']: if self.param['rect_locked']:
facelib.draw_landmarks(image, view_landmarks, (255,255,0) ) LandmarksProcessor.draw_landmarks(image, view_landmarks, (255,255,0) )
self.param['redraw_needed'] = False self.param['redraw_needed'] = False
cv2.imshow (self.wnd_name, image) cv2.imshow (self.wnd_name, image)