<! DOCTYPE html> <html> <head> <meta charset = “UTF-8”> <title> Mushroom Recognition </ title> </ head> <style> .body { background: # 000; color: #fff; overflow: hidden; } </style> <body class=”body”> <input type=”file” onchange=”onImageSelected(event)”/> <button type=”button” id=”htmlButtonPress” onclick=”launchPython()” >Clasifica</button> <img id=”myimage” width=600 height=400 > <canvas id=”myCanvas”/> <section> <script> var buffer = require('buffer'); var path = require('path'); var fs = require('fs'); // Here, the image that is identified in the Canvas is loaded as “myimage. function onImageSelected(event) { var selectedFile = event.target.files[0]; var reader = new FileReader(); var imgtag = document.getElementById(“myimage”); reader.onload = function(event) { imgtag.src = event.target.result; var imagen = imgtag.src; var data = imagen.replace(/^data:image\/\w+;base64,/, “"); // console.log(“La data es:”+data) var buf = new Buffer(data, 'base64'); fs.writeFile('ima.jpg', buf, (error) => {/* handle error*/}); }; reader.readAsDataURL(selectedFile); } const PowerShell = require(“powershell”); // Here, the communication with Octave is made so that it executes the programs. function launchPython() { let ps = new PowerShell('C:/Octave/octave-4.4.1/bin/octave-cli -qf demos.m'); ps.on(“error”, err => { console.error(err); }); // Stdout ps.on(“output”, data => { console.log(data); const Par = document.createElement('p') Par.textContent = data; document.querySelector('body').appendChild(Par); }); } </script> // Modules to control application life and create native browser window const {app, BrowserWindow} = require('electron') // Keep a global reference of the window object. If you do not, the window will // be closed automatically when the JavaScript object is garbage collected. let mainWindow function createWindow () { // Create the browser window. mainWindow = new BrowserWindow({width: 600, height: 700}) // and load the index.html of the app. mainWindow.loadFile('index.html') // Open the DevTools. // mainWindow.webContents.openDevTools() // Emitted when the window is closed. mainWindow.on('closed', function () { // Dereference the window object, typically you would store windows // in an array if your app supports multi windows, this is the time // when you should delete the corresponding element. mainWindow = null }) } // This method will be called when Electron has finished // initialization and is ready to create browser windows. // Some APIs can only be used after this event occurs. app.on('ready', createWindow) // Quit when all windows are closed. app.on('window-all-closed', function () { // On OS X, it is typical for applications and their menu bar // to stay active until the user quits explicitly with Cmd + Q if (process.platform!== 'darwin') { app.quit() } }) app.on('activate', function () { // On OS X, it is typical to re-create a window in the app when the // dock icon is clicked and there are no other windows open. if (mainWindow === null) { createWindow() } }) // In this file, you can include the remainder of your app's specific primary process // code. You can also place them in separate files and require them here. See translate video of program operation in Appendix 1. |