Changeset 9439 for trunk/MagicSoft/Cosy/videodev
- Timestamp:
- 05/09/09 13:48:12 (16 years ago)
- Location:
- trunk/MagicSoft/Cosy/videodev
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Cosy/videodev/FilterLed.cc
r8869 r9439 247 247 248 248 int FilterLed::GetMeanPosition(const int x, const int y, 249 const int box, float &mx, float &my, unsigned int &sum) const 249 const int boxx, const int boxy, 250 float &mx, float &my, unsigned int &sum) const 250 251 { 251 252 unsigned int sumx=0; … … 253 254 254 255 sum=0; 255 for (int dx=x-box ; dx<x+box+1; dx++)256 for (int dy=y-box ; dy<y+box+1; dy++)256 for (int dx=x-boxx; dx<x+boxx+1; dx++) 257 for (int dy=y-boxy; dy<y+boxy+1; dy++) 257 258 { 258 259 const byte &m = fImg[dy*fW+dx]; … … 269 270 } 270 271 271 int FilterLed::GetMeanPosition(const int x, const int y, const int box ) const272 int FilterLed::GetMeanPosition(const int x, const int y, const int boxx, const int boxy) const 272 273 { 273 274 float mx, my; 274 275 unsigned int sum; 275 return GetMeanPosition(x, y, box , mx, my, sum);276 return GetMeanPosition(x, y, boxx, boxy, mx, my, sum); 276 277 } 277 278 278 279 int FilterLed::GetMeanPositionBox(const int x, const int y, 279 const int box , float &mx,280 float &m y, unsigned int &sum) const280 const int boxx, const int boxy, 281 float &mx, float &my, unsigned int &sum) const 281 282 { 282 283 //------------------------------- 283 284 // Improved algorithm: 284 285 // 1. Look for the largest five-pixel-cross signal inside the box 285 int x0 = TMath::Max(x-box +1, 0);286 int y0 = TMath::Max(y-box +1, 0);287 288 int x1 = TMath::Min(x+box +1-1, fW);289 int y1 = TMath::Min(y+box +1-1, fH);286 int x0 = TMath::Max(x-boxx+1, 0); 287 int y0 = TMath::Max(y-boxy+1, 0); 288 289 int x1 = TMath::Min(x+boxx+1-1, fW); 290 int y1 = TMath::Min(y+boxy+1-1, fH); 290 291 291 292 int maxx=0; … … 330 331 331 332 int FilterLed::GetMeanPositionBox(const int x, const int y, 332 const int box ) const333 const int boxx, const int boxy) const 333 334 { 334 335 float mx, my; 335 336 unsigned int sum; 336 return GetMeanPositionBox(x, y, box , mx, my, sum);337 return GetMeanPositionBox(x, y, boxx, boxy, mx, my, sum); 337 338 } 338 339 … … 374 375 void FilterLed::Execute(Leds &leds, int xc, int yc, double &bright) const 375 376 { 376 const int x0 = TMath::Max(xc-fBox , 0);377 const int y0 = TMath::Max(yc-fBox , 0);378 const int x1 = TMath::Min(xc+fBox , fW);379 const int y1 = TMath::Min(yc+fBox , fH);377 const int x0 = TMath::Max(xc-fBoxX, 0); 378 const int y0 = TMath::Max(yc-fBoxY, 0); 379 const int x1 = TMath::Min(xc+fBoxX, fW); 380 const int y1 = TMath::Min(yc+fBoxY, fH); 380 381 381 382 const int wx = x1-x0; … … 432 433 // Define inner box in which to search the signal 433 434 // 434 const int x0 = TMath::Max(xc-fBox , 0);435 const int y0 = TMath::Max(yc-fBox , 0);436 const int x1 = TMath::Min(xc+fBox , fW);437 const int y1 = TMath::Min(yc+fBox , fH);435 const int x0 = TMath::Max(xc-fBoxX, 0); 436 const int y0 = TMath::Max(yc-fBoxY, 0); 437 const int x1 = TMath::Min(xc+fBoxX, fW); 438 const int y1 = TMath::Min(yc+fBoxY, fH); 438 439 439 440 // … … 444 445 const double sqrt2 = sqrt(2.); 445 446 446 const int xa = TMath::Max(xc- (int)rint(fBox*sqrt2), 0);447 const int ya = TMath::Max(yc- (int)rint(fBox*sqrt2), 0);448 const int xb = TMath::Min(xc+ (int)rint(fBox*sqrt2), fW);449 const int yb = TMath::Min(yc+ (int)rint(fBox*sqrt2), fH);447 const int xa = TMath::Max(xc-TMath::Nint(fBoxX*sqrt2), 0); 448 const int ya = TMath::Max(yc-TMath::Nint(fBoxY*sqrt2), 0); 449 const int xb = TMath::Min(xc+TMath::Nint(fBoxX*sqrt2), fW); 450 const int yb = TMath::Min(yc+TMath::Nint(fBoxY*sqrt2), fH); 450 451 451 452 // … … 518 519 float mx, my; 519 520 unsigned int mag; 520 int pos = box ? GetMeanPositionBox(xc, yc, fBox-1, mx, my, mag) : GetMeanPosition(xc, yc, fBox-1, mx, my, mag); 521 int pos = box ? GetMeanPositionBox(xc, yc, fBoxX-1, fBoxY-1, mx, my, mag) 522 : GetMeanPosition(xc, yc, fBoxX-1, fBoxY-1, mx, my, mag); 521 523 522 524 if (pos<0 || pos>=fW*fH || fImg[pos]<sum+fCut*sdev) -
trunk/MagicSoft/Cosy/videodev/FilterLed.h
r8810 r9439 17 17 int fW; 18 18 int fH; 19 int fBox; 19 int fBoxX; 20 int fBoxY; 20 21 float fCut; 21 22 … … 24 25 25 26 void GetMinMax(const int offset, byte *min, byte *max) const; 26 int GetMeanPosition(const int x, const int y, const int box ) const;27 int GetMeanPosition(const int x, const int y, const int box ,27 int GetMeanPosition(const int x, const int y, const int boxx, const int boxy) const; 28 int GetMeanPosition(const int x, const int y, const int boxx, const int boxy, 28 29 float &mx, float &my, unsigned int &sum) const; 29 30 30 31 int GetMeanPositionBox(const int x, const int y, 31 const int box ) const;32 const int boxx, const int boxy) const; 32 33 int GetMeanPositionBox(const int x, const int y, 33 const int box , float &mx, float &my,34 const int boxx, const int boxy, float &mx, float &my, 34 35 unsigned int &sum) const; 35 36 … … 40 41 public: 41 42 FilterLed(byte *img, int w, int h, double cut=2.5) 42 : fImg(img), fW(w), fH(h), fBox (w>h?w:h), fCut(cut)43 : fImg(img), fW(w), fH(h), fBoxX(w), fBoxY(h), fCut(cut) 43 44 { 44 45 } 45 46 46 FilterLed(byte *img, int w, int h, int box , double cut=2.5)47 : fImg(img), fW(w), fH(h), fBox (box), fCut(cut)47 FilterLed(byte *img, int w, int h, int boxx, int boxy, double cut=2.5) 48 : fImg(img), fW(w), fH(h), fBoxX(boxx), fBoxY(boxy), fCut(cut) 48 49 { 49 50 } 50 51 virtual ~FilterLed() { } 51 52 52 void SetBox(int box) { fBox = box; } 53 void SetBox(int box) { fBoxX = fBoxY = box; } 54 void SetBox(int boxx, int boxy) { fBoxX = boxx; fBoxY = boxy; } 53 55 void SetCut(float cut) { fCut = cut; } 54 56 void FindStar(Leds &leds, int xc, int yc, bool circle=false) const;
Note:
See TracChangeset
for help on using the changeset viewer.