Пример #1
0
def FindTennisBall():
    i = 0

    while i < 10:
        with picamera.PiCamera() as camera:
            camera.resolution = (1024, 768)
            camera.capture("images/tennisImage.jpg")
            camera.close()

        img = cv2.imread("images/tennisImage.jpg")

        imgCopy = img.copy()

        checker = od()

        if checker.checkForTennisBall(img.copy()):
            with picamera.PiCamera() as camera:
                camera.resolution = (1024, 768)
                camera.capture("images/ActualImage.jpg")
                camera.close()

            post.postImage("images/ActualImage.jpg")
            time.sleep(10)
            post.postText(200, "Great picture! I'll put it on facebook for you")
            time.sleep(10)
            post.postText(300, "kidding ;) ")
            time.sleep(2)
            break
        else:
            i = i + 1
    else:
        post.postText(200, "Maybe next time!")
        time.sleep(10)
Пример #2
0
def FindFace():
    faceCount = 0

    while faceCount == 0:
        stream = io.BytesIO()
        with picamera.PiCamera() as camera:
            camera.resolution = (640, 480)
            camera.capture("images/LifeFaceDetection.jpg")
            camera.close()

        stream.seek(0)

        image = cv2.imread("images/LifeFaceDetection.jpg")

        fd = FaceDetector()

        faceRects = fd.detect(image)
        faceCount = len(faceRects)

        if len(faceRects) > 0:
            DrawRectangleAndSave(faceRects, image)

            lib.logImages.logFace(image)

            post.postText(700, "Hi!")
            time.sleep(3)
            post.postText(400, "Nice outfit")
            time.sleep(2)
            post.postText(200, "If you have a tennis ball I can take your picture")
            FindTennisBall()
        else:
            print "no faces found"
Пример #3
0
        image = cv2.imread("images/LifeFaceDetection.jpg")

        fd = FaceDetector()

        faceRects = fd.detect(image)
        faceCount = len(faceRects)

        if len(faceRects) > 0:
            DrawRectangleAndSave(faceRects, image)

            lib.logImages.logFace(image)

            post.postText(700, "Hi!")
            time.sleep(3)
            post.postText(400, "Nice outfit")
            time.sleep(2)
            post.postText(200, "If you have a tennis ball I can take your picture")
            FindTennisBall()
        else:
            print "no faces found"


if __name__ == "__main__":

    post.postText(200, "")

    while True:
        numberFaces = FindFace()
        print post.postText(500, "")
        time.sleep(5)