Ask Your Question
0

Help! Show coordinates face detection

asked 2015-05-29 11:16:46 -0600

eliaz gravatar image

updated 2015-06-01 11:20:31 -0600

Hi! i need calculate the distance between two o more faces (the faces are inside rectangle, because i am using facedetection code in python), and if two or more faces are together(rectangles together) then print " faces together". if(distance(face1 and face2)<= "n" pixel) {print "faces together"} #n = your calibrate distance. I do not know how translate this order to python language, somebody can help me? Thanks. this is the code:

i am using other code with opencv 2.4.9, this code:

#Ejemplo de deteccion facial con OpenCV y Python
#Por Glare
#www.robologs.net

import numpy as np
import cv2

#cargamos la plantilla e inicializamos la webcam:
face_cascade = cv2.CascadeClassifier('haarcascade_frontalface_alt.xml')
cap = cv2.VideoCapture(0)

while(True):
#leemos un frame y lo guardamos
ret, img = cap.read()

#convertimos la imagen a blanco y negro
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
hsv = cv2.cvtColor(img, cv2.COLOR_BGR2HSV)
#buscamos las coordenadas de los rostros (si los hay) y
#guardamos su posicion
faces = face_cascade.detectMultiScale(gray, 1.3, 5)

#Dibujamos un rectangulo en las coordenadas de cada rostro
for (x,y,w,h) in faces:
    cv2.rectangle(img,(x,y),(x+w,y+h),(125,255,0),2)


#Mostramos la imagen
cv2.imshow('img',img)

#con la tecla 'q' salimos del programa
if cv2.waitKey(1) & 0xFF == ord('q'):
    break
cap.release()
cv2-destroyAllWindows()
edit retag flag offensive close merge delete

Comments

oh, dear, unfortunately your code is horribly outdated. you must not use the arcane cv api(it is already gone in opencv3.0), but cv2.

(grabbing things from a 2010 blog is a terrible idea...)

so, before investing into any new code, rather look at the facedetect demo , tutorials , and refactor (better rewrite) your code.

then, let's start again...

berak gravatar imageberak ( 2015-05-29 11:30:00 -0600 )edit

HI berak, I searched info in many websites and tutorial, the code is correct run, does not it the problem, the problem is find the coordenates of each rectangle, and calculate the distance between each rectangle, after, use conditional ( if distancia(rectangle1 and rectangle2<= "n pixel") print, "face together" n= measure selected for the user, do you can help me with that function? thanks

eliaz gravatar imageeliaz ( 2015-05-29 20:34:17 -0600 )edit

not as long as you insist on doing the wrong thing

berak gravatar imageberak ( 2015-05-30 02:38:55 -0600 )edit

i am using other code, do you can help me?

eliaz gravatar imageeliaz ( 2015-06-01 11:16:31 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
0

answered 2015-06-09 11:31:25 -0600

eliaz gravatar image

i found the answer, thanks!

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2015-05-29 11:16:46 -0600

Seen: 1,495 times

Last updated: Jun 09 '15