mirror of
https://github.com/jomjol/AI-on-the-edge-device.git
synced 2025-12-07 12:06:58 +03:00
Merge branch 'jomjol:rolling' into rolling
This commit is contained in:
@@ -52,7 +52,11 @@ In other cases you can contact the developer via email: <img src="https://raw.gi
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
##### Rolling (2022-06-18)
|
##### Rolling (2022-06-26)
|
||||||
|
|
||||||
|
- Internal update (Neural Network Algo)
|
||||||
|
|
||||||
|
Rolling (2022-06-18)
|
||||||
|
|
||||||
- Internal update (Neural Network Algo)
|
- Internal update (Neural Network Algo)
|
||||||
|
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ void ClassFlowAlignment::SetInitialParameter(void)
|
|||||||
initalrotate = 0;
|
initalrotate = 0;
|
||||||
anz_ref = 0;
|
anz_ref = 0;
|
||||||
initialmirror = false;
|
initialmirror = false;
|
||||||
|
use_antialiasing = false;
|
||||||
initialflip = false;
|
initialflip = false;
|
||||||
SaveAllFiles = false;
|
SaveAllFiles = false;
|
||||||
namerawimage = "/sdcard/img_tmp/raw.jpg";
|
namerawimage = "/sdcard/img_tmp/raw.jpg";
|
||||||
@@ -94,7 +95,12 @@ bool ClassFlowAlignment::ReadParameter(FILE* pfile, string& aktparamgraph)
|
|||||||
if ((toUpper(zerlegt[0]) == "SEARCHFIELDY") && (zerlegt.size() > 1))
|
if ((toUpper(zerlegt[0]) == "SEARCHFIELDY") && (zerlegt.size() > 1))
|
||||||
{
|
{
|
||||||
suchey = std::stod(zerlegt[1]);
|
suchey = std::stod(zerlegt[1]);
|
||||||
}
|
}
|
||||||
|
if ((toUpper(zerlegt[0]) == "ANTIALIASING") && (zerlegt.size() > 1))
|
||||||
|
{
|
||||||
|
if (toUpper(zerlegt[1]) == "TRUE")
|
||||||
|
use_antialiasing = true;
|
||||||
|
}
|
||||||
if ((zerlegt.size() == 3) && (anz_ref < 2))
|
if ((zerlegt.size() == 3) && (anz_ref < 2))
|
||||||
{
|
{
|
||||||
References[anz_ref].image_file = FormatFileName("/sdcard" + zerlegt[0]);
|
References[anz_ref].image_file = FormatFileName("/sdcard" + zerlegt[0]);
|
||||||
@@ -175,7 +181,10 @@ bool ClassFlowAlignment::doFlow(string time)
|
|||||||
|
|
||||||
if ((initalrotate != 0) || initialflip)
|
if ((initalrotate != 0) || initialflip)
|
||||||
{
|
{
|
||||||
rt.Rotate(initalrotate);
|
if (use_antialiasing)
|
||||||
|
rt.RotateAntiAliasing(initalrotate);
|
||||||
|
else
|
||||||
|
rt.Rotate(initalrotate);
|
||||||
if (SaveAllFiles) AlignAndCutImage->SaveToFile(FormatFileName("/sdcard/img_tmp/rot.jpg"));
|
if (SaveAllFiles) AlignAndCutImage->SaveToFile(FormatFileName("/sdcard/img_tmp/rot.jpg"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ protected:
|
|||||||
float initalrotate;
|
float initalrotate;
|
||||||
bool initialmirror;
|
bool initialmirror;
|
||||||
bool initialflip;
|
bool initialflip;
|
||||||
|
bool use_antialiasing;
|
||||||
RefInfo References[2];
|
RefInfo References[2];
|
||||||
int anz_ref;
|
int anz_ref;
|
||||||
string namerawimage;
|
string namerawimage;
|
||||||
|
|||||||
@@ -156,12 +156,140 @@ void CRotateImage::Rotate(float _angle, int _centerx, int _centery)
|
|||||||
RGBImageRelease();
|
RGBImageRelease();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void CRotateImage::RotateAntiAliasing(float _angle, int _centerx, int _centery)
|
||||||
|
{
|
||||||
|
int org_width, org_height;
|
||||||
|
float m[2][3];
|
||||||
|
|
||||||
|
float x_center = _centerx;
|
||||||
|
float y_center = _centery;
|
||||||
|
_angle = _angle / 180 * M_PI;
|
||||||
|
|
||||||
|
if (doflip)
|
||||||
|
{
|
||||||
|
org_width = width;
|
||||||
|
org_height = height;
|
||||||
|
height = org_width;
|
||||||
|
width = org_height;
|
||||||
|
x_center = x_center - (org_width/2) + (org_height/2);
|
||||||
|
y_center = y_center + (org_width/2) - (org_height/2);
|
||||||
|
if (ImageOrg)
|
||||||
|
{
|
||||||
|
ImageOrg->height = height;
|
||||||
|
ImageOrg->width = width;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
org_width = width;
|
||||||
|
org_height = height;
|
||||||
|
}
|
||||||
|
|
||||||
|
m[0][0] = cos(_angle);
|
||||||
|
m[0][1] = sin(_angle);
|
||||||
|
m[0][2] = (1 - m[0][0]) * x_center - m[0][1] * y_center;
|
||||||
|
|
||||||
|
m[1][0] = -m[0][1];
|
||||||
|
m[1][1] = m[0][0];
|
||||||
|
m[1][2] = m[0][1] * x_center + (1 - m[0][0]) * y_center;
|
||||||
|
|
||||||
|
if (doflip)
|
||||||
|
{
|
||||||
|
m[0][2] = m[0][2] + (org_width/2) - (org_height/2);
|
||||||
|
m[1][2] = m[1][2] - (org_width/2) + (org_height/2);
|
||||||
|
}
|
||||||
|
|
||||||
|
int memsize = width * height * channels;
|
||||||
|
uint8_t* odata;
|
||||||
|
if (ImageTMP)
|
||||||
|
{
|
||||||
|
odata = ImageTMP->RGBImageLock();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
odata = (unsigned char*)GET_MEMORY(memsize);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int x_source_1, y_source_1, x_source_2, y_source_2;
|
||||||
|
float x_source, y_source;
|
||||||
|
float quad_ul, quad_ur, quad_ol, quad_or;
|
||||||
|
stbi_uc* p_target;
|
||||||
|
stbi_uc *p_source_ul, *p_source_ur, *p_source_ol, *p_source_or;
|
||||||
|
|
||||||
|
RGBImageLock();
|
||||||
|
|
||||||
|
for (int x = 0; x < width; ++x)
|
||||||
|
for (int y = 0; y < height; ++y)
|
||||||
|
{
|
||||||
|
p_target = odata + (channels * (y * width + x));
|
||||||
|
|
||||||
|
x_source = (m[0][0] * x + m[0][1] * y);
|
||||||
|
y_source = (m[1][0] * x + m[1][1] * y);
|
||||||
|
|
||||||
|
x_source += (m[0][2]);
|
||||||
|
y_source += (m[1][2]);
|
||||||
|
|
||||||
|
x_source_1 = (int)x_source;
|
||||||
|
x_source_2 = x_source_1 + 1;
|
||||||
|
y_source_1 = (int)y_source;
|
||||||
|
y_source_2 = y_source_1 + 1;
|
||||||
|
|
||||||
|
quad_ul = (x_source_2 - x_source) * (y_source_2 - y_source);
|
||||||
|
quad_ur = (1- (x_source_2 - x_source)) * (y_source_2 - y_source);
|
||||||
|
quad_or = (x_source_2 - x_source) * (1-(y_source_2 - y_source));
|
||||||
|
quad_ol = (1- (x_source_2 - x_source)) * (1-(y_source_2 - y_source));
|
||||||
|
|
||||||
|
|
||||||
|
if ((x_source_1 >= 0) && (x_source_2 < org_width) && (y_source_1 >= 0) && (y_source_2 < org_height))
|
||||||
|
{
|
||||||
|
p_source_ul = rgb_image + (channels * (y_source_1 * org_width + x_source_1));
|
||||||
|
p_source_ur = rgb_image + (channels * (y_source_1 * org_width + x_source_2));
|
||||||
|
p_source_or = rgb_image + (channels * (y_source_2 * org_width + x_source_1));
|
||||||
|
p_source_ol = rgb_image + (channels * (y_source_2 * org_width + x_source_2));
|
||||||
|
for (int _channels = 0; _channels < channels; ++_channels)
|
||||||
|
{
|
||||||
|
p_target[_channels] = (int)((float)p_source_ul[_channels] * quad_ul
|
||||||
|
+ (float)p_source_ur[_channels] * quad_ur
|
||||||
|
+ (float)p_source_or[_channels] * quad_or
|
||||||
|
+ (float)p_source_ol[_channels] * quad_ol);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for (int _channels = 0; _channels < channels; ++_channels)
|
||||||
|
p_target[_channels] = 255;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// memcpy(rgb_image, odata, memsize);
|
||||||
|
memCopy(odata, rgb_image, memsize);
|
||||||
|
|
||||||
|
if (!ImageTMP)
|
||||||
|
{
|
||||||
|
stbi_image_free(odata);
|
||||||
|
}
|
||||||
|
if (ImageTMP)
|
||||||
|
ImageTMP->RGBImageRelease();
|
||||||
|
|
||||||
|
RGBImageRelease();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void CRotateImage::Rotate(float _angle)
|
void CRotateImage::Rotate(float _angle)
|
||||||
{
|
{
|
||||||
// printf("width %d, height %d\n", width, height);
|
// printf("width %d, height %d\n", width, height);
|
||||||
Rotate(_angle, width / 2, height / 2);
|
Rotate(_angle, width / 2, height / 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CRotateImage::RotateAntiAliasing(float _angle)
|
||||||
|
{
|
||||||
|
// printf("width %d, height %d\n", width, height);
|
||||||
|
RotateAntiAliasing(_angle, width / 2, height / 2);
|
||||||
|
}
|
||||||
|
|
||||||
void CRotateImage::Translate(int _dx, int _dy)
|
void CRotateImage::Translate(int _dx, int _dy)
|
||||||
{
|
{
|
||||||
int memsize = width * height * channels;
|
int memsize = width * height * channels;
|
||||||
|
|||||||
@@ -11,7 +11,11 @@ class CRotateImage: public CImageBasis
|
|||||||
CRotateImage(CImageBasis *_org, CImageBasis *_temp, bool _flip = false);
|
CRotateImage(CImageBasis *_org, CImageBasis *_temp, bool _flip = false);
|
||||||
|
|
||||||
void Rotate(float _angle);
|
void Rotate(float _angle);
|
||||||
|
void RotateAntiAliasing(float _angle);
|
||||||
|
|
||||||
void Rotate(float _angle, int _centerx, int _centery);
|
void Rotate(float _angle, int _centerx, int _centery);
|
||||||
|
void RotateAntiAliasing(float _angle, int _centerx, int _centery);
|
||||||
|
|
||||||
void Translate(int _dx, int _dy);
|
void Translate(int _dx, int _dy);
|
||||||
void Mirror();
|
void Mirror();
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
const char* GIT_REV="35a9602";
|
const char* GIT_REV="60cdee2";
|
||||||
const char* GIT_TAG="";
|
const char* GIT_TAG="";
|
||||||
const char* GIT_BRANCH="rolling";
|
const char* GIT_BRANCH="rolling";
|
||||||
const char* BUILD_TIME="2022-06-18 15:11";
|
const char* BUILD_TIME="2022-06-26 21:24";
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
const char* GIT_REV="35a9602";
|
const char* GIT_REV="60cdee2";
|
||||||
const char* GIT_TAG="";
|
const char* GIT_TAG="";
|
||||||
const char* GIT_BRANCH="rolling";
|
const char* GIT_BRANCH="rolling";
|
||||||
const char* BUILD_TIME="2022-06-18 15:11";
|
const char* BUILD_TIME="2022-06-26 21:23";
|
||||||
Binary file not shown.
BIN
firmware/dhy0500s3DropOut-10erq.tflite
Normal file
BIN
firmware/dhy0500s3DropOut-10erq.tflite
Normal file
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user