class VideoCamera(object):
    def __init__(self):
        self.video = cv2.VideoCapture(0)
        self.nn = CNN()
        self.model = None
        if os.path.exists('./model.h5'):
            print 'Model Already Exist'
            print '--------------------'
            self.model = self.nn.load_model()
        else:
            print 'Model Does Not Exist'
            print '--------------------'
            self.model = self.nn.create_cnn_model()

    def __del__(self):
        self.video.release()

    def get_frame(self):

        _, fr = self.video.read()
        frame = np.copy(fr)
        frame = self.nn.data_frame(frame)
        self.nn.predict_frame(self.model, frame)
        _, jpeg = cv2.imencode('.jpg', fr)
        return jpeg.tobytes()
from cnn import CNN
import os
import time
import threading
import tensorflow as tf

nn = CNN()

if os.path.exists('./model2.h5'):
    print 'Model Already Exist'
    print '--------------------'
    model = nn.load_model()
else:
    print 'Model Does Not Exist'
    print '--------------------'
    model = nn.create_cnn_model()

input = int(raw_input('Enter 0 to train:\nEnter 1 to predict:'))

if input == 0:
    list = []
    for i in xrange(65, 91):
        print 'Training:    ' + str(chr(i))
        print '-----------------------------------------------------'
        images = nn.fetch_data('../asl_alphabet_train/' + chr(i))
        nn.prepare_data(images, letter=chr(i))
    #Nothing
    images = nn.fetch_data('../asl_alphabet_train/' + 'nothing')
    nn.prepare_data(images, letter='nothing')
    #Space
    images = nn.fetch_data('../asl_alphabet_train/' + 'space')