CFindTemplate.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #pragma once
  2. #ifndef CFINDTEMPLATE_H
  3. #define CFINDTEMPLATE_H
  4. #include "CImageBasis.h"
  5. struct RefInfo
  6. {
  7. std::string image_file;
  8. int target_x = 0; // X-coordinate of the alignment image
  9. int target_y = 0; // Y-coordinate of the alignment image
  10. int width = 0; // Width of the alignment image
  11. int height = 0; // Height of the alignment image
  12. int search_x; // X-size (width) in which the reference is searched
  13. int search_y; // Y-size (height) in which the reference is searched
  14. float search_max_angle; // Max rotation angle in which the reference is searched
  15. int found_x;
  16. int found_y;
  17. int fastalg_x = -1;
  18. int fastalg_y = -1;
  19. int fastalg_min = -256;
  20. float fastalg_avg = -1;
  21. int fastalg_max = -1;
  22. float fastalg_SAD = -1;
  23. float fastalg_SAD_criteria = -1;
  24. int alignment_algo = 0; // 0 = "Default" (nur R-Kanal), 1 = "HighAccuracy" (RGB-Kanal), 2 = "Fast" (1.x RGB, dann isSimilar)
  25. };
  26. class CFindTemplate : public CImageBasis
  27. {
  28. public:
  29. int tpl_width, tpl_height, tpl_bpp;
  30. #define Fast_Alignment_OK 1
  31. #define Alignment_OK 0
  32. #define Alignment_Failed -1
  33. #define Rotation_Alignment_Failed -2
  34. #define Shift_Alignment_Failed -3
  35. CFindTemplate(std::string name, uint8_t *_rgb_image, int _channels, int _width, int _height, int _bpp) : CImageBasis(name, _rgb_image, _channels, _width, _height, _bpp) {};
  36. bool FindTemplate(RefInfo *_ref);
  37. bool CalculateSimularities(uint8_t *_rgb_tmpl, int _startx, int _starty, int _sizex, int _sizey, int &min, float &avg, int &max, float &SAD, float _SADold, float _SADcrit);
  38. };
  39. #endif // CFINDTEMPLATE_H