예제 #1
0
    def __init__(self,filename,color,cascade,READ_FILE):

        labeled=zip(filename,color)
        label=[]
        feature_train=[]

        for (fd,c) in labeled:
            print fd
            if READ_FILE is True:
                img=cv2.imread(fd,0)
            else:
                img = filename
            if img is None:
                print "image can't be loaded in face recog"
                sys.exit(0)
            face_cascade=cv2.CascadeClassifier(cascade)
            features=Feature_extractor(img)

            face=face_cascade.detectMultiScale(
                img,
                scaleFactor=1.1,
                minNeighbors=2,
                minSize=(10,10)
            )

            window=face[0]
            (x,y,w,h)=window


            #print "selectkp"
            #print window

            kp=features.keypoints()

            selectKp=features.select_kp(window)
            #print selectKp


            for (X,Y) in selectKp:
                plt.scatter(X,Y,color=c)
                label.append(c)
                feature_train.append([X,Y])


            #cv2.rectangle(img,(x,y),(x+w,y+h),(0,255,0),1)

            #cv2.imshow("image",img)


        self.label=label
        self.feature_train=feature_train
예제 #2
0


face=face_cascade.detectMultiScale(
    image,
    scaleFactor=1.1,
    minNeighbors=2,
    minSize=(400,400)
)

window=face[0]
print face
(x,y,w,h)=window


kp=features.keypoints()
selectKp=features.select_kp(window)

if len(selectKp)==0 :
    print "NO KEYPOINTS IN WINDOW"
    sys.exit(0)



clf=Training(filenames,color,cascade,READ_FILE=True)

clf.train()
points= clf.predict(selectKp)


print "counting frequency"