Commit ff0db8c5 authored by root's avatar root
Browse files

Production setup

parent b75809bd
......@@ -130,6 +130,12 @@
<iframe class="embed-responsive-item thumbnail" src="/{{ s.media }}" allowFullScreen></iframe>
</div>
</td>
{% elif s.type == 'audio' %}
<td>
<div class="embed-responsive embed-responsive-16by9 ">
<iframe class="embed-responsive-item thumbnail" src="/{{ s.media }}" allowFullScreen></iframe>
</div>
</td>
{% else %}
<td>{{ s.text }}</td>
{% endif %}
......
......@@ -986,7 +986,7 @@ def create_embody(page_id):
embody = page_id["embody"]
img_path = embody_plot.get_coordinates(page, embody)
print(img_path)
app.logger.info(img_path)
emit('end', {'path':img_path})
@socketio.on('end', namespace="/create_embody")
......
......@@ -409,12 +409,22 @@ def download_csv():
embody_answers = embody_answer.query.filter_by(answer_set_idanswer_set=participant.idanswer_set).all()
answers_list = []
for embody_answer_data in embody_answers:
embody_answer_data = json.loads(embody_answer_data.coordinates)
coordinates_to_bitmap = [[0 for x in range(embody_answer_data['height'] + 2)] for y in range(embody_answer_data['width'] + 2)]
for point in list(zip( embody_answer_data['x'], embody_answer_data['y'])):
coordinates_to_bitmap[point[0]][point[1]] += 0.1
answers_list.append(json.dumps(coordinates_to_bitmap))
try:
embody_answer_data = json.loads(embody_answer_data.coordinates)
coordinates_to_bitmap = [[0 for x in range(embody_answer_data['height'] + 2)] for y in range(embody_answer_data['width'] + 2)]
for point in list(zip( embody_answer_data['x'], embody_answer_data['y'] )):
try:
coordinates_to_bitmap[point[0]][point[1]] += 0.1
except IndexError:
continue
answers_list.append(json.dumps(coordinates_to_bitmap))
except ValueError as err:
app.logger.info(err)
# old way to save only visited points:
# answers_list = [ json.dumps(list(zip( json.loads(a.coordinates)['x'], json.loads(a.coordinates)['y']))) for a in embody_answers]
......@@ -444,4 +454,4 @@ def researcher_info():
return render_template('researcher_info.html')
# EOF
\ No newline at end of file
# EOF
......@@ -27,6 +27,13 @@ class Config(object):
SQLALCHEMY_DATABASE_URI = 'mysql+pymysql://'+MYSQL_USER+':'+MYSQL_PASSWORD+'@'+MYSQL_SERVER+'/'+MYSQL_DB+'?charset=utf8mb4'
SQLALCHEMY_TRACK_MODIFICATIONS = False
SQLALCHEMY_ENGINE_OPTIONS = {
"pool_pre_ping": True,
"pool_recycle": 300,
"max_overflow": 30,
"pool_size": 20
}
TEMPLATES_AUTO_RELOAD = True
DEBUG = True
DEBUG = False
......@@ -36,7 +36,7 @@ from matplotlib.backends.backend_agg import FigureCanvasAgg as FigureCanvas
from matplotlib.figure import Figure
from flask_socketio import emit
from app import socketio
from app import socketio, app
from config import Config
......@@ -134,6 +134,7 @@ def get_coordinates(idpage, idembody=None, select_clause=SELECT_BY_PAGE_AND_PICT
image_path = db._db_cur.fetchone()[0]
image_path = './app' + image_path
# Draw image
plt = plot_coordinates(coordinates, image_path)
else:
......@@ -167,6 +168,9 @@ def format_coordinates(cursor):
standard_radiuses = np.full((1, len(coordinates['x'])), standard_radius).tolist()[0]
r.extend(standard_radiuses)
continue
except ValueError as err:
app.logger.info(err)
continue
return {
"x":x,
......@@ -196,9 +200,15 @@ def plot_coordinates(coordinates, image_path=DEFAULT_IMAGE_PATH):
frame = np.zeros((image_data[0] + 10,image_data[1] + 10))
if image_path == DEFAULT_IMAGE_PATH:
#app.logger.info(coordinates)
for idx, point in enumerate(coordinates["coordinates"]):
frame[int(point[1]), int(point[0])] = 1
try:
frame[int(point[1]), int(point[0])] = 1
except IndexError as err:
app.logger.info(err)
point = ndimage.gaussian_filter(frame, sigma=5)
ax2.imshow(point, cmap='hot', interpolation='none')
......@@ -212,6 +222,7 @@ def plot_coordinates(coordinates, image_path=DEFAULT_IMAGE_PATH):
image_mask = mpimg.imread(IMAGE_PATH_MASK)
ax2.imshow(image_mask)
else:
# TODO: gaussian disk appearing only on empty spaces in the pictures
# -> at the moment this implementation works only for the default image
......@@ -223,6 +234,8 @@ def plot_coordinates(coordinates, image_path=DEFAULT_IMAGE_PATH):
ax1.plot(coordinates["x"],coordinates["y"], 'ro', alpha=0.2)
ax1.imshow(image, alpha=0.6)
app.logger.info("iamge plotted")
# return figure for saving/etc...
return fig
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment