Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- try {
- String line = new String();
- String command = "/Library/Frameworks/Python.framework/Versions/3.6/bin/python3 ./tester.py";
- Process p = Runtime.getRuntime().exec(command+ " "+id);
- p.waitFor();
- System.out.println("exit value: "+p.exitValue());
- BufferedReader bri = new BufferedReader(new InputStreamReader(p.getInputStream()));
- if ((line = bri.readLine()) != null) {
- x = Integer.parseInt(line);
- System.out.println("valore int x : " +x);
- }
- bri.close();
- }catch (Exception e){
- e.printStackTrace();
- }
- import cv2
- import os
- import numpy as np
- import faceRecognition as fr
- import sys
- #This module takes images stored in diskand performs face recognition
- test_img=cv2.imread('TestImages/imgtotest'+sys.argv[1]+'.jpg')#test_img path
- faces_detected,gray_img=fr.faceDetection(test_img)
- # print("faces_detected:",faces_detected)
- #Comment belows lines when running this program second time.Since it saves training.yml file in directory
- # faces,faceID=fr.labels_for_training_data('trainingImages')
- # face_recognizer=fr.train_classifier(faces,faceID)
- # face_recognizer.write('trainingData.yml')
- #Uncomment below line for subsequent runs
- face_recognizer=cv2.face.LBPHFaceRecognizer_create()
- face_recognizer.read('trainingData.yml')#use this to load training data for subsequent runs
- name={0:"Priyanka",1:"Kangana",2:"Agos",3:"Valaur"}#creating dictionary containing names for each label
- returnCode = 0
- #forExecuted = -1
- for face in faces_detected:
- #print("sono qui")
- #forExeceuted = 1
- (x,y,w,h)=face
- roi_gray=gray_img[y:y+h,x:x+h]
- label,confidence=face_recognizer.predict(roi_gray)#predicting the label of given image
- # print("confidence:",confidence)
- # print("label:",label)
- fr.draw_rect(test_img,face)
- predicted_name=name[label]
- if(confidence>37):#If confidence more than 37 then don't print predicted face text on screen
- #print("sono qui")
- returnCode = -1
- continue
- returnCode = 1
- fr.put_text(test_img,predicted_name,x,y)
- resized_img=cv2.resize(test_img,(1000,1000))
- print(int(func(returnCode)))
- #cv2.imshow("face dtecetion tutorial",resized_img)
- #cv2.waitKey(0)#Waits indefinitely until a key is pressed
- #cv2.destroyAllWindows
- def func(a):
- return a
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement