def recognizeFaces(self):
        try:
            start = time.time()
            argsnum = len(sys.argv)

            # path to our database

            path = "E:\POP project\images\input"

            # all the set of images that have to be recognized (input)
            image_paths = [os.path.join(path, f) for f in os.listdir(path)]
            print "no of images: ",len(image_paths)

            n = 11
            # initialise the dictionary with all marked as absent
            for i in range(1,n):
                self.dict.update({i:"Absent"})

            for imgname in image_paths:
                # imgname="E:\POP project\images\probes\jack1.png"
                dirname = "E:\POP project\images\Basedatabase"
                eigenfaces = 22
                threshold = 0.6

                pyf = pyfaces.PyFaces(imgname, dirname, eigenfaces, threshold)
                match = pyf.getMatchFile()

                if(match is not None):
                    # print 'match = ',match
                    self.matches.update({imgname:match})
                    match = match.split("_")[0]
                    # print 'match = ',match
                    match = match.split("\\")[4]
                    # print 'match = ',match

                    # we maintain a dictionary to map roll no with attendance status
                    self.dict[int(match)] = "Present"
                    # self.count = self.count + 1

                    end = time.time()
                    print 'took :', (end - start), 'secs'

            print "Attendance status=",str(self.dict)
            print "Matches=",(self.matches)
            # print "Number of FACES RECOGNIZED = ", self.count

            n = 1
            for i in self.dict:
                # print self.dict[i]
                label = tk.Label(self.rightFrame, bg="black", text=self.dict[i], fg="white")
                label.grid(row=n, column=1, padx=(0,0), sticky=tk.W)
                n = n + 1


        except Exception, detail:
            print detail.args
            print "usage:python pyfacesdemo imgname dirname numofeigenfaces threshold "
コード例 #2
0
CWP = os.getcwd()  # Get current working directory
CWP_parent = '/'.join(CWP.split('/')[:-1])


def run_bash_cmd(cmd):
    process = subprocess.Popen(cmd.split(), stdout=subprocess.PIPE)
    output = process.communicate()[0]
    return output


print("Taking a photo!")
# CAPTURE_COMMAND = "fswebcam -r 1280x720 image.jpg"
CAPTURE_COMMAND = "fswebcam -r 640x426 image.jpg"
print run_bash_cmd(CAPTURE_COMMAND)

print("Cropping...")
imgname = CWP + "/image.jpg"
crop_img(imgname)
imgname = CWP + "/image_cropped.jpg"

print("Run face recognition!")
# FACE_REC_COMMAND = "python pyfacescmd/pyfacesdemo %s 12 3" % image_path

dirname = CWP_parent + "/images/gallery/"
egfaces = 12
thrshld = 3
pyf = pyfaces.PyFaces(imgname, dirname, egfaces, thrshld)
end = time.time()
print 'took :', (end - start), 'secs'
コード例 #3
0
    try:
        start = time.time()
        argsnum = len(sys.argv)
        print "args:", argsnum
        if (argsnum < 1):
            print "Veuillez revoir la syntaxe d'execution "
            sys.exit(2)
        path_test = "att_faces/test/"
        Dataset_test = []
        for i in os.listdir(path_test):
            Dataset_test.append(os.path.join(path_test, i))
        path_train = 'att_faces/train/'
        egfaces = int(8)
        thrshld = float(10)
        vrai = 0
        for i in range(len(Dataset_test)):
            pyf = pyfaces.PyFaces(Dataset_test[i], path_train, egfaces,
                                  thrshld)
            nom_image_test = Dataset_test[i].split("/")[2]

            nom_image_train = pyf.get_image()
            if nom_image_train.split("-")[0] == nom_image_test.split("-")[0]:
                vrai = vrai + 1
            end = time.time()
        print 'Performance :', vrai / 2, '%'
        print 'temps de calcul est :', (end - start), 'secs'

    except Exception, detail:
        print detail.args
        print " Erreur d'execution "