mirror of
https://github.com/jomjol/AI-on-the-edge-device.git
synced 2025-12-18 05:28:19 +03:00
Nightly
- implementation mirroring - index.hthml
This commit is contained in:
@@ -26,6 +26,17 @@
|
||||
<input type="submit" id="take" onclick="doTake()" value="Make new raw image (raw.jpg)">
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="mirror">Mirror image</label>
|
||||
</td>
|
||||
<td>
|
||||
<input type="checkbox" id="mirror" name="mirror" value="1" onchange="drawRotated()">
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
|
||||
|
||||
<tr>
|
||||
<td>
|
||||
Pre-rotate Angle
|
||||
@@ -85,10 +96,13 @@
|
||||
url = basepath + "/fileserver/img_tmp/raw.jpg" + "?session=" + Math.floor((Math.random() * 1000000) + 1);
|
||||
document.getElementById("finerotate").value = 0;
|
||||
document.getElementById("prerotateangle").value = getPreRotate();
|
||||
document.getElementById("mirror").checked = getMirror();
|
||||
document.getElementById("finerotate").disabled = false;
|
||||
document.getElementById("prerotateangle").disabled = false;
|
||||
document.getElementById("updatereferenceimage").disabled = false;
|
||||
document.getElementById("take").disabled = false;
|
||||
document.getElementById("mirror").disabled = false;
|
||||
|
||||
// document.getElementById("ButtonRotate").disabled = false;
|
||||
isActReference = false;
|
||||
loadCanvas(url);
|
||||
@@ -103,7 +117,8 @@
|
||||
document.getElementById("prerotateangle").disabled = true;
|
||||
document.getElementById("updatereferenceimage").disabled = true;
|
||||
document.getElementById("take").disabled = true;
|
||||
// document.getElementById("ButtonRotate").disabled = true;
|
||||
document.getElementById("mirror").disabled = true;
|
||||
|
||||
isActReference = true;
|
||||
loadCanvas(url);
|
||||
ParseConfig();
|
||||
@@ -122,7 +137,8 @@
|
||||
function SaveReference(){
|
||||
if (confirm("Are you sure you want to update the reference image?")) {
|
||||
setPreRotate(document.getElementById("prerotateangle").value);
|
||||
UpdateConfigFile(basepath);
|
||||
setMirror(document.getElementById("mirror").checked);
|
||||
UpdateConfigFileReferenceChange(basepath);
|
||||
var canvas = document.getElementById("canvas");
|
||||
drawRotated(false);
|
||||
SaveCanvasToImage(canvas, "/config/reference.jpg", true, basepath);
|
||||
@@ -162,12 +178,15 @@
|
||||
canvas.addEventListener('mousemove', mouseMove, false);
|
||||
basepath = getbasepath();
|
||||
loadConfig(basepath);
|
||||
ParseConfig();
|
||||
showReference();
|
||||
}
|
||||
|
||||
function drawRotated(_grid = true){
|
||||
finerot= parseFloat(document.getElementById("finerotate").value);
|
||||
prerot = parseFloat(document.getElementById("prerotateangle").value);
|
||||
mirror = document.getElementById("mirror").checked;
|
||||
|
||||
if (finerot == 1) {
|
||||
prerot+=1
|
||||
finerot = 0
|
||||
@@ -185,9 +204,19 @@
|
||||
|
||||
context.clearRect(0,0,imageObj.width,imageObj.height);
|
||||
context.save();
|
||||
context.translate(imageObj.width/2,imageObj.height/2);
|
||||
context.rotate(degrees*Math.PI/180);
|
||||
context.drawImage(imageObj,-imageObj.width/2,-imageObj.height/2);
|
||||
|
||||
if (mirror) {
|
||||
context.scale(-1, 1);
|
||||
context.translate(-imageObj.width/2,imageObj.height/2);
|
||||
context.rotate(-degrees*Math.PI/180);
|
||||
context.drawImage(imageObj, imageObj.width/2,-imageObj.height/2, -imageObj.width, imageObj.height);
|
||||
}
|
||||
else {
|
||||
context.translate(imageObj.width/2,imageObj.height/2);
|
||||
context.rotate(degrees*Math.PI/180);
|
||||
context.drawImage(imageObj,-imageObj.width/2,-imageObj.height/2);
|
||||
}
|
||||
|
||||
context.restore();
|
||||
if (_grid == true && !isActReference){
|
||||
drawGrid();
|
||||
|
||||
@@ -38,7 +38,13 @@ function ParseConfigAlignment(_aktline){
|
||||
|
||||
while ((akt_ref < 2) && (_aktline < config_split.length) && (config_split[_aktline][0] != "[")) {
|
||||
var linesplit = ZerlegeZeile(config_split[_aktline]);
|
||||
if ((linesplit[0] == "InitalRotate") && (linesplit.length > 1))
|
||||
if ((linesplit[0].toUpperCase() == "INITIALMIRROR") && (linesplit.length > 1))
|
||||
{
|
||||
initalrotate["mirror"] = linesplit[1].toUpperCase().localeCompare("TRUE") == 0;
|
||||
initalrotate["pos_config_mirror"] = _aktline;
|
||||
}
|
||||
|
||||
if (((linesplit[0].toUpperCase() == "INITALROTATE") || (linesplit[0].toUpperCase() == "INITIALROTATE")) && (linesplit.length > 1))
|
||||
{
|
||||
initalrotate["angle"] = parseInt(linesplit[1]);
|
||||
initalrotate["pos_config"] = _aktline;
|
||||
@@ -131,7 +137,7 @@ function SaveROIToConfig(_ROIInfo, _typeROI, _basepath){
|
||||
config_split.push(zw);
|
||||
for (var j = config_split.length-2; j > _pos + 1; --j){
|
||||
config_split[j] = config_split[j-1];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (i = targetROI.length-1; i > _ROIInfo.length-1; --i){
|
||||
@@ -159,16 +165,16 @@ function ParseConfig() {
|
||||
var aktline = 0;
|
||||
|
||||
while (aktline < config_split.length){
|
||||
if (config_split[aktline].trim() == "[Alignment]") {
|
||||
if (config_split[aktline].trim().toUpperCase() == "[ALIGNMENT]") {
|
||||
aktline = ParseConfigAlignment(aktline);
|
||||
continue;
|
||||
}
|
||||
if (config_split[aktline].trim() == "[Digits]") {
|
||||
if (config_split[aktline].trim().toUpperCase() == "[DIGITS]") {
|
||||
aktline = ParseConfigDigit(aktline);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (config_split[aktline].trim() == "[Analog]") {
|
||||
if (config_split[aktline].trim().toUpperCase() == "[ANALOG]") {
|
||||
aktline = ParseConfigAnalog(aktline);
|
||||
continue;
|
||||
}
|
||||
@@ -185,6 +191,17 @@ function setPreRotate(_prerotate){
|
||||
initalrotate["angle"] = _prerotate;
|
||||
}
|
||||
|
||||
function getMirror(){
|
||||
if (initalrotate.hasOwnProperty("mirror")) {
|
||||
return initalrotate["mirror"];
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function setMirror(_mirror){
|
||||
initalrotate["mirror"] = _mirror;
|
||||
}
|
||||
|
||||
function SaveCanvasToImage(_canvas, _filename, _delete = true, _basepath = ""){
|
||||
var JPEG_QUALITY=0.8;
|
||||
var dataUrl = _canvas.toDataURL('image/jpeg', JPEG_QUALITY);
|
||||
@@ -198,7 +215,11 @@ function SaveCanvasToImage(_canvas, _filename, _delete = true, _basepath = ""){
|
||||
}
|
||||
|
||||
function SaveConfigToServer(_basepath){
|
||||
FileDeleteOnServer("/config/config.ini", _basepath);
|
||||
// leere Zeilen am Ende löschen
|
||||
var zw = config_split.length - 1;
|
||||
while (config_split[zw] == "") {
|
||||
config_split.pop();
|
||||
}
|
||||
|
||||
var config_gesamt = "";
|
||||
for (var i = 0; i < config_split.length; ++i)
|
||||
@@ -206,20 +227,60 @@ function SaveConfigToServer(_basepath){
|
||||
config_gesamt = config_gesamt + config_split[i] + "\n";
|
||||
}
|
||||
|
||||
FileDeleteOnServer("/config/config.ini", _basepath);
|
||||
|
||||
FileSendContent(config_gesamt, "/config/config.ini", _basepath);
|
||||
}
|
||||
|
||||
function UpdateConfigFile(_basepath){
|
||||
function UpdateConfigFileReferenceChange(_basepath){
|
||||
for (var _index = 0; _index < ref.length; ++_index){
|
||||
var zeile = ref[_index]["name"] + " " + ref[_index]["x"] + ", " + ref[_index]["y"];
|
||||
var _pos = ref[_index]["pos_ref"];
|
||||
config_split[_pos] = zeile;
|
||||
}
|
||||
|
||||
zeile = "InitalRotate=" + initalrotate["angle"];
|
||||
zeile = "InitialRotate = " + initalrotate["angle"];
|
||||
var _pos = initalrotate["pos_config"];
|
||||
config_split[_pos] = zeile;
|
||||
|
||||
var mirror = false;
|
||||
if (initalrotate.hasOwnProperty("mirror")) {
|
||||
mirror = initalrotate["mirror"];
|
||||
}
|
||||
var mirror_pos = -1;
|
||||
if (initalrotate.hasOwnProperty("pos_config_mirror")) {
|
||||
mirror_pos = initalrotate["pos_config_mirror"];
|
||||
}
|
||||
if (mirror_pos > -1) {
|
||||
if (mirror) {
|
||||
config_split[mirror_pos] = "InitialMirror = True";
|
||||
}
|
||||
else {
|
||||
config_split[mirror_pos] = "InitialMirror = False";
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (mirror) { // neue Zeile muss an der richtigen Stelle eingefügt werden - hier direct nach [Alignment]
|
||||
var aktline = 0;
|
||||
|
||||
while (aktline < config_split.length){
|
||||
if (config_split[aktline].trim() == "[Alignment]") {
|
||||
break;
|
||||
}
|
||||
aktline++
|
||||
}
|
||||
|
||||
// fuege neue Zeile in config_split ein
|
||||
var zw = config_split[config_split.length-1];
|
||||
config_split.push(zw);
|
||||
for (var j = config_split.length-2; j > aktline + 1; --j){
|
||||
config_split[j] = config_split[j-1];
|
||||
}
|
||||
|
||||
config_split[aktline + 1] = "InitialMirror = True"
|
||||
}
|
||||
}
|
||||
|
||||
SaveConfigToServer(_basepath);
|
||||
}
|
||||
|
||||
|
||||
@@ -66,7 +66,7 @@ function includeHTML() {
|
||||
</tr>
|
||||
<tr>
|
||||
<th class="th">
|
||||
Current Value:
|
||||
Checked Value:
|
||||
</th>
|
||||
</tr>
|
||||
<tr>
|
||||
|
||||
Reference in New Issue
Block a user