source: branches/FACT++_lidctrl_usb/drive/FilterLed.h

Last change on this file was 18621, checked in by tbretz, 8 years ago
Removed references to root, replaced with basic types.
File size: 2.4 KB
Line 
1#ifndef CAOS_FilterLed
2#define CAOS_FilterLed
3
4#include <stdint.h>
5#include <vector>
6
7class Led;
8class Ring;
9
10class 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
37public:
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
Note: See TracBrowser for help on using the repository browser.