def cut_face(): num_usuario = 1 [total_usuarios, usuarios] = cadastro.getusers() while num_usuario <= total_usuarios: name = usuarios[num_usuario - 1] path_users = diretorio + '/BancoDeDados/Originais/' + str(name) total_img = os.listdir(path_users) total_img = len(total_img) index_inicio = str(name).find('_') + 1 index_fim = len(str(name)) nome_img = str(name)[index_inicio:index_fim] num_img = 1 while num_img <= total_img: path_image = diretorio + '/BancoDeDados/Originais/' + str( name) + '/' + nome_img + str(num_img) + '.jpg' image = cv2.imread(path_image) faces = viola_jones(image) if len(faces) > 1: print('Existe mais de uma face na camera.') if len(faces) == 0: print(('\n\nFace nao encontrada na imagem:\n {}'.format( path_image))) if len(faces) == 1: #desenhando retangulo ao redor de cada face: for (x, y, w, h) in faces: cv2.rectangle(image, (x, y), (x + w, y + h), (255, 255, 0), 2) so_face = image[ y:y + w, x:x + h] #recortando imagem atraves do retangulo so_face = cv2.cvtColor(so_face, cv2.COLOR_BGR2GRAY) path_so_face = diretorio + '/BancoDeDados/PreProcess/' + str( name) + '/' + nome_img + str(num_img) + 'p.pgm' cv2.imwrite(path_so_face, so_face) #salvando a imagem num_img = num_img + 1 num_usuario = num_usuario + 1
import io import numpy as np from numpy import linalg as la import cv2 import cv2.cv import os import cadastro_usuarios as cadastro import preprocess as pp import filter_proj as flt import math import time num_usuario = 1 [total_usuarios, usuarios] = cadastro.getusers() while num_usuario <= total_usuarios: name = usuarios[num_usuario-1] print '\n\nxxxxxxxxxxxxxxxxxxxxxxxxxxx' print name path_users = '/home/caroline/Documentos/Smart_room/BancoDeDados/PreProcess/' + str(name) total_img = os.listdir(path_users) total_img = len(total_img) #total_img = 40 index_inicio = str(name).find('_') +1 index_fim = len(str(name)) nome_img = str(name)[index_inicio: index_fim] num_img = 1 indice = np.array(range(1,total_img+1,1))