Changeset 9439 for trunk/MagicSoft/Cosy/videodev/FilterLed.cc
- Timestamp:
- 05/09/09 13:48:12 (16 years ago)
- File:
-
- 1 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)
Note:
See TracChangeset
for help on using the changeset viewer.