-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrenderer.js
More file actions
45 lines (37 loc) · 1.22 KB
/
Copy pathrenderer.js
File metadata and controls
45 lines (37 loc) · 1.22 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
const execSync = require('child_process').execSync;
var command;
var app = require('electron').remote;
var dialog = app.dialog;
var fs = require('fs');
var fileloc;
document.getElementById('addImageButton').onclick = () => {
dialog.showOpenDialog((filenames) => {
if(filenames === undefined) {
alert('No file selected');
} else {
readFile(filenames[0]);
}
});
};
function readFile(filepath) {
fs.readFile(filepath, (err, data) => {
if(err) {
alert('Some error has occured');
return;
}
document.getElementById('addedImages').innerHTML += ('<li><input type="image" src="' + filepath + '"></li>');
fileloc = filepath;
});
}
document.getElementById('addedImages').onclick = () => {
command = 'python text_recognition.py --east frozen_east_text_detection.pb --image ' + fileloc;
execSync(command);
fs.readFile('testFile.txt', 'utf-8', (err, data) => {
document.getElementById('extractedText').innerHTML = data;
});
};
document.getElementById('copyToClipboardButton').onclick = () => {
var copyText = document.getElementById('extractedText');
copyText.select();
document.execCommand("copy");
};