Пример #1
0
	bool Epipolar::chooseValidPair(vector<ImageContainer>& imgCont, vector<vector<DMatch>>& goodMatchesM, Mat& cam, Mat& distor
		, Mat& ess, double inlierPercent){
		size_t count = 0;
		size_t nImages = imgCont.size();
		Mat inliersMask;
		while (true)
		{
			if (isValidPair(goodMatchesM[0], imgCont[0].imgKeys, imgCont[1].imgKeys, cam, distor, ess, inliersMask, inlierPercent)) break;
			if (count > nImages - 3){
				return false;
			}
			imgCont.erase(imgCont.begin(), imgCont.begin() + 1);
			goodMatchesM.erase(goodMatchesM.begin(), goodMatchesM.begin() + 1);
			count++;
		}
		vector<DMatch>unrefinMatches = goodMatchesM[0];
		goodMatchesM[0].clear();
		for (size_t i = 0; i < unrefinMatches.size(); i++)
		{
			if ((int)inliersMask.at<uchar>(i, 0) == 1)
			{
				goodMatchesM[0].push_back(unrefinMatches[i]);
			}
		}
		return true;
	}
Пример #2
0
int solution(string &S) {
    // write your code in C++11
    if (S.empty()) return 1;
    if (S.size() == 1) return 0;
    stack<char> brackets;
    for (auto i = S.begin(); i != S.end(); i++) {
        if (brackets.empty()) {
            brackets.push(*i);
            continue;
        }
        if (!isValidPair(brackets.top(), *i)) {
            brackets.push(*i);
        } else {
            brackets.pop();
        }
    }
    return brackets.empty() ? 1 : 0;
}