-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f696984
commit 20434cc
Showing
34 changed files
with
737 additions
and
0 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
function [xCLE,yCLE,xCRE,yCRE]= EyesSimple(rostro) | ||
|
||
RightEye = vision.CascadeObjectDetector('RightEyeCART','MergeThreshold',4); | ||
BB=step(RightEye,rostro); | ||
|
||
%OJO IZQUIERDO | ||
xLE=BB(1,1); | ||
yLE=BB(1,2); | ||
aLE=BB(1,3); | ||
lLE=BB(1,4); | ||
%Coordenadas del punto medio del ojo izquierdo | ||
xCLE=xLE+(aLE/2); | ||
yCLE=yLE+(lLE/2); | ||
|
||
%OJO DERECHO | ||
xRE=BB(2,1); | ||
yRE=BB(2,2); | ||
aRE=BB(2,3); | ||
lRE=BB(2,4); | ||
%Coordenadas del punto medio del ojo derecho | ||
xCRE=xRE+(aRE/2); | ||
yCRE=yRE+(lRE/2); | ||
|
||
imshow(rostro); | ||
|
||
rectangle('Position',[xLE,yLE,aLE,lLE],'LineWidth',1,'LineStyle','-','EdgeColor','b'); | ||
rectangle('Position',[xRE,yRE,aRE,lRE],'LineWidth',1,'LineStyle','-','EdgeColor','b'); | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
%OJO que cuando no tienen relaciones en comun, toma como distancia 0. | ||
|
||
function distancia = calcularSimilitud(metricasObjConsulta, metricasObjX) | ||
%la distancia que usamos es la distancia eucleadiana | ||
i=1; | ||
sumDeCuadrados=0; | ||
contador=0; | ||
largoVector = length(metricasObjConsulta); | ||
%al ser dos vectores de igual tamaño, recorremos mientras uno se | ||
%termina | ||
while i<=length(metricasObjConsulta) | ||
%Chequea si las metricas de la consulta son certeras | ||
%Si son erroneas, tienen un valor de -1) | ||
if ((metricasObjConsulta(i) == -1) || (metricasObjX(i) == -1)) | ||
contador = contador + 1; | ||
end | ||
if ((metricasObjConsulta(i) >= 0) && (metricasObjX(i) >= 0)) | ||
%acumulamos el cuadrado de la diferencia entre caracteristicas | ||
sumDeCuadrados=sumDeCuadrados + ((metricasObjConsulta(i) - metricasObjX(i))^2); | ||
i=i+1; | ||
else | ||
i=i+1; | ||
end | ||
end | ||
|
||
if contador < (largoVector/2) | ||
distancia = sumDeCuadrados; | ||
|
||
else | ||
distancia = 10000; | ||
end | ||
%distancia = sqrt (sumDeCuadrados); | ||
%esta distancia indica la simitud entre el Obj1 y Obj2 segun sus | ||
%metricas | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
%Toma una ruta como entrada,carga todas las imagenes de la ruta, calcula | ||
%las relaciones de cada una, y las carga en la base de datos | ||
|
||
function cargarImagenes(ruta,cantImagenes) | ||
%Concexion con Base de datos en postgres | ||
dbhost = 'localhost:5432'; | ||
dbname = 'bbddRostros'; | ||
dbuser = 'postgres'; | ||
dbpass = 'joaco'; | ||
dbdriver = 'C:\Users\Joaco\Downloads\jdk\PostgreSQLDriver\postgresql-9.2-1002.jdbc4'; | ||
dburl = sprintf('jdbc:postgresql://%s/%s',dbhost,dbname); | ||
conn = database(dbname,dbuser,dbpass,dbdriver,dburl) ; | ||
|
||
for i=1:cantImagenes | ||
direccion =strcat(ruta,int2str(i),'.png'); | ||
rostro = imread(direccion); | ||
relRostro=relaciones(rostro); | ||
|
||
for j=1:10 | ||
if j==1 | ||
cadena =num2str(relRostro(j)); | ||
else | ||
cadena = strcat(cadena,',',num2str(relRostro(j))); | ||
end | ||
end | ||
cadI=int2str(i); | ||
sql= strcat('INSERT INTO "relaciones" (id,relacion[1],relacion[2],relacion[3],relacion[4],relacion[5],relacion[6],relacion[7],relacion[8],relacion[9],relacion[10]) VALUES (',cadI,',',cadena,')'); | ||
exec( conn, sql); | ||
|
||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
%LR=largoRostro | ||
%AR=altoRostro | ||
%XB=ValorEnXDeLaBoca | ||
%YB=ValorENYDeLaBoca | ||
|
||
function resultado = chequearBoca(LR,AR,XB,YB) | ||
resultado=0; | ||
%El primer pixel comienza en la izquiera y va hacia la derecha | ||
%La boca en un rostro se ubica en la segunda columna, tomando | ||
% 3 columnas totales (columna media) | ||
AnchoCadaColumna=LR/3; | ||
XInicialColumnaBoca=AnchoCadaColumna; | ||
XFinalColumnaBoca=2*AnchoCadaColumna; | ||
%El primer pixel comienza desde arriba y va hacia abajo | ||
%La boca se ubica en la ultima fila (fila 3) dividiendo el | ||
%rostro en 3 filas de arriba hacia abajo | ||
AlturaCadaFila=AR/3; | ||
YInicialFilaBoca=2*AlturaCadaFila; | ||
YFinalFilaBoca=3*AlturaCadaFila; | ||
%Chequeo de cuadrantes | ||
if (XInicialColumnaBoca < XB) && (XFinalColumnaBoca > XB) | ||
if ( YInicialFilaBoca < YB) && (YFinalFilaBoca > YB) | ||
resultado= 1; | ||
end; | ||
end; | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
%LR=largoRostro | ||
%AR=altoRostro | ||
%XN=ValorEnXDeNariz | ||
%YN=ValorENYDeNariz | ||
|
||
function resultado=chequearNariz(LR,AR,XN,YN) | ||
resultado = 0; | ||
%El primer pixel comienza en la izquiera y va hacia la derecha | ||
%La nariz en un rostro se ubica en la tercer columna, tomando | ||
% 5columnas totales (columna media) | ||
AnchoCadaColumna=LR/5; | ||
XInicialColumnaNariz=2*AnchoCadaColumna; | ||
XFinalColumnaNariz=3*AnchoCadaColumna; | ||
%El primer pixel comienza desde arriba y va hacia abajo | ||
%La nariz se ubica en la tercer fila dividiendo el rostro en 4 filas | ||
AlturaCadaFila=AR/4; | ||
YInicialFilaNariz=2*AlturaCadaFila; | ||
YFinalFilaNariz=3*AlturaCadaFila; | ||
%Chequeo de cuadrantes para nariz | ||
if (XInicialColumnaNariz<XN) && (XFinalColumnaNariz>XN) | ||
if (YInicialFilaNariz<YN) && (YFinalFilaNariz>YN) | ||
resultado= 1; | ||
end; | ||
end; | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
function resultado = consulta(rutaConsulta,cantParecidos) | ||
relacionesAuxiliar = []; | ||
imagenConsulta = imread(rutaConsulta); | ||
relConsulta = relaciones(imagenConsulta); | ||
%conexion con base de datos | ||
dbhost = 'localhost:5432'; | ||
dbname = 'bbddRostros'; | ||
dbuser = 'postgres'; | ||
dbpass = 'joaco'; | ||
dbdriver = 'C:\Users\Joaco\Downloads\jdk\PostgreSQLDriver\postgresql-9.2-1002.jdbc4'; | ||
dburl = sprintf('jdbc:postgresql://%s/%s',dbhost,dbname); | ||
conn = database(dbname,dbuser,dbpass,dbdriver,dburl) ; | ||
e = exec( conn, 'SELECT relacion[1],relacion[2],relacion[3],relacion[4],relacion[5],relacion[6],relacion[7],relacion[8],relacion[9],relacion[10] FROM relaciones' ); | ||
e = fetch(e); | ||
|
||
cantidadRostrosEnBBDD = size(e.Data,1); | ||
for j=1:cantidadRostrosEnBBDD | ||
for i=1:10 | ||
relacionesAuxiliar(i) = cell2mat( e.Data(j,i)); | ||
|
||
end; | ||
|
||
distancia = calcularSimilitud(relacionesAuxiliar, relConsulta); | ||
relacionesAuxiliar=[]; | ||
lista(j) = distancia; | ||
|
||
end; | ||
|
||
[minimos]=encontrar(lista,cantParecidos); | ||
resultado=[lista,minimos]; | ||
|
||
%[minimo,indice] = min(lista); | ||
%resultado=[lista,minimo,indice]; | ||
%figure,imshow(rutaConsulta); | ||
%direccionRostro = strcat('./Sistema V2/SistemaV2_BBDD/BBDD_Destino/',int2str(indice),'.png'); | ||
%figure,imshow(direccionRostro); | ||
|
||
end | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
function distance = dist(x1,y1,x2,y2) | ||
distance=sqrt( ((x2-x1)^2 ) + ((y2-y1)^2)); | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
%Esta funcion toma como entrada la lista de diferencias entre la base de | ||
%datos y la consulta (lista) y la cantidad de imagenes mas parecidas que | ||
%quiere devolver | ||
|
||
function resultado= encontrar(lista,cantMinim) | ||
listaMinimos=minim(lista,cantMinim); | ||
posiciones=[]; | ||
i=1; | ||
j=1; | ||
while length(posiciones) < length(listaMinimos) | ||
res = find(lista == listaMinimos(j)); | ||
for t=1:length(res) | ||
if length(posiciones) < length(listaMinimos) | ||
posiciones(i)=res(t); | ||
i=i+1; | ||
|
||
end | ||
j=j+1; | ||
|
||
|
||
end | ||
resultado=[listaMinimos,posiciones]; | ||
end | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
|
||
%Toma como entrada el rostro(previamente recortado) y las coordenadas del punto medio de la nariz, en base a esto | ||
%compara todos los ojos encontrados tanto derechos como izquierdos y se | ||
%queda con el que tenga mas "sentido", midiendo la distancia entre cada uno | ||
%de estos al punto medio de la nariz. | ||
%Agrega el chequeo de ojos, cuando se evalua la condicion de distancias | ||
%entre ojos y nariz | ||
function [xCREfinal,yCREfinal,xCLEfinal,yCLEfinal] = eyesV2(rostro,xCN,yCN) | ||
ancho=size(rostro,1); | ||
alto=size(rostro,2); | ||
%Para chequear despues si encontro buenos ojos | ||
xCREfinal=0; | ||
yCREfinal=0; | ||
xCLEfinal=0; | ||
yCLEfinal=0; | ||
i=1; | ||
j=1; | ||
correcto=0; | ||
correcto2=0; | ||
|
||
|
||
|
||
while (correcto==0) && (j < 16) | ||
LeftEye = vision.CascadeObjectDetector('LeftEyeCART','MergeThreshold',j); | ||
LE=step(LeftEye,rostro); | ||
|
||
j=j+1; | ||
limit=size(LE,1); | ||
|
||
|
||
|
||
while (limit) > 0 && (correcto==0) | ||
xLE=LE(limit,1); | ||
yLE=LE(limit,2); | ||
aLE=LE(limit,3); | ||
lLE=LE(limit,4); | ||
limit=limit-1; | ||
|
||
|
||
%Coordenadas del punto medio del ojo izquierdo | ||
xCLE=xLE+(aLE/2); | ||
yCLE=yLE+(lLE/2); | ||
|
||
while (correcto2==0) && (i < 16) | ||
|
||
RightEye = vision.CascadeObjectDetector('RightEyeCART','MergeThreshold',i); | ||
RE=step(RightEye,rostro); | ||
i=i+1; | ||
limit2=size(RE,1); | ||
while (limit2) > 0 && (correcto2==0) | ||
xRE=RE(limit2,1); | ||
yRE=RE(limit2,2); | ||
aRE=RE(limit2,3); | ||
lRE=RE(limit2,4); | ||
limit2=limit2-1; | ||
|
||
|
||
|
||
%Coordenadas del ojo derecho | ||
xCRE=xRE+(aRE/2); | ||
yCRE=yRE+(lRE/2); | ||
if (dist(xCRE,yCRE,xCN,yCN) - dist(xCLE,yCLE,xCN,yCN) < 3) %&& (xCRE > (ancho/2)) && (xCLE < (ancho/2)) | ||
xCREfinal=xCRE; | ||
yCREfinal=yCRE; | ||
xCLEfinal=xCLE; | ||
yCLEfinal=yCLE; | ||
correcto=1; | ||
correcto2=1; | ||
|
||
|
||
end | ||
end | ||
end | ||
|
||
|
||
|
||
end | ||
end | ||
end | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
%ANDA PERFECTO PARA LAS IMAGENES ESTANDARIZADAS | ||
%Entra como parametro el rostro (previamente recortado) y devuelve las | ||
%coordendas del punto medio del ojo derecho.Itera para encontrar el | ||
%ojo derecho con mejor precision. | ||
|
||
function [xCLEFinal,yCLEFinal] = leftEyeV3(rostro) | ||
%ancho y alto del rostro para hacer el recorte del ojo izquierdo | ||
ancho=size(rostro,1); | ||
alto=size(rostro,2); | ||
%parametros para el imcrop | ||
%REC=[0,0,ancho/2,alto/2]; | ||
%rostro2=imcrop(rostro,REC); | ||
|
||
xCLEFinal=0; | ||
yCLEFinal=0; | ||
|
||
correcto=0; | ||
i=1; | ||
while correcto==0 && i<16 | ||
RightEye = vision.CascadeObjectDetector('LeftEye','MergeThreshold',i); | ||
BB=step(RightEye,rostro); | ||
lim=size(BB,1); | ||
i = i+1; | ||
while lim > 0 && correcto==0 | ||
xLE=BB(lim,1); | ||
yLE=BB(lim,2); | ||
aLE=BB(lim,3); | ||
lLE=BB(lim,4); | ||
lim=lim-1; | ||
%Coordenadas del punto medio del ojo derecho | ||
xCLE=xLE+(aLE/2); | ||
yCLE=yLE+(lLE/2); | ||
if (xCLE < ancho/2) && (yCLE < alto/2) | ||
xCLEFinal = xCLE; | ||
yCLEFinal = yCLE; | ||
correcto=1; | ||
end | ||
end | ||
end | ||
end | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
%Esta funcion toma como entrada un vector de valores y la cantdad de | ||
%valores mas chios que se quieren obtener, y se obtienen los n valores mas | ||
%pequeños | ||
|
||
function minimos = minim(vector,cantMinimos) | ||
|
||
for j=1:cantMinimos | ||
|
||
|
||
minimos(j)=vector(1); | ||
|
||
for i=1: length(vector) | ||
|
||
if minimos(j)> vector(i) | ||
minimos(j)=vector(i); | ||
end | ||
end | ||
pos=find(vector== minimos(j)); | ||
vector(pos(1))=[]; | ||
%for k=1:length(pos) | ||
%vector(pos(k))=[]; | ||
%end | ||
end | ||
%PARA QUE DEVUELVE CON TODAS LAS ITERACIONES BORRAR EL ULTIMO FOR Y | ||
%DEJAR vector(pos(1))=[]; | ||
|
||
|
||
end | ||
|
||
|
||
|
||
|
||
|
Oops, something went wrong.