-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathAppServer.py
More file actions
53 lines (40 loc) · 1.19 KB
/
Copy pathAppServer.py
File metadata and controls
53 lines (40 loc) · 1.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# -*- coding: utf-8 -*-
"""
Created on Sat Nov 12 15:33:54 2016
@author: strider
"""
import pygame, pygame.camera, time
import os, flask, json, storefilesintoazure, emotioncog
from flask import Flask, request
application = Flask(__name__)
def getImages():
pygame.camera.init()
cam = pygame.camera.Camera("/dev/video0",(640,480))
cam.start()
for i in range(0,5):
time.sleep(2)
img = cam.get_image()
filename="filename"+str(i)+".jpg"
pygame.image.save(img,filename)
cam.stop()
storefilesintoazure.saveFile()
#var = 0
getEmotion()
return json.dumps({"value":True})
def getEmotion():
count = 0
for i in range(0,5):
link="https://reactonfly.blob.core.windows.net/images/myblockblob"+str(i)
if(emotioncog.processLinkForEmotion(link)):
count = count + 1
if count>=3:
return json.dumps({"value":True})
else:
return json.dumps({"value":True})
@application.route('/')
def main():
#getImages()
return flask.jsonify(getImages())
if __name__ == "__main__":
application.secret_key = os.urandom(24)
application.run(threaded=True, ssl_context=('ssl.cert', 'ssl.key'))