本文整理汇总了C++中cv::vector::erase方法的典型用法代码示例。如果您正苦于以下问题:C++ vector::erase方法的具体用法?C++ vector::erase怎么用?C++ vector::erase使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cv::vector
的用法示例。
在下文中一共展示了vector::erase方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: removeOutlier
void RemoveNoise::removeOutlier(cv::vector<cv::Point2f>& start,
cv::vector<cv::Point2f>& end) const
{
float averageNorm = 0.0f;
for(auto startIter=start.begin(),endIter=end.begin();
startIter!=start.end(); startIter++,endIter++)
{
averageNorm += cv::norm(*startIter - *endIter);
}
averageNorm /= start.size();
for(auto startIter=start.begin(), endIter=end.begin();
startIter!=start.end(); /* look at the end of for */)
{
if(cv::norm(*startIter - *endIter) > threshNorm * averageNorm){
startIter = start.erase(startIter);
endIter = end.erase(endIter);
continue;
}
startIter++, endIter++;
}
}
示例2: labelPockets
cv::vector<pocket> PointLocator::infer(cv::vector<cv::KeyPoint> orangeKeyPoints, cv::vector<cv::KeyPoint> greenKeyPoints,
cv::vector<cv::KeyPoint> purpleKeyPoints, cv::vector<cv::KeyPoint> pinkKeyPoints)
{
//Define vector of pocket points to be passed
cv::vector<pocket> pockets;
//There should be a maximum of 2 points per colour. If there is more, reduce.
//This depends on the quality of test video results.
//Right now it just takes the first 2 points in vector to prevent crashes.
//Takes only one point for orange and purple since they are side pockets
//TODO if needed later.
if (orangeKeyPoints.size() > 1){
orangeKeyPoints.erase(orangeKeyPoints.begin() + 1, orangeKeyPoints.end());
}
if (greenKeyPoints.size() > 2){
greenKeyPoints.erase(greenKeyPoints.begin() + 2, greenKeyPoints.end());
}
if (purpleKeyPoints.size() > 1){
purpleKeyPoints.erase(purpleKeyPoints.begin() + 1, purpleKeyPoints.end());
}
if (pinkKeyPoints.size() > 3){
pinkKeyPoints.erase(pinkKeyPoints.begin() + 3, pinkKeyPoints.end());
}
//Returns a vector of pocket type
pockets = labelPockets(orangeKeyPoints, greenKeyPoints, purpleKeyPoints, pinkKeyPoints);
return pockets;
}
示例3: findChessboard
int findChessboard(cv::vector<cv::Mat> &rgb, cv::vector<cv::Mat> &depth,
cv::vector<cv::vector<cv::vector<cv::Point2f> > > &imagePoints,
const cv::Size patternSize,
const int &fileNum){
for(int i = 0; i < rgb.size(); ++i){
cout << i << endl;
if( cv::findChessboardCorners( rgb[i],
patternSize,
imagePoints[0][i],
CV_CALIB_CB_ADAPTIVE_THRESH | CV_CALIB_CB_NORMALIZE_IMAGE
) &&
cv::findChessboardCorners( depth[i],
patternSize,
imagePoints[1][i] ,
CV_CALIB_CB_ADAPTIVE_THRESH | CV_CALIB_CB_NORMALIZE_IMAGE
) ) {
std::cout << " ... All corners found." << std::endl;
cv::cornerSubPix(rgb[i], imagePoints[0][i], cv::Size(11,11), cv::Size(-1,-1),
cv::TermCriteria(CV_TERMCRIT_ITER+CV_TERMCRIT_EPS,
30, 0.01));
cv::cornerSubPix(depth[i], imagePoints[1][i], cv::Size(11,11), cv::Size(-1,-1),
cv::TermCriteria(CV_TERMCRIT_ITER+CV_TERMCRIT_EPS,
30, 0.01));
// 検出点を描画する
cv::drawChessboardCorners( rgb[i], patternSize, ( cv::Mat )( imagePoints[0][i] ), true );
cv::drawChessboardCorners( depth[i], patternSize, ( cv::Mat )( imagePoints[1][i] ), true );
cv::imshow( "rgb", rgb[i] );
cv::imshow("depth", depth[i]);
cv::waitKey( 100 );
} else {
std::cout << " ... at least 1 corner not found." << std::endl;
rgb.erase(rgb.begin() + i);
depth.erase(depth.begin() + i);
imagePoints[0].erase(imagePoints[0].begin() + i);
imagePoints[1].erase(imagePoints[1].begin() + i);
cout << rgb.size() << endl;;
// fileNum--;
i--;
cv::waitKey( 100 );
}
}
return rgb.size();
}
示例4: findChessboards
int findChessboards(
cv::vector<cv::Mat> &lefts, cv::vector<cv::Mat> &rights,
cv::vector<cv::vector<cv::vector<cv::Point2f>>> &imagePoints,
const cv::Size patternSize, const int &fileNum) {
for (size_t i = 0; i < lefts.size(); ++i) {
if (cv::findChessboardCorners(
lefts[i], patternSize, imagePoints[0][i],
CV_CALIB_CB_ADAPTIVE_THRESH | CV_CALIB_CB_NORMALIZE_IMAGE) &&
cv::findChessboardCorners(
rights[i], patternSize, imagePoints[1][i],
CV_CALIB_CB_ADAPTIVE_THRESH | CV_CALIB_CB_NORMALIZE_IMAGE)) {
cv::cornerSubPix(
lefts[i], imagePoints[0][i], cv::Size(11, 11), cv::Size(-1, -1),
cv::TermCriteria(CV_TERMCRIT_ITER + CV_TERMCRIT_EPS, 30, 0.01));
cv::cornerSubPix(
rights[i], imagePoints[1][i], cv::Size(11, 11), cv::Size(-1, -1),
cv::TermCriteria(CV_TERMCRIT_ITER + CV_TERMCRIT_EPS, 30, 0.01));
cv::drawChessboardCorners(
lefts[i], patternSize, (cv::Mat)(imagePoints[0][i]), true);
cv::drawChessboardCorners(
rights[i], patternSize, (cv::Mat)(imagePoints[1][i]), true);
cv::imshow("Left", lefts[i]);
cv::imshow("Right", rights[i]);
} else {
std::cout << "cannot find all corners" << std::endl;
lefts.erase(lefts.begin() + i);
rights.erase(rights.begin() + i);
imagePoints[0].erase(imagePoints[0].begin() + i);
imagePoints[1].erase(imagePoints[1].begin() + i);
i--;
}
cv::waitKey(100);
}
return lefts.size();
}
示例5: 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);
}
}
示例6: if
//.........这里部分代码省略.........
//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;
}
//Remove pink marker from candidate list
pinkKeyPoints.erase(pinkKeyPoints.begin() + min, pinkKeyPoints.begin() + min + 1);
}
//Use the pink marker furthest to the left
/*if ((pocketCount == 2 || pocketCount == 3) && !pinkKeyPoints.empty()){
//Determine which pink side marker is being used.
//Should be marker closest along line between first two pockets.
float distance = -1;
int min = 0;
cv::Vec2f line = lineEqn(pockets[0].pocketPoints.pt.x, pockets[0].pocketPoints.pt.y, pockets[1].pocketPoints.pt.x, pockets[1].pocketPoints.pt.y);
for (int i = 0; i < pinkKeyPoints.size(); i++){
float newDistance = pinkKeyPoints[i].pt.x;
if ((distance + 1) < epsilon || newDistance < distance){
distance = newDistance;
min = i;
}
}
pockets[pocketCount].pocketPoints = pinkKeyPoints[min];
pockets[pocketCount].xLocation = xLeft;
pockets[pocketCount].yLocation = yMidTop;
pinkKeyPoints.erase(pinkKeyPoints.begin() + min, pinkKeyPoints.begin() + min + 1);
pocketCount++;
}*/
//If 2 or 3 pockets are picked up, use any pink side marker
/*if (pocketCount == 2 || pocketCount == 3){
//Determine which pink side marker is being used.
//Should be marker closest along line between first two pockets.
float distance = -1;
int min = 0;
cv::Vec2f line = lineEqn(pockets[0].pocketPoints.pt.x, pockets[0].pocketPoints.pt.y, pockets[1].pocketPoints.pt.x, pockets[1].pocketPoints.pt.y);
for (int i = 0; i < pinkKeyPoints.size(); i++){
float newDistance = distPointToLine(pinkKeyPoints[i].pt.x, pinkKeyPoints[i].pt.y, line);