def flandmark_init(model=MODEL): flandmark = PyFlandmark(model, False) # Initialize featurePool bw = flandmark.getBaseWindowSize() featurePool = PyFeaturePool(bw[0], bw[1], None) featurePool.addFeatuaddSparseLBPfeatures() flandmark.setFeaturePool(featurePool) return flandmark
returns 2x2 matrix coordinates of left upper and right lower corners of rectangle that contains face stored in columns of matrix """ f = open(file_name) str = f.read().replace(',', ' ') f.close() ret = np.array(list(map(int,str.split())) ,dtype=np.int32) ret = ret.reshape((2,2), order='F') return ret DIR = '../../../data/Images/' JPGS = [f for f in os.listdir(DIR) if fnmatch(f, '*.jpg')] flmrk = PyFlandmark("../../../data/flandmark_model.xml", False) for jpg_name in JPGS: file_name = jpg_name[:-4] img = Image.open(DIR + jpg_name) arr = rgb2gray(np.asarray(img)) bbox = read_bbox_from_txt(DIR + jpg_name[:-4] + '.det') d_landmarks = flmrk.detect(arr, bbox) n = d_landmarks.shape[1] print("test detect method") im = Image.fromarray(arr)
returns 2x2 matrix coordinates of left upper and right lower corners of rectangle that contains face stored in columns of matrix """ f = open(file_name) str = f.read().replace(',', ' ') f.close() ret = np.array(map(int, str.split()), dtype=np.int32) ret = ret.reshape((2, 2), order='F') return ret DIR = '../../../data/Images/' JPGS = [f for f in os.listdir(DIR) if fnmatch(f, '*.jpg')] flmrk = PyFlandmark("../../../data/flandmark_model.xml", False) for jpg_name in JPGS: file_name = jpg_name[:-4] img = Image.open(DIR + jpg_name) arr = rgb2gray(np.asarray(img)) bbox = read_bbox_from_txt(DIR + jpg_name[:-4] + '.det') d_landmarks = flmrk.detect(arr, bbox) n = d_landmarks.shape[1] print "test detect method" im = Image.fromarray(arr) img_dr = ImageDraw.Draw(im)
returns 2x2 matrix coordinates of left upper and right lower corners of rectangle that contains face stored in columns of matrix """ f = open(file_name) str = f.read().replace(",", " ") f.close() ret = np.array(map(int, str.split()), dtype=np.int32) ret = ret.reshape((2, 2), order="F") return ret DIR = "../../../data/Images/" JPGS = [f for f in os.listdir(DIR) if fnmatch(f, "*.jpg")] flmrk = PyFlandmark("../../../data/flandmark_model.xml", False) for jpg_name in JPGS: file_name = jpg_name[:-4] img = Image.open(DIR + jpg_name) arr = rgb2gray(np.asarray(img)) bbox = read_bbox_from_txt(DIR + jpg_name[:-4] + ".det") d_landmarks = flmrk.detect(arr, bbox) n = d_landmarks.shape[1] print "test detect method" im = Image.fromarray(arr)
# -*- coding: utf-8 -*- """ Created on Sun Feb 05 16:26:55 2017 @author: uricar.michal """ import sys sys.path.append("D:/GitHub/clandmark/install/share/clandmark/python/") from py_flandmark import PyFlandmark from py_featurePool import PyFeaturePool #flandmark = PyFlandmark("D:/GitHub/clandmark/matlab_interface/models/FDPM.xml", False) flandmark = PyFlandmark("D:/GitHub/clandmark/matlab_interface/models/CDPM.xml", False) bw = flandmark.getBaseWindowSize() featurePool = PyFeaturePool(bw[0], bw[1], None) featurePool.addFeatuaddSparseLBPfeatures() flandmark.setFeaturePool(featurePool) import time import numpy as np import cv2 def rgb2gray(rgb): """ converts rgb array to grey scale variant accordingly to fomula taken from wiki (this function is missing in python)
flandmark = PyFlandmark(model, False) # Initialize featurePool bw = flandmark.getBaseWindowSize() featurePool = PyFeaturePool(bw[0], bw[1], None) featurePool.addFeatuaddSparseLBPfeatures() flandmark.setFeaturePool(featurePool) return flandmark if __name__ == '__main__': # flandmark = flandmark_init() flandmark = PyFlandmark(MODEL, False) # Initialize featurePool bw = flandmark.getBaseWindowSize() featurePool = PyFeaturePool(bw[0], bw[1], None) featurePool.addFeatuaddSparseLBPfeatures() flandmark.setFeaturePool(featurePool) faceCascade = cv2.CascadeClassifier(CV_CASCADE_PATH) video_capture = cv2.VideoCapture(CAM_ID) while True: # Capture frame-by-frame ret, frame = video_capture.read() gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
# -*- coding: utf-8 -*- """ Created on Sun Feb 05 16:26:55 2017 @author: uricar.michal """ import sys sys.path.append("D:/GitHub/clandmark/install/share/clandmark/python/") from py_flandmark import PyFlandmark from py_featurePool import PyFeaturePool #flandmark = PyFlandmark("D:/GitHub/clandmark/matlab_interface/models/FDPM.xml", False) flandmark = PyFlandmark("D:/GitHub/clandmark/matlab_interface/models/CDPM.xml", False) bw = flandmark.getBaseWindowSize() featurePool = PyFeaturePool(bw[0], bw[1], None) featurePool.addFeatuaddSparseLBPfeatures() flandmark.setFeaturePool(featurePool) import time import numpy as np import cv2 def rgb2gray(rgb): """ converts rgb array to grey scale variant
from py_flandmark import PyFlandmark from py_featurePool import PyFeaturePool # flandmark = PyFlandmark("../../../data/flandmark_model.xml", False) # flandmark = PyFlandmark("../../../data/FRONTAL_21L.xml", False) flandmark = PyFlandmark("../../../data/300W/FDPM.xml", False) bw = flandmark.getBaseWindowSize() featurePool = PyFeaturePool(bw[0], bw[1], None) featurePool.addFeatuaddSparseLBPfeatures() flandmark.setFeaturePool(featurePool) import time import numpy as np import os from fnmatch import fnmatch from PIL import Image import matplotlib.pyplot as plt #%matplotlib inline def rgb2gray(rgb): """ converts rgb array to grey scale variant accordingly to fomula taken from wiki (this function is missing in python) """ return np.dot(rgb[..., :3], [0.299, 0.587, 0.144])