FACT++  1.0
FilterLed.h
Go to the documentation of this file.
1 #ifndef CAOS_FilterLed
2 #define CAOS_FilterLed
3 
4 #include <stdint.h>
5 #include <vector>
6 
7 class Led;
8 class Ring;
9 
10 class FilterLed
11 {
12  uint8_t *fImg;
13  int fW;
14  int fH;
15  int fBoxX;
16  int fBoxY;
17  float fCut;
18 
19  float FindCluster(int &cnt, float *sum, uint32_t x, uint32_t y,
20  uint32_t x0, uint32_t y0, uint32_t x1, uint32_t y1) const;
21 
22  void GetMinMax(const int offset, uint8_t *min, uint8_t *max) const;
23  int GetMeanPosition(const int x, const int y, const int boxx, const int boxy) const;
24  int GetMeanPosition(const int x, const int y, const int boxx, const int boxy,
25  float &mx, float &my, unsigned int &sum) const;
26 
27  int GetMeanPositionBox(const int x, const int y,
28  const int boxx, const int boxy) const;
29  int GetMeanPositionBox(const int x, const int y,
30  const int boxx, const int boxy, float &mx, float &my,
31  unsigned int &sum) const;
32 
33  void DrawBox(const int x1, const int y1,
34  const int x2, const int y2,
35  const int col) const;
36 
37 public:
38  FilterLed(uint8_t *img, int w, int h, double cut=2.5) : fImg(img),
39  fW(w), fH(h), fBoxX(w), fBoxY(h), fCut(cut)
40  {
41  }
42 
43  FilterLed(uint8_t *img, int w, int h, int boxx, int boxy, double cut=2.5) : fImg(img),
44  fW(w), fH(h), fBoxX(boxx), fBoxY(boxy), fCut(cut)
45  {
46  }
47  virtual ~FilterLed() { }
48 
49  void SetBox(int box) { fBoxX = fBoxY = box; }
50  void SetBox(int boxx, int boxy) { fBoxX = boxx; fBoxY = boxy; }
51  void SetCut(float cut) { fCut = cut; }
52  void FindStar(std::vector<Led> &leds, int xc, int yc, bool circle=false) const;
53 
54  void Execute(std::vector<Led> &leds, int xc, int yc, double &bright) const;
55  void Execute(std::vector<Led> &leds, int xc, int yc) const;
56  void Execute(std::vector<Led> &leds) const { Execute(leds, fW/2, fH/2); }
57 
58  void MarkPoint(const Led &led) const;
59  void MarkPoint(float x, float y, float mag) const;
60  void Stretch() const;
61 
62  void DrawCircle(float cx, float cy, float r, uint8_t col=0x40) const;
63  void DrawCircle(float r, uint8_t col=0x40) const { DrawCircle(fW/2, fH/2, r, col); }
64  void DrawCircle(const Ring &c, uint8_t col=0x40) const;
65  void DrawCircle(const Ring &c, double r, uint8_t col) const;
66  void DrawHexagon(float cx, float cy, float r, uint8_t col=0x40) const;
67  void DrawHexagon(const Ring &c, double r, uint8_t col) const;
68 };
69 
70 #endif
FilterLed(uint8_t *img, int w, int h, int boxx, int boxy, double cut=2.5)
Definition: FilterLed.h:43
void SetBox(int boxx, int boxy)
Definition: FilterLed.h:50
void Execute(std::vector< Led > &leds) const
Definition: FilterLed.h:56
int GetMeanPositionBox(const int x, const int y, const int boxx, const int boxy) const
Definition: FilterLed.cc:330
int fH
Definition: FilterLed.h:14
void MarkPoint(const Led &led) const
Definition: FilterLed.cc:166
void Stretch() const
Definition: FilterLed.cc:502
void SetCut(float cut)
Definition: FilterLed.h:51
float mag
Definition: HeadersSQM.h:89
void DrawCircle(float r, uint8_t col=0x40) const
Definition: FilterLed.h:63
Definition: Led.h:8
int fBoxY
Definition: FilterLed.h:16
void Execute(std::vector< Led > &leds, int xc, int yc, double &bright) const
Definition: FilterLed.cc:344
virtual ~FilterLed()
Definition: FilterLed.h:47
Definition: Ring.h:10
int fBoxX
Definition: FilterLed.h:15
void SetBox(int box)
Definition: FilterLed.h:49
void DrawBox(const int x1, const int y1, const int x2, const int y2, const int col) const
Definition: FilterLed.cc:147
float FindCluster(int &cnt, float *sum, uint32_t x, uint32_t y, uint32_t x0, uint32_t y0, uint32_t x1, uint32_t y1) const
FilterLed(uint8_t *img, int w, int h, double cut=2.5)
Definition: FilterLed.h:38
void DrawHexagon(float cx, float cy, float r, uint8_t col=0x40) const
Definition: FilterLed.cc:190
float fCut
Definition: FilterLed.h:17
int fW
Definition: FilterLed.h:13
void GetMinMax(const int offset, uint8_t *min, uint8_t *max) const
Definition: FilterLed.cc:210
void DrawCircle(float cx, float cy, float r, uint8_t col=0x40) const
Definition: FilterLed.cc:185
uint8_t * fImg
Definition: FilterLed.h:12
void FindStar(std::vector< Led > &leds, int xc, int yc, bool circle=false) const
Definition: FilterLed.cc:396
int GetMeanPosition(const int x, const int y, const int boxx, const int boxy) const
Definition: FilterLed.cc:270