def process_data(self, data): filepath = Path(data[0]) try: dflimg = DFLIMG.load(filepath) if dflimg is None: self.log_err("%s is not a dfl image file" % (filepath.name)) return [1, [str(filepath)]] bgr = cv2_imread(str(filepath)) if bgr is None: raise Exception("Unable to load %s" % (filepath.name)) gray = cv2.cvtColor(bgr, cv2.COLOR_BGR2GRAY) sharpness = estimate_sharpness( gray) if self.include_by_blur else 0 pitch, yaw, roll = LandmarksProcessor.estimate_pitch_yaw_roll( dflimg.get_landmarks()) hist = cv2.calcHist([gray], [0], None, [256], [0, 256]) except Exception as e: self.log_err(e) return [1, [str(filepath)]] return [0, [str(filepath), sharpness, hist, yaw, pitch]]
def process_data(self, data): filepath = Path(data[0]) try: dflimg = DFLIMG.load(filepath) if dflimg is None or not dflimg.has_data(): self.log_err(f"{filepath.name} is not a dfl image file") return [1, [str(filepath)]] bgr = cv2_imread(str(filepath)) if bgr is None: raise Exception("Unable to load %s" % (filepath.name)) gray = cv2.cvtColor(bgr, cv2.COLOR_BGR2GRAY) if self.faster: source_rect = dflimg.get_source_rect() sharpness = mathlib.polygon_area( np.array(source_rect[[0, 2, 2, 0]]).astype(np.float32), np.array(source_rect[[1, 1, 3, 3]]).astype(np.float32)) else: face_mask = LandmarksProcessor.get_image_hull_mask( gray.shape, dflimg.get_landmarks()) sharpness = estimate_sharpness( (gray[..., None] * face_mask).astype(np.uint8)) pitch, yaw, roll = LandmarksProcessor.estimate_pitch_yaw_roll( dflimg.get_landmarks(), size=dflimg.get_shape()[1]) hist = cv2.calcHist([gray], [0], None, [256], [0, 256]) except Exception as e: self.log_err(e) return [1, [str(filepath)]] return [0, [str(filepath), sharpness, hist, yaw, pitch]]
def process_data(self, data): filepath = Path(data[0]) dflimg = DFLIMG.load(filepath) if dflimg is not None: image = cv2_imread(str(filepath)) return [str(filepath), estimate_sharpness(image)] else: self.log_err("%s is not a dfl image file" % (filepath.name)) return [str(filepath), 0]
def process_data(self, data): filepath = Path( data[0] ) dflimg = DFLIMG.load (filepath) if dflimg is None or not dflimg.has_data(): self.log_err (f"{filepath.name} is not a dfl image file") return [ str(filepath), 0 ] else: image = cv2_imread( str(filepath) ) return [ str(filepath), estimate_sharpness(image) ]
def process_data(self, data): filepath = Path( data[0] ) dflimg = DFLIMG.load (filepath) if dflimg is None or not dflimg.has_data(): self.log_err (f"{filepath.name} is not a dfl image file") return [ str(filepath), 0 ] else: image = cv2_imread( str(filepath) ) face_mask = LandmarksProcessor.get_image_hull_mask (image.shape, dflimg.get_landmarks()) image = (image*face_mask).astype(np.uint8) return [ str(filepath), estimate_sharpness(image) ]
def process_data(self, data): filepath = Path(data[0]) dflimg = DFLIMG.load(filepath) if dflimg is None or not dflimg.has_data(): self.log_err(f"{filepath.name} is not a dfl image file") return [str(filepath), 0] else: image = cv2_imread(str(filepath)) face_mask = LandmarksProcessor.get_image_hull_mask( image.shape, dflimg.get_landmarks()) image = (image * face_mask).astype(np.uint8) if self.estimate_motion_blur: value = cv2.Laplacian(image, cv2.CV_64F, ksize=11).var() else: value = estimate_sharpness(image) return [str(filepath), value]