本文整理汇总了C++中cv::vector::empty方法的典型用法代码示例。如果您正苦于以下问题:C++ vector::empty方法的具体用法?C++ vector::empty怎么用?C++ vector::empty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cv::vector
的用法示例。
在下文中一共展示了vector::empty方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: removePinkCandidate
//Remove pink pocket from vector that is between 2 green points.
void PointLocator::removePinkCandidate(cv::vector<cv::KeyPoint> &pinkKeyPoints, cv::KeyPoint firstPocket, cv::KeyPoint secondPocket){
//First check that there are actually pink pocket points
if (!pinkKeyPoints.empty()){
float distance = -1;
int min = 0;
cv::KeyPoint middlePoint;
middlePoint.pt.x = (firstPocket.pt.x + secondPocket.pt.x) / 2;
middlePoint.pt.y = (firstPocket.pt.y + secondPocket.pt.y) / 2;
for (int i = 0; i < pinkKeyPoints.size(); i++){
float newDistance = distBetweenKeyPoints(pinkKeyPoints[i], middlePoint);
if ((distance + 1) < epsilon || newDistance < distance){
distance = newDistance;
min = i;
}
}
pinkKeyPoints.erase(pinkKeyPoints.begin() + min, pinkKeyPoints.begin() + min + 1);
}
}
示例2: if
//.........这里部分代码省略.........
if (orangeKeyPoints.size() > 0){
removePinkCandidate(pinkKeyPoints, pockets[1].pocketPoints, orangeKeyPoints[0]);
pinkRight = false;
}
if (purpleKeyPoints.size() > 0){
removePinkCandidate(pinkKeyPoints, pockets[0].pocketPoints, purpleKeyPoints[0]);
pinkLeft = false;
}
}
else if (greenKeyPoints.size() == 1){
int removeLocation = 0;
if (orangeKeyPoints.size() > 0 && purpleKeyPoints.size() > 0){
float distToOrange = distBetweenKeyPoints(orangeKeyPoints[0], pockets[0].pocketPoints);
float distToPurple = distBetweenKeyPoints(purpleKeyPoints[0], pockets[0].pocketPoints);
if (distToOrange > distToPurple){
removeLocation = 2;
}
else{
removeLocation = 1;
}
}
else if (orangeKeyPoints.size() > 0 && (removeLocation == 0 || removeLocation == 1)){
removePinkCandidate(pinkKeyPoints, pockets[0].pocketPoints, orangeKeyPoints[0]);
pinkRight = false;
}
if (purpleKeyPoints.size() > 0 && (removeLocation == 0 || removeLocation == 2)){
removePinkCandidate(pinkKeyPoints, pockets[0].pocketPoints, purpleKeyPoints[0]);
pinkLeft = false;
}
}
//Adds pink pockets to list of pockets based on other pockets identified.
while (!pinkKeyPoints.empty() && pockets[3].xLocation == NULL && pocketCount < 4){
//Find the pink marker closest to the first pocket in list.
//It is structured so this is always the right marker to choose because of elimination of markers from candidate list.
float distance = -1;
int min = 0;
for (int i = 0; i < pinkKeyPoints.size(); i++){
float newDistance = distBetweenKeyPoints(pinkKeyPoints[i], pockets[0].pocketPoints);
if ((distance + 1) < epsilon || newDistance < distance){
distance = newDistance;
min = i;
}
}
pockets[pocketCount].pocketPoints = pinkKeyPoints[min];
//
if (pinkTop){
pockets[pocketCount].xLocation = xMid;
pockets[pocketCount].yLocation = yTop;
pocketCount++;
pinkTop = false;
}
else if (pinkLeft){
pockets[pocketCount].xLocation = xLeft;
pockets[pocketCount].yLocation = yMidTop;
pocketCount++;
pinkLeft = false;
}
else if (pinkRight){
pockets[pocketCount].xLocation = xRight;
pockets[pocketCount].yLocation = yMidTop;
pocketCount++;
pinkRight = false;
}