<commit_before>import cv2
from PIL import Image, ImageTk
# Author: <NAME>

# const
EMO_ANGRY = 100
EMO_SAD = 101
EMO_HAPPY = 102

# test purposes
ex_img = cv2.imread("no_signal.png", 1)

# auxiliary functions
def _toTkImage(img):
    # convert to RGB channel
    img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
    im = Image.fromarray(img)
    # return a TkImage which could be used directly by Tkinter
    return ImageTk.PhotoImage(im)

# interface

def getUserEmotion():
    return EMO_SAD

def getCameraSnapShot():
    # getCameraSnapShot() -> TkImage
    return _toTkImage(ex_img)<commit_msg>Implementation of SnaoShot<commit_after>import cv2
from PIL import Image, ImageTk
# Author: <NAME>

# const
EMO_ANGRY = 100
EMO_SAD = 101
EMO_HAPPY = 102

CAMERA_PORT = 0
# Number of frames to throw away while the camera adjusts to light levels
RAMP_FRAMES = 5

CAMERA = cv2.VideoCapture(CAMERA_PORT)

# test purposes
ex_img = cv2.imread("no_signal.png", 1)

# auxiliary functions
def _toTkImage(img):
    # convert to RGB channel
    img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
    im = Image.fromarray(img)
    # return a TkImage which could be used directly by Tkinter
    return ImageTk.PhotoImage(im)

def _getCameraRaw():
    focusCamera()
    retval, img = CAMERA.read()
    return img

# interface

def focusCamera():
    for i in xrange(RAMP_FRAMES):
        CAMERA.read()

def getUserEmotion():
    return EMO_SAD

def getCameraSnapShot():
    # getCameraSnapShot() -> TkImage
    im = _getCameraRaw()
    # This should be executed after Tk() is called
    im = _toTkImage(im)
    return im

# unit test code
if __name__ == "__main__":
    print getUserEmotion()
    cv2.imshow("image", _getCameraRaw())
    cv2.waitKey(0)
    cv2.destroyAllWindows()
{'fraction_non_alphanumeric': 0.0930896630496859, 'fraction_numerical': 0.0211307824100514, 'mean_word_length': 3.7868852459016393, 'pattern_counts': {'":': 1, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1390460', 'n_tokens_mistral': 675, 'n_tokens_neox': 646, 'n_words': 173}