I try to get the perspectiveTransform of some Point Matches I find, but I somehow get the Assertion Error and my Application gets killed.
Here is my method for this:
int MatcherManager::getInlierRANSAC(std::vector<cv::KeyPoint> reference, std::vector<cv::KeyPoint> matches, std::vector<cv::Point2f> &ransacs, std::vector<cv::Point2f> &obj_corners, std::vector<cv::Point2f> &scene_corners){
double ransacThreshold = 1;
int result = 0;
cv::Mat mask;
std::vector<cv::Point2f> points1, points2;
if(reference.size() > 0 && matches.size() > 0) {
for(int i = 0; i < reference.size(); i++){
points1.push_back(reference[i].pt);
points2.push_back(matches[i].pt);
}
cv::Mat H = cv::findHomography(points1, points2, CV_RANSAC, ransacThreshold, mask);
for (int i = 0; i < mask.rows; i++) {
if ((unsigned int) mask.at<uchar>(i)) {
result++;
ransacs.push_back(points2[i]);
}
}
cv::perspectiveTransform(obj_corners, scene_corners, H);
}
return result;
}
Does somebody see what causes the Exception here?