Beispiel #1
0
import logging

import cv2

from ggly.ggly import Ggly

if __name__ == "__main__":
    logging.basicConfig(level=logging.DEBUG,
                        format='%(asctime)s [%(levelname)s] %(message)s')
    img, _ = Ggly(debug=True).go(cv2.imread("./.test_img/test_1.jpg"))
    cv2.imwrite('./.test_img/test_ggly.jpg', img)
Beispiel #2
0
import os

from ggly.ggly import Ggly
from ggly.handlers.fb import FacebookHandler
from ggly.handlers.url import UrlHandler

ggly = Ggly()
url_handler = UrlHandler(ggly)
fb = FacebookHandler(ggly, os.environ.get('FB_ACCESS_TOKEN', None), os.environ.get('FB_VERIFY_TOKEN', None))


def handle_url(request):
    return url_handler.handle_http_request(request)


def handle_fb_webhook(request):
    return fb.handle_http_request(request)


def handle_fb_gcs_event(data, context):
    return fb.handle_gcs_event(data, context)
Beispiel #3
0
import logging
import os
import tempfile

from flask import Flask, request

import main
from ggly.ggly import Ggly

logging.basicConfig(level=logging.DEBUG, format='%(asctime)s [%(levelname)s] %(name)s: %(message)s')
logger = logging.getLogger(__name__)

img_dir = '%s/ggly/' % tempfile.gettempdir()
if not os.path.exists(img_dir):
    os.makedirs(img_dir)
logger.debug("Writing files to %s", img_dir)

ggly = Ggly(debug=True)
app = Flask(__name__)


@app.route('/ggly')
def ggly():
    return main.handle_url(request)
Beispiel #4
0
 def test_group_1(self):
     _, face_count = Ggly().go(cv2.imread("./img/group_1.jpg"))
     self.assertEqual(face_count, 15)
Beispiel #5
0
 def test_selfie(self):
     _, face_count = Ggly().go(cv2.imread("./img/selfie.jpg"))
     self.assertEqual(face_count, 1)
Beispiel #6
0
import logging
import sys

import cv2

from ggly.ggly import Ggly

if __name__ == "__main__":
    logging.basicConfig(level=logging.INFO,
                        format='%(asctime)s [%(levelname)s] %(message)s')
    video_capture = cv2.VideoCapture(0)
    if not video_capture.isOpened():
        logging.error("Unable to capture video")
        sys.exit(-1)
    ggly = Ggly(debug=True)
    while True:
        ret, frame = video_capture.read()
        img, _ = ggly.go(frame)
        cv2.imshow('Press q to exit', cv2.flip(img, 1))
        if cv2.waitKey(1) & 0xFF == ord('q'):
            break
    video_capture.release()
    cv2.destroyAllWindows()