Commit c21c9bd9 authored by Ossi Laine's avatar Ossi Laine
Browse files

Fixed socket connection in embody genration

parent ea9b8649
...@@ -950,6 +950,8 @@ def statistics(): ...@@ -950,6 +950,8 @@ def statistics():
questions = question.query.filter_by(experiment_idexperiment=exp_id).all() questions = question.query.filter_by(experiment_idexperiment=exp_id).all()
pages_and_questions = {} pages_and_questions = {}
'''
for p in pages: for p in pages:
questions_list = [(p.idpage, a.idquestion) for a in questions] questions_list = [(p.idpage, a.idquestion) for a in questions]
pages_and_questions[p.idpage] = questions_list pages_and_questions[p.idpage] = questions_list
...@@ -979,9 +981,13 @@ def statistics(): ...@@ -979,9 +981,13 @@ def statistics():
# slider_answers['mean'] = get_mean_from_slider_answers(slider_answers) # slider_answers['mean'] = get_mean_from_slider_answers(slider_answers)
slider_answers = { slider_answers = {
'mean': mean 'mean': mean
} }
'''
slider_answers = {}
# Background question answers # Background question answers
bg_questions = background_question.query.filter_by( bg_questions = background_question.query.filter_by(
experiment_idexperiment=exp_id).all() experiment_idexperiment=exp_id).all()
......
...@@ -183,6 +183,7 @@ def plot_coordinates(coordinates, image_path=DEFAULT_IMAGE_PATH): ...@@ -183,6 +183,7 @@ def plot_coordinates(coordinates, image_path=DEFAULT_IMAGE_PATH):
# Total amount of points # Total amount of points
points_count = len(coordinates['coordinates']) points_count = len(coordinates['coordinates'])
step = 1
# Load image to a plot # Load image to a plot
image = mpimg.imread(image_path) image = mpimg.imread(image_path)
...@@ -205,21 +206,28 @@ def plot_coordinates(coordinates, image_path=DEFAULT_IMAGE_PATH): ...@@ -205,21 +206,28 @@ def plot_coordinates(coordinates, image_path=DEFAULT_IMAGE_PATH):
for idx, point in enumerate(coordinates["coordinates"]): for idx, point in enumerate(coordinates["coordinates"]):
try: try:
frame[int(point[1]), int(point[0])] = 1 frame[int(point[1]), int(point[0])] = 1
except IndexError as err: except IndexError as err:
app.logger.info(err) app.logger.info(err)
point = ndimage.gaussian_filter(frame, sigma=5) point = ndimage.gaussian_filter(frame, sigma=5)
ax2.imshow(point, cmap='hot', interpolation='none') ax2.imshow(point, cmap='hot', interpolation='none')
# Try to send progress information to socket.io # Try to send progress information to socket.io
try:
emit('progress', {'done':idx+1/points_count, 'from':points_count}) if idx == 0:
socketio.sleep(0)
except RuntimeError as err:
print(err)
continue continue
if round((idx / points_count) * 100) % (step * 5) == 0:
try:
emit('progress', {'done':step * 5, 'from':100})
socketio.sleep(0.05)
except RuntimeError as err:
print(err)
continue
step += 1
image_mask = mpimg.imread(IMAGE_PATH_MASK) image_mask = mpimg.imread(IMAGE_PATH_MASK)
ax2.imshow(image_mask) ax2.imshow(image_mask)
......
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