save csv + paper dims
Co-authored-by: Alex <AlexanderMcDowell@users.noreply.github.com>master
parent
fa1e988344
commit
76e178176d
|
@ -1,11 +1,11 @@
|
|||
from flask import Flask, render_template, request
|
||||
from flask import Flask, render_template, request, send_file
|
||||
import numpy as np
|
||||
from ratio_pyrometry import ratio_pyrometry_pipeline
|
||||
from size_projection import get_projected_area
|
||||
import base64
|
||||
import cv2 as cv
|
||||
import plotly.figure_factory as ff
|
||||
from scipy import stats
|
||||
import pandas as pd
|
||||
|
||||
app = Flask(
|
||||
__name__,
|
||||
|
@ -58,12 +58,28 @@ def ratio_pyro():
|
|||
)
|
||||
freq_plot = fig.to_html()
|
||||
|
||||
# create csv-formatted stuff
|
||||
# currently only supports 1 firebrand (grabs first object in plot).
|
||||
plot_data=fig.to_dict()
|
||||
x_data = plot_data["data"][0]["x"]
|
||||
y_data = plot_data["data"][0]["y"]
|
||||
|
||||
tdata = [["Temperature", "Frequency"]]
|
||||
for i in range(len(x_data)):
|
||||
r = []
|
||||
r.append(x_data[i])
|
||||
r.append(y_data[i])
|
||||
tdata.append(r)
|
||||
|
||||
csvstr = pd.DataFrame(tdata).to_csv(index=False, header=False)
|
||||
|
||||
return render_template(
|
||||
'pyrometry-results.html',
|
||||
img_orig_b64=img_orig_b64,
|
||||
img_res_b64=img_res_b64,
|
||||
legend=key,
|
||||
freq_plot=freq_plot
|
||||
freq_plot=freq_plot,
|
||||
csv_data=csvstr
|
||||
)
|
||||
|
||||
|
||||
|
@ -81,6 +97,8 @@ def projected_area_results():
|
|||
f_bytes,
|
||||
int(request.form['area_threshold']),
|
||||
int(request.form['min_display_threshold']),
|
||||
float(request.form['paper_width']),
|
||||
float(request.form['paper_width'])
|
||||
)
|
||||
|
||||
return render_template(
|
||||
|
@ -88,3 +106,7 @@ def projected_area_results():
|
|||
img_b64=img,
|
||||
dtable=dtable
|
||||
)
|
||||
|
||||
# @app.route("/download_pyrometry_temps")
|
||||
# def download_pyrometry_temps():
|
||||
# return send_file()
|
||||
|
|
|
@ -9,9 +9,9 @@ import matplotlib.pyplot as plt
|
|||
from skimage import measure, morphology, color, segmentation
|
||||
import io
|
||||
|
||||
def get_projected_area(image, area_threshold, display_threshold):
|
||||
def get_projected_area(image, area_threshold, display_threshold, paper_width, paper_height):
|
||||
total_px = image.size
|
||||
total_mm = 60322.46
|
||||
total_mm = paper_width * paper_height * 25.4
|
||||
|
||||
output = []
|
||||
original = cv.imdecode(image, cv.IMREAD_UNCHANGED)
|
||||
|
|
|
@ -1,3 +1,21 @@
|
|||
function saveCsv(csvString) {
|
||||
function saveCsv(csvStr) {
|
||||
// string rep
|
||||
// var csvStr = "";
|
||||
// for (let r = 0; r < csvData.length; r++) {
|
||||
// let row = csvData[r]
|
||||
// for (let c = 0; c < row.length; c++) {
|
||||
// let item = row[c]
|
||||
// csvStr += item;
|
||||
// if (c < row.length - 1)
|
||||
// csvStr += ",";
|
||||
// }
|
||||
// if (r < csvStr.length - 1)
|
||||
// csvStr += "\r\n";
|
||||
// }
|
||||
|
||||
// define data blob
|
||||
var data = new Blob([csvStr]);
|
||||
|
||||
// create & click temp link
|
||||
window.open(URL.createObjectURL(data));
|
||||
}
|
||||
|
|
|
@ -1,6 +1,12 @@
|
|||
{% extends "base.html" %}
|
||||
|
||||
{% block head %}
|
||||
<script src="/s/js/csv_download.js"></script>
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
|
||||
<div style="display:flex; flex-direction: column;">
|
||||
<table class="img-table">
|
||||
<tr>
|
||||
<th class="img-table-heading">Input Image</th>
|
||||
|
@ -33,8 +39,17 @@
|
|||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<br>
|
||||
{# Temperature Frequency Plot #}
|
||||
<div style="display: flex; flex-direction: row; align-items: center;">
|
||||
<strong>Temperature Distribution</strong>
|
||||
<button
|
||||
style="width: 10rem; height: 2rem; margin-left: 1rem;"
|
||||
download="temperature-data.csv" type="text/csv" onclick="saveCsv(`{{csv_data}}`)">Download Data as CSV</button>
|
||||
</div>
|
||||
{{ freq_plot | safe }}
|
||||
|
||||
</div>
|
||||
|
||||
{% endblock %}
|
||||
|
|
Loading…
Reference in New Issue