Added Counter Clockwise option for analog dial.

This commit is contained in:
Anthony
2022-08-26 10:43:22 -04:00
parent aca60465f0
commit af546ef0f1
5 changed files with 29 additions and 10 deletions

View File

@@ -395,6 +395,7 @@ bool ClassFlowCNNGeneral::ReadParameter(FILE* pfile, string& aktparamgraph)
neuroi->posy = std::stoi(zerlegt[2]); neuroi->posy = std::stoi(zerlegt[2]);
neuroi->deltax = std::stoi(zerlegt[3]); neuroi->deltax = std::stoi(zerlegt[3]);
neuroi->deltay = std::stoi(zerlegt[4]); neuroi->deltay = std::stoi(zerlegt[4]);
neuroi->CCW = std::stoi(zerlegt[5]);
neuroi->result_float = -1; neuroi->result_float = -1;
neuroi->image = NULL; neuroi->image = NULL;
neuroi->image_org = NULL; neuroi->image_org = NULL;
@@ -680,7 +681,12 @@ bool ClassFlowCNNGeneral::doNeuralNetwork(string time)
f1 = tflite->GetOutputValue(0); f1 = tflite->GetOutputValue(0);
f2 = tflite->GetOutputValue(1); f2 = tflite->GetOutputValue(1);
float result = fmod(atan2(f1, f2) / (M_PI * 2) + 2, 1); float result = fmod(atan2(f1, f2) / (M_PI * 2) + 2, 1);
GENERAL[_ana]->ROI[i]->result_float = result * 10;
if(GENERAL[_ana]->ROI[i]->CCW)
GENERAL[_ana]->ROI[i]->result_float = 10 - (result * 10);
else
GENERAL[_ana]->ROI[i]->result_float = result * 10;
printf("Result General(Analog)%i: %f\n", i, GENERAL[_ana]->ROI[i]->result_float); printf("Result General(Analog)%i: %f\n", i, GENERAL[_ana]->ROI[i]->result_float);
if (isLogImage) if (isLogImage)
LogImage(logPath, GENERAL[_ana]->ROI[i]->name, &GENERAL[_ana]->ROI[i]->result_float, NULL, time, GENERAL[_ana]->ROI[i]->image_org); LogImage(logPath, GENERAL[_ana]->ROI[i]->name, &GENERAL[_ana]->ROI[i]->result_float, NULL, time, GENERAL[_ana]->ROI[i]->image_org);
@@ -872,8 +878,10 @@ bool ClassFlowCNNGeneral::doNeuralNetwork(string time)
_num = tflite->GetOutClassification(); _num = tflite->GetOutClassification();
GENERAL[_ana]->ROI[i]->result_float = (float)_num / 10.0; if(GENERAL[_ana]->ROI[i]->CCW)
GENERAL[_ana]->ROI[i]->result_float = 10 - ((float)_num / 10.0);
else
GENERAL[_ana]->ROI[i]->result_float = (float)_num / 10.0;
_result_save_file = GENERAL[_ana]->ROI[i]->result_float; _result_save_file = GENERAL[_ana]->ROI[i]->result_float;

View File

@@ -7,7 +7,7 @@ struct roi {
int posx, posy, deltax, deltay; int posx, posy, deltax, deltay;
float result_float; float result_float;
int result_klasse; int result_klasse;
bool isReject; bool isReject, CCW;
string name; string name;
CImageBasis *image, *image_org; CImageBasis *image, *image_org;
}; };

View File

