I'm writing a small Flask app to recognize handwritten digits (0-9). I wrote almost all the elements (machine learning model, web app, etc.) but I'm having a problem capturing an image (drawn using Canvas) like:
I would like to get the image and save it to a temp file. I know Python but I've never used JavaScript, which is necessary for using Canvas.
HTML:
<form method="post" action="{{url_for('main.image')}}">
<button name="img" onclick="drawDataURIOnCanvas();">Get png</button>
</form>
JS:
function InitThis() {
....
}
function Draw(x, y, isDown) {
....
function drawDataURIOnCanvas() {
var element = document.createElement('a');
element.setAttribute('href', document.getElementById('Canvas').toDataURL('image/jpeg'));
element.setAttribute('download', 'chart.jpeg');
element.style.display = 'none';
document.body.appendChild(element);
element.click();
}
Function drawDataURIOnCanvas() saves the image using browser save manager, but I would like to save it to temp files and use the image later.
