Esempio n. 1
0
def choiceResult(dbName,imageName,temp=""):
    print "Choice --- Executing."
    if(not(temp == "")):
        testImage = dbName+"/"+imageName+"/"+temp
    else:
        testImage = dbName+"/"+imageName
    print testImage
    if platform.system()=="Windows":
        look="\\"
    else:
        look="/"
    choiceImage = ""
    #do a prediction based on algorithm
    if(algoName == "eigenface"):
        result = utility.predict(testing[testing_answer.index(testImage)], training_answer, W, mu, projections)
        choiceImage = "eigenface_yale_choice"
    elif(algoName == "fisherface"):
        result = utility.predict(testing[testing_answer.index(testImage)], training_answer, W, mu, projections)
        choiceImage = "fisherface_yale_choice"
    elif(algoName == "sift"):
        result = sift.localPredict(descriptors_testing[testing_answer.index(testImage)], training_answer, descriptors_training)
        choiceImage = "sift_yale_choice"
    elif(algoName == "lem"):
        result = lem.predict_hausdroff(testing_corners[testing_answer.index(testImage)], training_corners, training_answer)
        choiceImage = "lem_yale_choice"

    #test the image for success based on databases
    if(database == "yale A"):
        heading=result[result.find(look)+len(look):result.find('.')]+" MATCHED WITH "+ testImage[testImage.find(look)+len(look):testImage.find('.')]
        if(result[:result.find('.')] == testImage[:testImage.find('.')]):
            print "HIT!"
            status="hit"
        else:
            status="miss"
        
    elif(database == "orl"):
        heading=result[result.find(look)+len(look):result.find(look,11)]+" MATCHED WITH "+ testImage[testImage.find(look)+len(look):testImage.find(look,11)]
        if(result[:result.find(look,12)] == testImage[:testImage.find(look,12)]):
            print "HIT"
            status="hit"
        else:
            status="miss"
    elif(database == "yale B"):
        pass

    #plot the visuals
    utility.choicePlot(testImage, result, choiceImage)
    os.system("convert "+choiceImage+" "+choiceImage+".png")
    os.system("rm static/images/"+choiceImage+".png")
    os.system("mv "+choiceImage+".png static/images/"+choiceImage+".png")
    return render_template("choiceResult.html", filename = "/static/images/"+choiceImage+".png", status=status, heading=heading)
Esempio n. 2
0
 def eigenTest(self):
     result = utility.predict(self.testing[self.testing_answer.index(self.testImage)], self.training_answer, self.W, self.mu, self.projections)
     print result, self.testImage
     if(result[6:9] == self.testImage[6:9]):
         print "HIT!"
     if(self.db == "yale"):
         utility.choicePlot("yalefaces/"+self.testImage, "yalefaces/"+result, self.choiceImage)
         print "Finished plotting image"
     elif(self.db == "orl"):
         utility.choicePlot("orl_faces/"+self.testImage, "orl_faces/"+result, self.choiceImage)
     elif(self.db == "db3"):
         pass
     self.choiceResult = tk.Frame(self)
     self.choiceResult.place(in_=self.algorithm, x=0,y=0,relwidth=1,relheight=1)
     choiceImage = ImageTk.PhotoImage(file=self.choiceImage)
     labelChoice = tk.Label(self.choiceResult, image=choiceImage)
     labelChoice.image = choiceImage
     labelChoice.pack(side="top")
     print "should happen"
     choiceBack = tk.Button(self.choiceResult, text="Back", command=lambda: self.algorithm.lift())
     choiceBack.pack(side="top")
     self.choiceResult.lift()