Help! Show coordinates face detection
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()
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...
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
not as long as you insist on doing the wrong thing
i am using other code, do you can help me?