mirror of
https://github.com/jomjol/AI-on-the-edge-device.git
synced 2025-12-08 20:46:52 +03:00
Inital
This commit is contained in:
@@ -15,12 +15,18 @@
|
||||
#include "stb_image_resize.h"
|
||||
|
||||
|
||||
#define MAX_JPG_SIZE 128000
|
||||
|
||||
struct ImageData
|
||||
{
|
||||
uint8_t data[MAX_JPG_SIZE];
|
||||
size_t size = 0;
|
||||
};
|
||||
|
||||
|
||||
class CImageBasis
|
||||
{
|
||||
protected:
|
||||
uint8_t* rgb_image;
|
||||
int channels;
|
||||
int width, height, bpp;
|
||||
bool externalImage;
|
||||
std::string filename;
|
||||
|
||||
@@ -28,6 +34,10 @@ class CImageBasis
|
||||
bool isInImage(int x, int y);
|
||||
|
||||
public:
|
||||
uint8_t* rgb_image;
|
||||
int channels;
|
||||
int width, height, bpp;
|
||||
|
||||
int getWidth(){return this->width;};
|
||||
int getHeight(){return this->height;};
|
||||
int getChannels(){return this->channels;};
|
||||
@@ -37,11 +47,22 @@ class CImageBasis
|
||||
void setPixelColor(int x, int y, int r, int g, int b);
|
||||
void Contrast(float _contrast);
|
||||
bool ImageOkay();
|
||||
bool CopyFromMemory(uint8_t* _source, int _size);
|
||||
|
||||
void SetIndepended(){externalImage = false;};
|
||||
|
||||
void CreateEmptyImage(int _width, int _height, int _channels);
|
||||
|
||||
|
||||
CImageBasis();
|
||||
CImageBasis(std::string _image);
|
||||
CImageBasis(uint8_t* _rgb_image, int _channels, int _width, int _height, int _bpp);
|
||||
CImageBasis(CImageBasis *_copyfrom);
|
||||
|
||||
void LoadFromMemory(stbi_uc *_buffer, int len);
|
||||
|
||||
ImageData* writeToMemoryAsJPG(const int quality = 90);
|
||||
|
||||
uint8_t GetPixelColor(int x, int y, int ch);
|
||||
|
||||
~CImageBasis();
|
||||
@@ -53,7 +74,9 @@ class CFindTemplate : public CImageBasis
|
||||
{
|
||||
public:
|
||||
int tpl_width, tpl_height, tpl_bpp;
|
||||
CFindTemplate(std::string _image);
|
||||
// CFindTemplate(std::string _image);
|
||||
CFindTemplate(uint8_t* _rgb_image, int _channels, int _width, int _height, int _bpp) : CImageBasis(_rgb_image, _channels, _width, _height, _bpp) {};
|
||||
|
||||
|
||||
void FindTemplate(std::string _template, int* found_x, int* found_y, std::string _imageout);
|
||||
void FindTemplate(std::string _template, int* found_x, int* found_y, int _dx, int _dy, std::string _imageout);
|
||||
@@ -64,8 +87,10 @@ class CFindTemplate : public CImageBasis
|
||||
class CRotate: public CImageBasis
|
||||
{
|
||||
public:
|
||||
CRotate(std::string _image) : CImageBasis(_image) {};
|
||||
CRotate(uint8_t* _rgb_image, int _channels, int _width, int _height, int _bpp) : CImageBasis(_rgb_image, _channels, _width, _height, _bpp) {};
|
||||
CImageBasis *ImageTMP;
|
||||
CRotate(std::string _image) : CImageBasis(_image) {ImageTMP = NULL;};
|
||||
CRotate(uint8_t* _rgb_image, int _channels, int _width, int _height, int _bpp) : CImageBasis(_rgb_image, _channels, _width, _height, _bpp) {ImageTMP = NULL;};
|
||||
CRotate(CImageBasis *_org, CImageBasis *_temp);
|
||||
|
||||
void Rotate(float _angle);
|
||||
void Rotate(float _angle, int _centerx, int _centery);
|
||||
@@ -74,25 +99,33 @@ class CRotate: public CImageBasis
|
||||
};
|
||||
|
||||
|
||||
class CAlignAndCutImage : public CImageBasis
|
||||
{
|
||||
public:
|
||||
int t0_dx, t0_dy, t1_dx, t1_dy;
|
||||
CAlignAndCutImage(std::string _image) : CImageBasis(_image) {};
|
||||
|
||||
void Align(std::string _template1, int x1, int y1, std::string _template2, int x2, int y2, int deltax = 40, int deltay = 40, std::string imageROI = "");
|
||||
void CutAndSave(std::string _template1, int x1, int y1, int dx, int dy);
|
||||
};
|
||||
|
||||
|
||||
class CResizeImage : public CImageBasis
|
||||
{
|
||||
public:
|
||||
CResizeImage(std::string _image) : CImageBasis(_image) {};
|
||||
CResizeImage(uint8_t* _rgb_image, int _channels, int _width, int _height, int _bpp) : CImageBasis(_rgb_image, _channels, _width, _height, _bpp) {};
|
||||
|
||||
// CResizeImage(std::string _image, int _new_dx, int _new_dy);
|
||||
void Resize(int _new_dx, int _new_dy);
|
||||
};
|
||||
|
||||
|
||||
|
||||
class CAlignAndCutImage : public CImageBasis
|
||||
{
|
||||
public:
|
||||
int t0_dx, t0_dy, t1_dx, t1_dy;
|
||||
CImageBasis *ImageTMP;
|
||||
CAlignAndCutImage(std::string _image) : CImageBasis(_image) {ImageTMP = NULL;};
|
||||
CAlignAndCutImage(uint8_t* _rgb_image, int _channels, int _width, int _height, int _bpp) : CImageBasis(_rgb_image, _channels, _width, _height, _bpp) {ImageTMP = NULL;};
|
||||
CAlignAndCutImage(CImageBasis *_org, CImageBasis *_temp);
|
||||
|
||||
void Align(std::string _template1, int x1, int y1, std::string _template2, int x2, int y2, int deltax = 40, int deltay = 40, std::string imageROI = "");
|
||||
void CutAndSave(std::string _template1, int x1, int y1, int dx, int dy);
|
||||
CResizeImage* CutAndSave(int x1, int y1, int dx, int dy);
|
||||
void GetRefSize(int *ref_dx, int *ref_dy);
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
Reference in New Issue
Block a user