2017-09-20 8 views
0

enter image description here Je crée une application Android. Eh bien, ceci est un exemple de code pour la détection de visage fourni par google. Au lieu d'utiliser un fichier jpeg, je souhaite utiliser l'aperçu de ma caméra. Comment changer le code? Il serait très reconnaissant si vous m'aidez parce que je me bats avec cela pendant 3 heures.Comment puis-je charger l'aperçu de la caméra à la place d'une image?

ImageView myImageView = (ImageView) findViewById(R.id.imgview); 
BitmapFactory.Options options = new BitmapFactory.Options(); 
options.inMutable=true; 
Bitmap myBitmap = BitmapFactory.decodeResource(
     getApplicationContext().getResources(), 
     R.drawable.test1, 
     options); 
+0

Quelle technologie utilisez-vous? Code?? – sandrooco

Répondre

0
import cv2 
import numpy as np 

a = cv2.CascadeClassifier('haarcascades/haarcascade_frontalface_default.xml'); 
cam = cv2.VideoCapture(0); 

while(True): 
    ret,img=cam.read(); 
    gray = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY) 
    faces = a.detectMultiScale(gray,1.3,5) 
    for(x,y,w,h) in faces : 
     cv2.rectangle(img, (x,y), (x+w,y+h), (0,0,255), 2) 
    cv2.imshow("Face", img); 
    if(cv2.waitKey(1) == ord('q')): 
     break; 
cam.release() 
cv2.destroyAllWindows()