/************************************** * Definition: Finds squares of the given color and given minimum size * * Parameters: the color to threshold by and the minimum area for a square * * Returns: a squares_t linked list **************************************/ squares_t* Camera::findSquaresOf(int color, int areaThreshold) { squares_t *squares = NULL; switch (color) { case COLOR_PINK: squares = findSquares(_pinkThresholded, areaThreshold); break; case COLOR_YELLOW: squares = findSquares(_yellowThresholded, areaThreshold); break; } return rmOverlappingSquares(squares); }
void licenseLocate1(CvPoint& centre, IplImage* img,CvMemStorage* &storage1,bool isForDay){ if( img ) { findSquares( img, storage1,isForDay,centre); cvReleaseMemStorage(&storage1 ); } else cout<<"error in trackbar"<<endl; }
pieces_t findPieces(const cv::Mat &inputImage) { std::cout << "Finding pieces of the document in the input image..." << std::endl; rectangles_t rectangles = findSquares(inputImage); rectangles = filterOutOverlappingRectangles(rectangles); pieces_t result = cropImages(inputImage, rectangles); return result; }
void EyeTracker::startTracker() { while(true) { captureEyeFrame(); captureSceneFrame(); Point2f p = doTrack(); //qDebug() << "x: " << p.x << " y: " << p.y; drawTrasholds(); drawSquares(findSquares()); cvShowImage(PUPIL_DETECTION_WINDOW_NAME, grayEyeImagePts); releaseGrayEyeImage(); releaseGraySceneImage(); int k = cvWaitKey(20); if( k == 27 ) break; /* if( k == 'w' || k == 'W' ) ++highThreshold; else if ( k == 's' || k == 'S' ) --highThreshold; else if( k == 'q' || k == 'Q' ) ++squareThreshold; else if ( k == 'a' || k == 'A' ) --squareThreshold;*/ } }
//returns ms elapsed, -2 if the monster dies int shMonster::doPet () { int i, n; shCoord coord[9]; int info[9]; int best = -1; int score, bestscore = -9999; int flags = kLinedUp | kTrap; int res = -1; int dist; int scrubbot = isA (kMonScrubbot); int val_linedup; int val_adjacent; int val_dist; int val_track; int val_monst; shMonster *c; int elapsed; /* first priority is always to drink any beer in our square! */ res = drinkBeer (); if (-1 != res) return res; if (mHP > mMaxHP / 4) { flags |= kMonster; } if (canSee (&Hero)) { findPetGoal (); val_linedup = -10; val_dist = -2; val_track = -5; val_adjacent = RNG (3) ? -5 : 10; val_monst = 10; } else { mDestX = Hero.mX; mDestY = Hero.mY; val_linedup = 0; val_dist = -1; val_track = -10; val_adjacent = 5; val_monst = 5; } if (isSessile ()) { val_monst += 50; } if (scrubbot) flags |= kFreeWreck; n = findSquares (flags, coord, info); for (i = 0; i < n; i++) { score = 0; if (info[i] & kTrap and RNG (30)) /* small chance that a pet will walk on a trap*/ { score -= 30; } if (info[i] & kFreeWreck) score += 50; if (info[i] & kLinedUp) score += val_linedup; if (info[i] & kMonster) { c = (shMonster *) mLevel->getCreature (coord[i].mX, coord[i].mY); if (c and !c->isHero () and !c->isPet () and c->isHostile () and /* Smart bombs and missiles should be ready to sacrifice themselves on any hostile target. isExplosive checks this. */ (c->mCLevel <= mCLevel + 1 or isExplosive ())) { score += c->isHostile () ? val_monst : val_monst / 2; } else if (c != this) { score -= 30; } } if (coord[i].mX == mX and coord[i].mY == mY) { score -= 10; } if (areAdjacent (coord[i].mX, coord[i].mY, Hero.mX, Hero.mY)) score += val_adjacent; dist = distance (coord[i].mX, coord[i].mY, mDestX, mDestY); if (dist > 50 and val_dist > 0) { dist = 50; } score += val_dist * dist; int ti; for (ti = 0 ; ti < TRACKLEN; ti++) { if (mTrack[ti].mX == coord[i].mX and mTrack[ti].mY == coord[i].mY) { score += val_track; } } if (score > bestscore) { bestscore = score; best = i; } } if (-1 == best) { /* nothing to do but stay where we are for now */ return 500; } if (coord[best].mX == mX and coord[best].mY == mY) { if (info[best] & kFreeWreck) { shObjectVector *v = mLevel->getObjects (mX, mY); shObject *obj; for (int i = 0; i < v->count (); ++i) { obj = v->get (i); if (obj->isA (kObjWreck)) { v->remove (obj); if (0 == v->count ()) { delete v; mLevel->setObjects (mX, mY, NULL); } return utilizeWreck (obj); } } } return 250; } else { if (info[best] & kMonster) { c = (shMonster *) mLevel->getCreature (coord[best].mX, coord[best].mY); doAttack (c, &elapsed); return elapsed; } if (!isSessile ()) return doMove (vectorDirection (mX, mY, coord[best].mX, coord[best].mY)); } return 250; }