Example #1
0
 def addCamera(self, name, port=0, exposure=0.2, wait = 0 ):
     time.sleep(wait)
     save_camera_config(port, exposure)
     img_array = take_picture()
     face = self.img_to_array(img_array)[0]
     print('There are this many faces: ', len(face))
     if len(face) == 0:
         print(name, ' was not detected. Please try again!')
         return None
     print(img_array.shape)
     if len(face) > 1:
         print('Too many faces were detected. Please try again!')
         return None
     print(name, ' was successfully added to the database.')
     
     border = test.detectFromImg(img_array)[1][0]
     fig,ax = plt.subplots()
     ax.imshow(img_array)
     ax.add_patch(patches.Rectangle((border[1], border[3]),border[0]-border[1],border[2]-border[3],edgecolor = 'pink', fill=False))
     ax.set_xticks([])
     ax.set_yticks([])
     self.add(name,face)
Example #2
0
import os
import dlib
import matplotlib.pyplot as plt
import matplotlib.patches as patches
import cv2
from collections import Counter
import tensorflow as tf
import logging
logging.getLogger("tensorflow").setLevel(logging.FATAL)
print("Imports complete", flush = True)
import time
app = Flask(__name__)
ask = Ask(app, '/')

#camera set up (change port for different camera)
save_camera_config(port=2, exposure=0.5)

#for template matching
methods = ['cv2.TM_CCOEFF', 'cv2.TM_CCOEFF_NORMED','cv2.TM_CCORR_NORMED', 'cv2.TM_SQDIFF', 'cv2.TM_SQDIFF_NORMED']
ntemplates = [file for file in os.scandir("./masks/nums")]


#for matching output of classifier --> actual suit
suits = ["dclubs", "ddiamonds", "dhearts", "dspades","uclubs","udiamonds", "uhearts", "uspades"]
suits_true = ["clubs", "diamonds", "hearts", "spades"]
tmp = {}
for i, suit in enumerate(suits):
	tmp[suit] = i
	tmp[i] = suit
suits= tmp
Example #3
0
 def camera(self, port=0, exposure=0.2):
     save_camera_config(port, exposure)
     img_array = take_picture()
     if img_array == []:
         raise ValueError("No face detected") 
     return img_array
Example #4
0
from camera import take_picture
import cv2
from camera import save_camera_config
import matplotlib.pyplot as plt
import numpy as np
from model_tester import model

save_camera_config(port=0, exposure=1)


def get_signs(n, weights1, bias1, weights2, bias2, weights3, bias3, weights4,
              bias4):
    """
    Will take in a bunch of pictures every second for a specified amount of time
    creating np.ndarrays of our signs
    Parameter: n : number of pictures desired to be taken
    Returns: np.ndarray of our image arrays
    """

    uppercase = "ABCDEFGHIJKLMNOPQRSTUVWXYZ!? "
    str = ""
    img_session = []
    fig, ax = plt.subplots()
    for cnt in range(n):
        img_array = take_picture()
        print("Picture taken")
        img_array = img_array[:, 280:1000, :]
        resized = cv2.resize(img_array, (200, 200),
                             interpolation=cv2.INTER_AREA)
        gray = cv2.cvtColor(resized, cv2.COLOR_RGB2GRAY)
        ax.imshow(gray, cmap=plt.cm.gray)
Example #5
0
import os
import dlib
import matplotlib.pyplot as plt
import matplotlib.patches as patches
import cv2
from collections import Counter
import tensorflow as tf
import logging
logging.getLogger("tensorflow").setLevel(logging.FATAL)
print("Imports complete", flush=True)
import time
app = Flask(__name__)
ask = Ask(app, '/')

#camera set up (change port for different camera)
save_camera_config(port=2, exposure=0.5)

#for template matching
methods = [
    'cv2.TM_CCOEFF', 'cv2.TM_CCOEFF_NORMED', 'cv2.TM_CCORR_NORMED',
    'cv2.TM_SQDIFF', 'cv2.TM_SQDIFF_NORMED'
]
ntemplates = [file for file in os.scandir("./masks/nums")]

#for matching output of classifier --> actual suit
suits = [
    "dclubs", "ddiamonds", "dhearts", "dspades", "uclubs", "udiamonds",
    "uhearts", "uspades"
]
suits_true = ["clubs", "diamonds", "hearts", "spades"]
tmp = {}
Example #6
0
# coding: utf-8

# In[2]:

import ImageLoader
import ImageCompare
import database
import matplotlib.pyplot as plt
import matplotlib.patches as patches
get_ipython().magic('matplotlib notebook')

from camera import save_camera_config
save_camera_config(port=1, exposure=0.7)

# In[3]:


def identify(save=True, force_input=False, from_file=False):
    """
    Takes a picture with configured camera and identifies all of the faces in the picture
    Parameters:
    -----------
    save (boolean):
        whether or not to add the captured image to the database
    from_file(boolean):
        whether or not expect a filename instead of taking a picture
    
    Returns:
    --------
    names (list)
        the list of the name of each person in the picture
Example #7
0
 def __init__(self):
     self.db = Database()
     self.db.load('celebrities.pkl')
     self.logged_in = False
     save_camera_config(0, exposure=0.2)
Example #8
0
 def camera(self, port=0, exposure=0.2):
     save_camera_config(port, exposure)
     img_array = take_picture()
     self.database.append(img_array)
Example #9
0
 def camera(self, port=0, exposure=0.2):
     save_camera_config(port, exposure)
     img_array = take_picture()
     return img_array