def fourier_draw(self): arr = image_to_array(self.draw_buffer.toImage()) values = arr[arr == self.color.red()] * (self.scale_factor / 255) self.raw_fourier[arr == self.color.red()] = np.abs(2**values) self.emit_fourier()
def add_noise(self): dialog = NoiseDialog() if not dialog.exec_(): return function = dialog.painter_function image = self.image_label.pixmap().toImage() painter = QPainter(image) function(painter, QColor(0, 0, 0)) self.update(image_to_array(image)) del painter
def get_face_landmarks(self, image): """Compute 68 facial landmarks""" landmarks = [] image_array = image_to_array(image) detector = dlib.get_frontal_face_detector() predictor = dlib.shape_predictor(self.predictor_path) face_rectangles = detector(image_array) if len(face_rectangles) < 1: return None dlib_shape = predictor(image_array, face_rectangles[0]) for i in range(0, dlib_shape.num_parts): landmarks.append([dlib_shape.part(i).x, dlib_shape.part(i).y]) return landmarks
def get_keypoints(image: Image) -> Optional[Dict]: # run inference to detect faces (on CPU only) with tf.device("/cpu:0"): detection = detector.detect_faces(image_to_array(image)) # run detection and keep results with certain confidence only results = [ item for item in detection if item['confidence'] > minimal_confidence ] # nothing found if len(results) == 0: return None # return result with highest confidence and size return max(results, key=lambda item: item['confidence'] * item['box'][2] * item[ 'box'][3])
def load_file(self, file_name): array = image_to_array(QImage(file_name), to_gray=True) if array is None: return self.update(array.copy()) self.setWindowTitle(os.path.basename(file_name))
def load_file(self, file_name): array = image_to_array(QImage(file_name), to_gray=True) self.update(array) self.setWindowTitle(os.path.basename(file_name))