Exemple #1
0
def cameraStream():
    camera = picamera.PiCamera()
    camera.vflip = True

    fFace1 = cv2.CascadeClassifier(
        '/home/pi/Downloads/opencv-3.0.0/data/haarcascades/haarcascade_frontalface_alt.xml'
    )
    fFace2 = cv2.CascadeClassifier(
        '/home/pi/Downloads/opencv-3.0.0/data/haarcascades_cuda/haarcascade_frontalface_default.xml'
    )

    pFace = cv2.CascadeClassifier(
        '/home/pi/Downloads/opencv-3.0.0/data/haarcascades_cuda/haarcascade_profileface.xml'
    )

    x = 0

    while True:
        filename = 'image' + str(x) + '.jpg'
        camera.capture(filename)
        image = np.asarray(cv2.imread(filename))
        grayScale = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
        numFaces = len(fFace2.detectMultiScale(grayScale, 1.3, 4))

        if numFaces > 0:
            ftp.Upload(filename)
            GPIO.output(start_stop, GPIO.LOW)
            x += 1
        os.remove(filename)

    camera.close()
Exemple #2
0
def faceDetector(filename):
    #fFace1 = cv2.CascadeClassifier('/home/pi/Downloads/opencv-3.0.0/data/haarcascades/haarcascade_frontalface_alt.xml')
    fFace2 = cv2.CascadeClassifier(
        '/home/pi/Downloads/opencv-3.0.0/data/haarcascades_cuda/haarcascade_frontalface_default.xml'
    )
    #pFace = cv2.CascadeClassifier('/home/pi/Downloads/opencv-3.0.0/data/haarcascades_cuda/haarcascade_profileface.xml')
    image = np.asarray(cv2.imread(filename))
    grayScale = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
    numFaces = len(fFace2.detectMultiScale(grayScale, 1.75, 4))

    if numFaces > 0:
        print(numFaces)
        ftp.Upload(filename)
        GPIO.output(start_stop, GPIO.LOW)
    os.remove(filename)
Exemple #3
0
def faceDetector(filename):
    """Documentation for the faceDetector thread

    Opens an image file and searches for a face by means of haarcascades. If a face is found it uploads the picture to the server.
    It also changes the state of GPIO start_stop to LOW
    """
    #fFace1 = cv2.CascadeClassifier('/home/pi/Downloads/opencv-3.0.0/data/haarcascades/haarcascade_frontalface_alt.xml')
    fFace2 = cv2.CascadeClassifier(
        '/home/pi/Downloads/opencv-3.0.0/data/haarcascades_cuda/haarcascade_frontalface_default.xml'
    )
    #pFace = cv2.CascadeClassifier('/home/pi/Downloads/opencv-3.0.0/data/haarcascades_cuda/haarcascade_profileface.xml')
    image = np.asarray(cv2.imread(filename))
    grayScale = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
    numFaces = len(fFace2.detectMultiScale(grayScale, 1.3, 4))

    if numFaces > 0:  #if there is a face
        ftp.Upload(filename)
        GPIO.output(start_stop, GPIO.LOW)  #changes state of start_stop to LOW
    os.remove(filename)
Exemple #4
0
def faceDetector(filename):
    """Documentation for the faceDetector thread

    Opens an image file and searches for a face by means of haarcascades. If a face is found it uploads the picture to the server.
    It also changes the state of GPIO start_stop to LOW
    """

    global isTakingPictures

    fFace2 = cv2.CascadeClassifier(
        '/home/pi/Downloads/opencv-3.0.0/data/haarcascades_cuda/haarcascade_frontalface_default.xml'
    )
    image = np.asarray(cv2.imread(filename))
    grayScale = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
    numFaces = len(fFace2.detectMultiScale(grayScale, 1.3, 4))

    if numFaces > 0:  #if there is a face
        Stop()
        ftp.Upload(filename)
        print('IMAGE')
        WriteToServer('IMAGE ' + filename)
        #isTakingPictures = False

    os.remove(filename)
Exemple #5
0
fFace1 = cv2.CascadeClassifier(
    '/home/pi/Downloads/opencv-3.0.0/data/haarcascades/haarcascade_frontalface_alt.xml'
)
fFace2 = cv2.CascadeClassifier(
    '/home/pi/Downloads/opencv-3.0.0/data/haarcascades_cuda/haarcascade_frontalface_default.xml'
)

pFace = cv2.CascadeClassifier(
    '/home/pi/Downloads/opencv-3.0.0/data/haarcascades_cuda/haarcascade_profileface.xml'
)

x = 0
while time.time() < end:
    filename = 'image' + str(x) + '.jpg'
    camera.capture(filename)
    image = np.asarray(cv2.imread(filename))
    grayScale = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
    #numFaces = len(fFace1.detectMultiScale(grayScale, 1.2, 4))
    numFaces = len(fFace2.detectMultiScale(grayScale, 1.3, 4))
    #numFaces += len(pFace.detectMultiScale(grayScale, 1.1, 4))

    if numFaces > 0:
        ftp.Upload(filename)
        x += 1
    os.remove(filename)
    print(numFaces)

camera.close()

exit(0)