mirror of
https://github.com/jomjol/AI-on-the-edge-device.git
synced 2025-12-08 20:46:52 +03:00
88 lines
2.3 KiB
Plaintext
88 lines
2.3 KiB
Plaintext
#pragma once
|
|
|
|
|
|
#ifndef __CFINDTEMPLATE
|
|
#define __CFINGTEMPLATE
|
|
|
|
#include <stdint.h>
|
|
#include <string>
|
|
|
|
#define _USE_MATH_DEFINES
|
|
#include <math.h>
|
|
|
|
#include <esp_heap_caps.h>
|
|
|
|
#include "stb_image.h"
|
|
#include "stb_image_write.h"
|
|
#include "stb_image_resize.h"
|
|
|
|
|
|
|
|
class CImageBasis
|
|
{
|
|
protected:
|
|
uint8_t* rgb_image;
|
|
int channels;
|
|
int width, height, bpp;
|
|
bool externalImage;
|
|
std::string filename;
|
|
|
|
void memCopy(uint8_t* _source, uint8_t* _target, int _size);
|
|
public:
|
|
int getWidth(){return this->width;};
|
|
int getHeight(){return this->width;};
|
|
int getChannels(){return this->channels;};
|
|
|
|
CImageBasis();
|
|
CImageBasis(std::string _image);
|
|
CImageBasis(uint8_t* _rgb_image, int _channels, int _width, int _height, int _bpp);
|
|
uint8_t GetPixelColor(int x, int y, int ch);
|
|
|
|
~CImageBasis();
|
|
|
|
void SaveToFile(std::string _imageout);
|
|
};
|
|
|
|
class CFindTemplate : public CImageBasis
|
|
{
|
|
public:
|
|
CFindTemplate(std::string _image);
|
|
|
|
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);
|
|
void FindTemplate(std::string _template, int* found_x, int* found_y);
|
|
void FindTemplate(std::string _template, int* found_x, int* found_y, int _dx, int _dy);
|
|
};
|
|
|
|
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) {};
|
|
|
|
void Rotate(float _angle);
|
|
void Rotate(float _angle, int _centerx, int _centery);
|
|
void Translate(int _dx, int _dy);
|
|
};
|
|
|
|
|
|
class CAlignAndCutImage : public CImageBasis
|
|
{
|
|
public:
|
|
CAlignAndCutImage(std::string _image) : CImageBasis(_image) {};
|
|
|
|
void Align(std::string _template0, int ref0_x, int ref0_y, std::string _template1, int ref1_x, int ref1_y, int deltax, int deltay);
|
|
void CutAndSave(std::string _template1, int x1, int y1, int dx, int dy);
|
|
};
|
|
|
|
|
|
class CResizeImage : public CImageBasis
|
|
{
|
|
public:
|
|
CResizeImage(std::string _image) : CImageBasis(_image) {};
|
|
void Resize(int _new_dx, int _new_dy);
|
|
};
|
|
|
|
#endif
|
|
|