Ask Your Question
0

findKeypointMatch() causes "Fatal Python error: (pygame parachute) Segmentation Fault"

asked 2014-11-08 23:55:39 -0500

YoungbinHan gravatar image

updated 2014-11-11 07:37:28 -0500

Hello, I'm trying to use findKeypointMatch() to match faces. Seems like other thing works well. but findKeyointMatch() is not working and causes

Fatal Python error: (pygame parachute) Segmentation Fault

What should i do to solve this problem?

I'm using SimpleCV latest version from the repository, OpenCV 2.4.9, PyGame 1.9.1release on my Ubuntu Gnome 14.10

Here is the code that including findKetpointMatch()

#!/usr/bin/python
#-*- coding: utf-8 -*-

from SimpleCV import *
import os
import glob
import time
import pygame
import cv2

images_path = "visitors/"  #put your image path here if you want to override current directory
extension = "*.png"
quality = 400
minMatch = 0.4
minDist = 0.2
print SimpleCV.__version__
print pygame.__version__
print cv2.__version__
if not images_path:
        path = os.getcwd() #get the current directory
else:
        path = images_path

imgs = list() #load up an image list
directory = os.path.join(path, extension)
files = glob.glob(directory)
filecount = len(files)
print "Number of Files"
print len(files)

cam = Camera()
time.sleep(.1)
counter = 0
face_cascade = HaarCascade("HaarCascades/face.xml")

while True:
    img = cam.getImage()
    faces = img.findHaarFeatures(face_cascade)
    try:
        if faces is not None:
            print "Found Face"
            faces.draw()
            faces = faces.sortArea()
            face = faces[-1]
            newvisitor = face.crop()
            if filecount == 0:
                print "Visitors - no visitor yet"
                newvisitor.save("visitors/0.png")
                filecount += 1
            else:
                print "Visitors - One or more"

            for file in files:
                print file
                visited = Image(file)
                print "Imaged Loaded"
                visited.show()
                time.sleep(0.5)
                newvisitor.show()
                time.sleep(0.5)
                keypoints = visited.findKeypointMatch(newvisitor)
                print "Found Keypoint match percentage"
                if keypoints:
                    print "Y"
                else:
                    print "N"
    except:
        print"Exception Error"
    img.show()

and here is the output - "중지됨" means, "Stopped"

youngbin@youngbin-ultrabook:~/PycharmProjects/untitled$ python detector.py
1.3.0
1.9.1release
2.4.9
Number of Files
1
Found Face
Visitors - One or more
visitors/0.png
Imaged Loaded
Fatal Python error: (pygame parachute) Segmentation Fault
중지됨 (core dumped)
edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
0

answered 2014-11-09 11:41:45 -0500


  • sorry if not quite understand, my English is not very good, hope this helps!

very strange this error, but if what you want is to count faces, is an example, you can implement your algorithm based on it

 #!/usr/bin/python

import SimpleCV
from SimpleCV import * 
import time
import sys

if __name__ == "__main__":

        cont = 0
        green = (0, 255, 0)
        sleeptime = 2
        frame = Image('1.jpg')
        while 1:                
                facedetect = frame.findHaarFeatures('face')

                if facedetect:
            facedetect.draw()
            frame.show()

                        for f in facedetect:
                                cont += 1
                faces = {"faces Encontradas": cont}

        print(faces)
                cont = 0
                time.sleep(sleeptime)

        sys.exit()

image description

for capture and resize you can :

# -*- coding: UTF-8 -*-

__author__='Rodrigo gomes'

from SimpleCV import * #importa todo o framework

cam = Camera() #instanciacao da camera
disp = Display((640,480)) #cria um display com a resolução 640,480
iset = ImageSet() #instancia a classe imageSet

while len(iset) < 10: #enquanto o num de elementos de iset for menor que 10
    img = cam.getImage() #captura um frame
    face = img.findHaarFeatures('face.xml') #procura um rosto na img capturada
        if face: # se existir um rosto
            face = face.sortArea()
            face.draw(width=3) #desenha um retangulo com largura 3 na face
            face = face[-1].crop().resize(100,100) #recorta a face maior na imagem e recorta para 100,100
            iset.append(face) #adiciona a face recortada em uma lista de imagens
    print len(iset) # escreve o valor de iset
    img.save(disp) #apresenta o display capturando as imagens
iset.show() #apresenta os elementos incrementados a iset
edit flag offensive delete link more

Comments

Sorry, but what i want to do is matching a face with another face using findKeypointMatch(); not counting faces.

YoungbinHan gravatar imageYoungbinHan ( 2014-11-11 07:36:20 -0500 )edit

you want to do something like facial recognition?

Rodrigo gomes gravatar imageRodrigo gomes ( 2014-11-16 16:36:01 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2014-11-08 23:55:39 -0500

Seen: 1,127 times

Last updated: Nov 11 '14