本文整理汇总了C++中Blob::getLeftTopY方法的典型用法代码示例。如果您正苦于以下问题:C++ Blob::getLeftTopY方法的具体用法?C++ Blob::getLeftTopY怎么用?C++ Blob::getLeftTopY使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Blob
的用法示例。
在下文中一共展示了Blob::getLeftTopY方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: drawBlob
/* Draws the outline of a blob in the specified color.
* @param b the blob
* @param c the color to paint
*/
void Ball::drawBlob(Blob b, int c) {
#ifdef OFFLINE
thresh->drawLine(b.getLeftTopX(), b.getLeftTopY(),
b.getRightTopX(), b.getRightTopY(),
c);
thresh->drawLine(b.getLeftTopX(), b.getLeftTopY(),
b.getLeftBottomX(), b.getLeftBottomY(),
c);
thresh->drawLine(b.getLeftBottomX(), b.getLeftBottomY(),
b.getRightBottomX(), b.getRightBottomY(),
c);
thresh->drawLine(b.getRightTopX(), b.getRightTopY(),
b.getRightBottomX(), b.getRightBottomY(),
c);
#endif
}
示例2: rightBlobColor
/* Checks out how much of the blob is of the right color.
* If it is enough returns true, if not false.
* @param tempobj the blob we're checking (usually a post)
* @param minpercent how good it needs to be
* @return was it good enough?
*/
bool Ball::rightBlobColor(Blob tempobj, float minpercent) {
int x = tempobj.getLeftTopX();
int y = tempobj.getLeftTopY();
int spanX = tempobj.width();
int spanY = tempobj.height();
if (spanX < 2 || spanY < 2) return false;
int ny, nx, starty, startx;
int good = 0, total = 0;
for (int i = 0; i < spanY; i++) {
starty = y + i;
startx = x;
for (int j = 0; j < spanX; j++) {
nx = startx + j;
ny = starty;
if (ny > -1 && nx > -1 && ny < IMAGE_HEIGHT && nx < IMAGE_WIDTH) {
total++;
if (thresh->thresholded[ny][nx] == color) {
good++;
}
}
}
}
float percent = (float)good / (float) (total);
if (percent > minpercent) {
return true;
}
return false;
}
示例3: if
/* As part of our roundness checking we scan the midlines of the blob.
In principle every pixel should be the right color.
@param b candidate blob
@return a pair containing the number of good and bad pixels
*/
pair<int, int> Ball::scanMidlinesForRoundnessInformation(Blob b) {
int w = b.width();
int h = b.height();
int x = b.getLeftTopX();
int y = b.getLeftTopY();
int pix;
int goodPix = 0, badPix = 0;
for (int i = 0; i < h; i++) {
pix = thresh->getThresholded(y+i,x + w/2);
if (pix == ORANGE || pix == ORANGERED || pix == ORANGEYELLOW) {
goodPix++;
} else if (pix != GREY)
badPix++;
}
for (int i = 0; i < w; i++) {
pix = thresh->getThresholded(y+h/2,x + i);
if (pix == ORANGE || pix == ORANGERED || pix == ORANGEYELLOW) {
goodPix++;
} else if (pix != GREY) {
badPix++;
}
}
pair<int, int> info;
info.first = goodPix;
info.second = badPix;
return info;
}
示例4: checkSizeAgainstPixEstimate
/* Returns whether true when the size of the cross is reasonable when tested
against the pixEstimated distance.
@param b the candidate cross
@return if the size is reasonable
*/
bool Cross::checkSizeAgainstPixEstimate(Blob b) {
int x = b.getLeftTopX();
int y = b.getLeftTopY();
int w = b.width();
int h = b.height();
// before we spend a lot of time processing, let's see if it is a reasonable size
if (w > 3 * h || h > 2 * w) {
return false;
}
estimate e = vision->pose->pixEstimate(x, y, 0.0);
if (CROSSDEBUG) {
cout << "Distance check: " << e.dist << " " << w << endl;
}
if (e.dist < 100.0f && w < 20) {
return false;
} else if (e.dist < 150.0f && w < 12) {
return false;
} else if (e.dist < 200.0f && w < 8) {
return false;
}
if (e.dist > 200.0f && w > 20) {
return false;
}
return true;
}
示例5: checkForLineIntersection
/* Determines if a line intersects the candidate cross, if so it
is thrown out.
@param b the candidate cross
@return whether a line intersects
*/
bool Cross::checkForLineIntersection(Blob b) {
int x = b.getLeftTopX();
int y = b.getLeftTopY();
int w = b.width();
int h = b.height();
point <int> plumbLineTop, plumbLineBottom, line1start, line1end;
plumbLineTop.x = x + w / 2; plumbLineTop.y = y;
plumbLineBottom.x = x; plumbLineBottom.y = y + h;
const vector <boost::shared_ptr<VisualLine> >* lines =
vision->fieldLines->getLines();
for (vector <boost::shared_ptr<VisualLine> >::const_iterator k =
lines->begin();
k != lines->end(); k++) {
pair<int, int> foo = Utility::plumbIntersection(plumbLineTop,
plumbLineBottom,
(*k)->getStartpoint(),
(*k)->getEndpoint());
if (foo.first != Utility::NO_INTERSECTION && foo.second !=
Utility::NO_INTERSECTION) {
if (CROSSDEBUG)
cout << "Throwing out blob that is part of a line" << endl;
return true;
}
}
return false;
}
示例6: printBlob
/* Print debugging information for a blob.
* @param b the blob
*/
void Ball::printBlob(Blob b) {
#if defined OFFLINE
cout << "Blob Top Left Corner " << b.getLeftTopX() << " " << b.getLeftTopY()
<< endl;
cout << "Width/height " << b.width() << " " << b.height();
cout << " Amount of orange " << b.getPixels() << endl;
#endif
}
示例7: scanAroundPerimeter
/* Scans around the outside of the blob looking for green. Ideally the
cross will have only green around it. White is a big problem, so is
having the cross near the edge. This is because our version of the
cross is so simple - we don't look at its shape at all! Instead we
just look for white blobs with the right general properties.
@param b the candidate cross
@return the amount of green in the perimeter (white gives a huge
negative penalty)
*/
bool Cross::scanAroundPerimeter(Blob b) {
const float greenThreshold = 0.75f;
int x = b.getLeftTopX();
int y = b.getLeftTopY();
int w = b.width();
int h = b.height();
int counter = 0, count = 0;
// first scan the sides
for (int i = max(0, y - 2); i < min(IMAGE_HEIGHT - 1, y + h + 2); i++) {
if (x > 3) {
if (Utility::isGreen(thresh->getThresholded(i,x - 4))) {
count++;
} else if (Utility::isWhite(thresh->getThresholded(i,x - 4))) {
count-=3;
}
counter++;
} else return false;
if (x + w + 4 < IMAGE_WIDTH) {
if (Utility::isGreen(thresh->getThresholded(i,x + w+ 4))) {
count++;
} else if (Utility::isWhite(thresh->getThresholded(i,x + w+ 4))) {
count-=3;
}
counter++;
} else return false;
}
// now scan above and below
for (int i = max(0, x - 2); i < min(IMAGE_WIDTH - 1, x + w + 2); i++) {
if (y > 1) {
if (Utility::isGreen(thresh->getThresholded(y - 2,i))) {
count++;
} else if (Utility::isUndefined(thresh->getThresholded(y - 2,i))) {
count--;
} else if (Utility::isWhite(thresh->getThresholded(y - 2,i))) {
count-=3;
}
counter++;
} else return false;
if (y + h + 2 < IMAGE_HEIGHT) {
if (Utility::isGreen(thresh->getThresholded(y+h+2,i))) {
count++;
} else if (Utility::isWhite(thresh->getThresholded(y+h+2,i))) {
count-=3;
}
counter++;
} else return false;
}
if (count > (float)counter * greenThreshold) {
if (CROSSDEBUG) {
cout << "White stats: " << count << " " << counter << endl;
}
return true;
}
return false;
}
示例8: printBlob
/* Print debugging information for a blob.
* @param b the blob
*/
void Robots::printBlob(Blob b) {
#if defined OFFLINE
cout << "Outputting blob" << endl;
cout << b.getLeftTopX() << " " << b.getLeftTopY() << " " << b.getRightTopX() << " "
<< b.getRightTopY() << endl;
cout << b.getLeftBottomX() << " " << b.getLeftBottomY() << " " << b.getRightBottomX()
<< " " << b.getRightBottomY() << endl;
#endif
}
示例9: updateRobot
/**
* Update the robot values from the blob
*
* @param b The blob to update our object from.
*/
void VisualRobot::updateRobot(Blob b)
{
setLeftTopX(b.getLeftTopX());
setLeftTopY(b.getLeftTopY());
setLeftBottomX(b.getLeftBottomX());
setLeftBottomY(b.getLeftBottomY());
setRightTopX(b.getRightTopX());
setRightTopY(b.getRightTopY());
setRightBottomX(b.getRightBottomX());
setRightBottomY(b.getRightBottomY());
setX(b.getLeftTopX());
setY(b.getLeftTopY());
setWidth(dist(b.getRightTopX(), b.getRightTopY(), b.getLeftTopX(),
b.getLeftTopY()));
setHeight(dist(b.getLeftTopX(), b.getLeftTopY(), b.getLeftBottomX(),
b.getLeftBottomY()));
setCenterX(getLeftTopX() + ROUND2(getWidth() / 2));
setCenterY(getRightTopY() + ROUND2(getHeight() / 2));
setDistance(1);
}
示例10: rightHalfColor
// only called on really big orange blobs
float Ball::rightHalfColor(Blob tempobj)
{
const float COLOR_THRESH = 0.15f;
const float POOR_VALUE = 0.10f;
int x = tempobj.getLeftTopX();
int y = tempobj.getLeftTopY();
int spanY = tempobj.height() - 1;
int spanX = tempobj.width() - 1;
int good = 0, good1 = 0, good2 = 0;
int pix;
if (rightColor(tempobj, ORANGE) < COLOR_THRESH) return POOR_VALUE;
for (int i = spanY / 2; i < spanY; i++) {
for (int j = 0; j < spanX; j++) {
pix = thresh->thresholded[y + i][x + j];
if (y + i > -1 && x + j > -1 && (y + i) < IMAGE_HEIGHT &&
x + j < IMAGE_WIDTH && (pix == ORANGE || pix == ORANGERED ||
pix == ORANGEYELLOW)) {
good++;
}
}
}
for (int i = 0; i < spanY; i++) {
for (int j = 0; j < spanX / 2; j++) {
pix = thresh->thresholded[y + i][x + j];
if (y + i > -1 && x + j > -1 && (y + i) < IMAGE_HEIGHT &&
x + j < IMAGE_WIDTH && (pix == ORANGE || pix == ORANGERED ||
pix == ORANGEYELLOW)) {
good1++;
}
}
}
for (int i = 0; i < spanY; i++) {
for (int j = spanX / 2; j < spanX; j++) {
pix = thresh->thresholded[y + i][x + j];
if (y + i > -1 && x + j > -1 && (y + i) < IMAGE_HEIGHT &&
x + j < IMAGE_WIDTH && (pix == ORANGE || pix == ORANGERED ||
pix == ORANGEYELLOW)) {
good2++;
}
}
}
if (BALLDEBUG) {
cout << "Checking half color " << good << " " << good1 << " " <<
good2 << " " << (spanX * spanY / 2) << endl;
}
float percent = (float)max(max(good, good1), good2) /
(float) (spanX * spanY / 2);
return percent;
}
示例11: min
/* As part of roundness checking we scan the diagonals of the blob.
We know that there is a predictible transition point from no ball
to ball and categorize each pixel accordingly
@param b the blob
@return a pair containing the number of good pixels, and bad ones
*/
pair<int, int> Ball::scanDiagonalsForRoundnessInformation(Blob b) {
const float CORNER_CHUNK_DIV = 6.0f;
int w = b.width();
int h = b.height();
int x = b.getLeftTopX();
int y = b.getLeftTopY();
int pix;
int goodPix = 0, badPix = 0;
int d = ROUND2(static_cast<float>(std::max(w, h)) /
CORNER_CHUNK_DIV);
int d3 = min(w, h);
pair<int, int> info;
for (int i = 0; i < d3; i++) {
pix = thresh->getThresholded(y+i,x+i);
if (i < d || (i > d3 - d)) {
if (pix == ORANGE || pix == ORANGERED) {
//drawPoint(x+i, y+i, BLACK);
badPix++;
} else {
goodPix++;
}
} else {
if (pix == ORANGE || pix == ORANGERED || pix == ORANGEYELLOW) {
goodPix++;
} else if (pix != GREY) {
badPix++;
//drawPoint(x+i, y+i, PINK);
}
}
pix = thresh->getThresholded(y+i,x+w-i);
if (i < d || (i > d3 - d)) {
if (pix == ORANGE || pix == ORANGERED) {
//drawPoint(x+w-i, y+i, BLACK);
badPix++;
}
else {
goodPix++;
}
} else if (pix == ORANGE || pix == ORANGERED ||
pix == ORANGEYELLOW) {
goodPix++;
} else if (pix != GREY) {
badPix++;
}
}
info.first = goodPix;
info.second = badPix;
return info;
}
示例12: printBall
/* Prints a bunch of ball information about the best ball candidate (or any one).
* @param b the candidate ball
* @param c how confident we are its a ball
* @param p how many occlusions
* @param o what the occlusions are if any
* @param bg where around the ball there is green
*/
void Ball::printBall(Blob b, int c, float p, int o) {
#ifdef OFFLINE
if (BALLDEBUG) {
cout << "Ball info: " << b.getLeftTopX() << " " << b.getLeftTopY()
<< " " << b.width() << " " << b.height() << endl;
cout << "Confidence: " << c << " Orange Percent: " << p
<< " Occlusions: ";
if (o == NOOCCLUSION) cout << "none";
if (o % LEFTOCCLUSION == 0) cout << "left ";
if (o % RIGHTOCCLUSION == 0) cout << "right ";
if (o % TOPOCCLUSION == 0) cout << "top ";
if (o % BOTTOMOCCLUSION == 0) cout << "bottom ";
cout << endl;
}
#endif
}
示例13: ballNearGreen
int Ball::ballNearGreen(Blob b)
{
const int EXTRA_LINES = 6;
// first check the bottom
int w = b.width();
int h = b.height();
int where = NOGREEN;
if (greenCheck(b))
where = where * GREENBELOW;
// now try the sides - happily the ball is round so we don't have to worry
// about scan angles
int x = b.getLeftTopX();
int y = b.getLeftTopY();
for (int i = 0; i < h && y + i < IMAGE_HEIGHT && where % GREENLEFT != 0;
i= i+2) {
for (int j =-1; j < EXTRA_LINES && x + j > -1 && where % GREENLEFT != 0;
j++) {
if (thresh->thresholded[i+y][x - j] == GREEN) {
where = where * GREENLEFT;
}
}
}
for (int i = 0; i < w && x + i < IMAGE_WIDTH && where % GREENABOVE != 0;
i= i+2) {
for (int j = 0; j < EXTRA_LINES && y - j > 0 && where % GREENABOVE != 0;
j++) {
if (thresh->thresholded[i+y][j+x] == GREEN) {
where = where * GREENABOVE;
}
}
}
x = b.getRightTopX();
y = b.getRightTopY();
for (int i = 0; i < h && y + i < IMAGE_HEIGHT && where % GREENRIGHT != 0;
i= i+2) {
for (int j = 0; j < EXTRA_LINES && x + j < IMAGE_WIDTH &&
where % GREENRIGHT != 0; j++) {
if (thresh->thresholded[i+y][j+x] == GREEN) {
where = where * GREENRIGHT;
}
}
}
// put in the case where we don't have any, but want to check the corners
return where;
}
示例14: badSurround
bool Ball::badSurround(Blob b) {
// basically check around the blob and see if it is ok - ideally we'd have
// some green, worrisome would be lots of RED
static const int SURROUND = 12;
const float GREEN_PERCENT = 0.1f;
int x = b.getLeftTopX();
int y = b.getLeftTopY();
int w = b.width();
int h = b.height();
int surround = min(SURROUND, w/2);
int greens = 0, orange = 0, red = 0, borange = 0, pix, realred = 0,
yellows = 0;
// now collect information on the area surrounding the ball and the ball
x = max(0, x - surround);
y = max(0, y - surround);
w = w + surround * 2;
h = h + surround * 2;
for (int i = 0; i < w && x + i < IMAGE_WIDTH; i++) {
for (int j = 0; j < h && y + j < IMAGE_HEIGHT; j++) {
pix = thresh->getThresholded(y + j,x + i);
if (pix == ORANGE || pix == ORANGEYELLOW) {
orange++;
if (x + i >= b.getLeft() && x + i <= b.getRight() &&
y + j >= b.getTop() && y + j <= b.getBottom()) {
borange++;
}
} else if (pix == RED) {
realred++;
} else if (pix == ORANGERED) {
red++;
} else if (pix == GREEN) {
greens++;
} else if (pix == YELLOW && j < surround) {
yellows++;
}
}
}
if (BALLDEBUG) {
cout << "Surround information " << red << " " << realred << " "
<< orange << " " << borange << " " << greens << " "
<< yellows << endl;
}
if (realred > borange) {
if (BALLDEBUG) {
cout << "Too much real red" << endl;
}
return true;
}
if (realred > greens && w * h < 2000) {
if (BALLDEBUG) {
cout << "Too much real red versus green" << endl;
}
return true;
}
if (realred > borange && realred > orange) {
if (BALLDEBUG) {
cout << "Too much real red vs borange" << endl;
}
return true;
}
if (orange - borange > borange * 0.3 && orange - borange > 10) {
if (BALLDEBUG) {
cout << "Too much orange outside of the ball" << endl;
}
// We can run into this problem with reflections - let's see if
// we're up against a post or something
if (yellows > w * 3) {
if (BALLDEBUG) {
cout << "But lots of yellow, doing nothing " << endl;
}
return false;
} else {
return true;
}
}
if ((red > orange) &&
(static_cast<float>(greens) <
(static_cast<float>(w * h) * GREEN_PERCENT))) {
if (BALLDEBUG) {
cout << "Too much real orangered without enough green" << endl;
}
return true;
}
if (red > orange || (realred > greens && realred > 2 * w &&
realred > borange * 0.1)) {
if (BALLDEBUG) {
cout << "Too much real red - doing more checking" << endl;
}
x = b.getLeftTopX();
y = b.getLeftBottomY();
if (nearImageEdgeX(x, 2) || nearImageEdgeX(x+b.width(), 2) ||
nearImageEdgeY(y, 2)) {
if (BALLDEBUG) {
cout << "Dangerous corner location detected " << x << " "
<< y << " " << w << endl;
}
return true;
//.........这里部分代码省略.........
示例15: atBoundary
/* Is the ball at the boundary of the screen?
* @param b the ball
* @return whether or not it borders a boundary
*/
bool Ball::atBoundary(Blob b) {
return b.getLeftTopX() == 0 || b.getRightTopX() >= IMAGE_WIDTH -1 ||
b.getLeftTopY() == 0
|| b.getLeftBottomY() >= IMAGE_HEIGHT - 1;
}