@@ -116,11 +116,12 @@ th, td {
<tr> <tr>
<td>x: <input type="number" name="refx" id="refx" step=1 onchange="valuemanualchanged()" tabindex=2></td> <td>x: <input type="number" name="refx" id="refx" step=1 onchange="valuemanualchanged()" tabindex=2></td>
<td>dx: <input type="number" name="refdx" id="refdx" step=1 onchange="valuemanualchangeddx()" tabindex=4></td> <td>dx: <input type="number" name="refdx" id="refdx" step=1 onchange="valuemanualchangeddx()" tabindex=4></td>
<td rowspan="2"><label for="lockAR"> Lock aspect ratio: </label><input type="checkbox" id="lockAR" name="lockAR" value="1" onclick="changelockAR()" checked tabindex=6></td> <td rowspan="1"><label for="lockAR"> Lock aspect ratio: </label><input type="checkbox" id="lockAR" name="lockAR" value="1" onclick="changelockAR()" checked tabindex=6></td>
</tr> </tr>
<tr> <tr>
<td>y: <input type="number" name="refy" id="refy" step=1 onchange="valuemanualchanged()" tabindex=3></td> <td>y: <input type="number" name="refy" id="refy" step=1 onchange="valuemanualchanged()" tabindex=3></td>
<td>dy: <input type="number" name="refdy" id="refdy" step=1 onchange="valuemanualchanged()" tabindex=5></td> <td>dy: <input type="number" name="refdy" id="refdy" step=1 onchange="valuemanualchanged()" tabindex=5></td>
<td rowspan="1"><label for="CCW"> Counter-Clockwise Rotation: </label><input type="checkbox" id="CCW" name="CCW" value="0" onclick="changeCCW()" checked tabindex=6></td>
</tr> </tr>
</table> </table>
</div> </div>
@@ -146,6 +147,7 @@ th, td {
ROIInfo, ROIInfo,
enhanceCon = false; enhanceCon = false;
lockAR = true; lockAR = true;
CCW = false;
basepath = "http://192.168.178.26"; basepath = "http://192.168.178.26";
@@ -204,9 +206,9 @@ function newROI(){
var _roinew = prompt("Please enter name of new ROI", "name"); var _roinew = prompt("Please enter name of new ROI", "name");
if (ROIInfo.length > 0) if (ROIInfo.length > 0)
erg = CreateROI(_number, "analog", sel.selectedIndex, _roinew, 1, 1, ROIInfo[aktindex]["dx"], ROIInfo[aktindex]["dy"]); erg = CreateROI(_number, "analog", sel.selectedIndex, _roinew, 1, 1, ROIInfo[aktindex]["dx"], ROIInfo[aktindex]["dy"],ROIInfo[aktindex]["CCW"]);
else else
erg = CreateROI(_number, "analog", sel.selectedIndex, _roinew, 1, 1, 30, 30); erg = CreateROI(_number, "analog", sel.selectedIndex, _roinew, 1, 1, 30, 30, 0);
if (erg != "") if (erg != "")
alert(erg); alert(erg);
@@ -234,6 +236,10 @@ function changelockAR(){
lockAR = document.getElementById("lockAR").checked; lockAR = document.getElementById("lockAR").checked;
} }
function changeCCW(){
CCW = document.getElementById("CCW").checked;
}
function ChangeSelection(){ function ChangeSelection(){
aktindex = parseInt(document.getElementById("index").value); aktindex = parseInt(document.getElementById("index").value);
// lockAR = true; // lockAR = true;
@@ -315,6 +321,7 @@ function UpdateROIs(){
} }
document.getElementById("lockAR").checked = lockAR; document.getElementById("lockAR").checked = lockAR;
document.getElementById("CCW").checked = CCW;
document.getElementById("refx").value = ROIInfo[aktindex]["x"]; document.getElementById("refx").value = ROIInfo[aktindex]["x"];
document.getElementById("refy").value = ROIInfo[aktindex]["y"]; document.getElementById("refy").value = ROIInfo[aktindex]["y"];

View File

@@ -197,9 +197,9 @@ function newROI() {
var _roinew = prompt("Please enter name of new ROI", "name"); var _roinew = prompt("Please enter name of new ROI", "name");
if (ROIInfo.length > 0) if (ROIInfo.length > 0)
erg = CreateROI(_number, "digit", sel.selectedIndex, _roinew, 1, 1, ROIInfo[aktindex]["dx"], ROIInfo[aktindex]["dy"]); erg = CreateROI(_number, "digit", sel.selectedIndex, _roinew, 1, 1, ROIInfo[aktindex]["dx"], ROIInfo[aktindex]["dy"], 0);
else else
erg = CreateROI(_number, "digit", sel.selectedIndex, _roinew, 1, 1, 30, 51); erg = CreateROI(_number, "digit", sel.selectedIndex, _roinew, 1, 1, 30, 51, 0);
if (erg != "") if (erg != "")
alert(erg); alert(erg);

View File

@@ -398,6 +398,7 @@ function WriteConfigININew()
text = text + " " + NUMBERS[_roi]["digit"][_roiddet]["y"]; text = text + " " + NUMBERS[_roi]["digit"][_roiddet]["y"];
text = text + " " + NUMBERS[_roi]["digit"][_roiddet]["dx"]; text = text + " " + NUMBERS[_roi]["digit"][_roiddet]["dx"];
text = text + " " + NUMBERS[_roi]["digit"][_roiddet]["dy"]; text = text + " " + NUMBERS[_roi]["digit"][_roiddet]["dy"];
text = text + " " + NUMBERS[_roi]["digit"][_roiddet]["CCW"];
config_split.push(text); config_split.push(text);
} }
} }
@@ -416,6 +417,7 @@ function WriteConfigININew()
text = text + " " + NUMBERS[_roi]["analog"][_roiddet]["y"]; text = text + " " + NUMBERS[_roi]["analog"][_roiddet]["y"];
text = text + " " + NUMBERS[_roi]["analog"][_roiddet]["dx"]; text = text + " " + NUMBERS[_roi]["analog"][_roiddet]["dx"];
text = text + " " + NUMBERS[_roi]["analog"][_roiddet]["dy"]; text = text + " " + NUMBERS[_roi]["analog"][_roiddet]["dy"];
text = text + " " + NUMBERS[_roi]["analog"][_roiddet]["CCW"];
config_split.push(text); config_split.push(text);
} }
} }
@@ -484,6 +486,7 @@ function ExtractROIs(_aktline, _type){
abc["dx"] = linesplit[3]; abc["dx"] = linesplit[3];
abc["dy"] = linesplit[4]; abc["dy"] = linesplit[4];
abc["ar"] = parseFloat(linesplit[3]) / parseFloat(linesplit[4]); abc["ar"] = parseFloat(linesplit[3]) / parseFloat(linesplit[4]);
abc["CCW"] = linesplit[5];
} }
@@ -712,7 +715,7 @@ function DeleteNUMBER(_delte){
return ""; return "";
} }
function CreateROI(_number, _type, _pos, _roinew, _x, _y, _dx, _dy){ function CreateROI(_number, _type, _pos, _roinew, _x, _y, _dx, _dy, _CCW){
_indexnumber = -1; _indexnumber = -1;
for (j = 0; j < NUMBERS.length; ++j) for (j = 0; j < NUMBERS.length; ++j)
if (NUMBERS[j]["name"] == _number) if (NUMBERS[j]["name"] == _number)
@@ -735,6 +738,7 @@ function CreateROI(_number, _type, _pos, _roinew, _x, _y, _dx, _dy){
_ret["dx"] = _dx; _ret["dx"] = _dx;
_ret["dy"] = _dy; _ret["dy"] = _dy;
_ret["ar"] = _dx / _dy; _ret["ar"] = _dx / _dy;
_ret["CCW"] = _CCW;
NUMBERS[_indexnumber][_type].splice(_pos+1, 0, _ret); NUMBERS[_indexnumber][_type].splice(_pos+1, 0, _ret);