Hi guys, I need some advice on how to go about scaling an interpolation routine for an AMG8833.
I am building a GUI using the GUISlice library and builder, and on one page I have a thermal cam.
I am using the code from Kris Kasprzak as it is simple, works well, and was easy to adapt for use with the GUISlice lib.
His code interpolates the 8x8 to a 70x70 grid, and each cell in the grid is 3x3 pixels, resulting in a picture size of 210 x 210. Unfortunately this size does not work for my GUI due to other buttons, taskbar ext.
I need something more along the lines of 180 x 250 or less, but also enough to make the most of the available space.
My very crude, poorly executed workaround was to change the number of rows and colomns to 60, and make each cell 3x4, giving me a picture size of 180 x 240.
Here is how it looks in my loop.
if (gslc_GetPageCur(&m_gui) == E_PG4) {
if (pauseThermal == false) {
float cursorTemp = (pixels [28] + pixels [29] + pixels [36] + pixels [37]) / 4;
snprintf(charCursTemp, 6, "%.2f", cursorTemp);
ThermalSensor.readPixels(pixels);
for (row = 0; row < 8; row ++) {
for (col = 0; col < 60; col ++) {
aLow = col / 10 + (row * 8);
aHigh = (col / 10) + 1 + (row * 8);
intPoint = (( pixels[aHigh] - pixels[aLow] ) / 10.0 );
incr = col % 10;
val = (intPoint * incr ) + pixels[aLow];
HDTemp[ (7 - row) * 10][col] = val;
}
}
for (col = 0; col < 60; col ++) {
for (row = 0; row < 60; row ++) {
aLow = (row / 10 ) * 10;
aHigh = aLow + 10;
intPoint = (( HDTemp[aHigh][col] - HDTemp[aLow][col] ) / 10.0 );
incr = row % 10;
val = (intPoint * incr ) + HDTemp[aLow][col];
HDTemp[ row ][col] = val;
}
}
for (row = 0; row < 60; row ++) {
if (ShowGrid < 0) {
BoxWidth = 3;
}
else {
if ((row % 10 == 9) ) {
BoxWidth = 2;
}
else {
BoxWidth = 3;
}
}
for (col = 0; col < 60; col++) {
if (ShowGrid < 0) {
BoxHeight = 4;
}
else {
if ( (col % 10 == 9)) {
BoxHeight = 2;
}
else {
BoxHeight = 3;
}
}
val = HDTemp[ row ][col];
red = constrain(255.0 / (c - b) * val - ((b * 255.0) / (c - b)), 0, 255);
if ((val > MinTemp) & (val < a)) {
green = constrain(255.0 / (a - MinTemp) * val - (255.0 * MinTemp) / (a - MinTemp), 0, 255);
}
else if ((val >= a) & (val <= c)) {
green = 255;
}
else if (val > c) {
green = constrain(255.0 / (c - d) * val - (d * 255.0) / (c - d), 0, 255);
}
else if ((val > d) | (val < a)) {
green = 0;
}
if (val <= b) {
blue = constrain(255.0 / (a - b) * val - (255.0 * b) / (a - b), 0, 255);
}
else if ((val > b) & (val <= d)) {
blue = 0;
}
else if (val > d) {
blue = constrain(240.0 / (MaxTemp - d) * val - (d * 240.0) / (MaxTemp - d), 0, 240);
}
gslc_tsRect rCamRect = { (col * 4) + 76, (row * 3) + 12, BoxHeight, BoxWidth};
gslc_tsColor nCamCol_rgb = { red, green, blue};
gslc_DrvDrawFillRect(&m_gui, rCamRect, nCamCol_rgb);
}
//gslc_DrvDrawTxt(&m_gui,190, 100,E_DOSIS_BOLD8,charCursTemp,0,cursorCol,0);
for (int j = 0; j < 3; j++) {
gslc_DrvDrawLine (&m_gui, 196 + j, 85, 196 + j, 115, nWhite);
gslc_DrvDrawLine (&m_gui, 181, 99 + j, 211, 99 + j, nWhite);
gslc_ElemSetTxtStr(&m_gui, m_pElemOutTxt23 , charCursTemp);
}
}
if (autoScale == true) {
SetTempScale();
}
snprintf(MinTempChar, 3, "%d", MinTemp);
gslc_ElemSetTxtStr(&m_gui, mintempBtn , MinTempChar);
snprintf(MaxTempChar, 3, "%d", MaxTemp);
gslc_ElemSetTxtStr(&m_gui, maxtempBtn, MaxTempChar);
}
}
I literally just changed every 70 to a 60, and changed the box size to 3 x 4, it works, but its obviously not the correct way to go (60 is not divisable by 7!) .
I believe the correct way to re-scale would be to change the interpolation from 10x10 to 8x8, so instead of a 70x70 I have 56x56, which can then be scaled to 168 x 224 by making each cell 3x4 pixels, and also speeding things up at the same time, as less calculations are being computed.
Unfortunately Im a bit stuck, and would appreciate some guidance implementing this. Ive played around a bit, but its a bit out of my league..
Any help would be appreciated.