This commit is contained in:
Andrey Kamaev 2012-05-31 08:02:52 +00:00
parent 1a572c8e89
commit 9399394e6c
3 changed files with 178 additions and 131 deletions

View File

@ -778,35 +778,34 @@ void ORB::operator()( InputArray _image, InputArray _mask, vector<KeyPoint>& _ke
{ {
if( level < firstLevel ) if( level < firstLevel )
{ {
resize(image, imagePyramid[level], sz, scale, scale, INTER_LINEAR); resize(image, imagePyramid[level], sz, 0, 0, INTER_LINEAR);
if (!mask.empty()) if (!mask.empty())
resize(mask, maskPyramid[level], sz, scale, scale, INTER_LINEAR); resize(mask, maskPyramid[level], sz, 0, 0, INTER_LINEAR);
copyMakeBorder(imagePyramid[level], temp, border, border, border, border,
BORDER_REFLECT_101+BORDER_ISOLATED);
} }
else else
{ {
resize(imagePyramid[level-1], imagePyramid[level], sz, resize(imagePyramid[level-1], imagePyramid[level], sz, 0, 0, INTER_LINEAR);
1./scaleFactor, 1./scaleFactor, INTER_LINEAR);
if (!mask.empty()) if (!mask.empty())
resize(maskPyramid[level-1], maskPyramid[level], sz, {
1./scaleFactor, 1./scaleFactor, INTER_LINEAR); resize(maskPyramid[level-1], maskPyramid[level], sz, 0, 0, INTER_LINEAR);
copyMakeBorder(imagePyramid[level], temp, border, border, border, border, threshold(maskPyramid[level], maskPyramid[level], 254, 0, THRESH_TOZERO);
BORDER_REFLECT_101+BORDER_ISOLATED); }
} }
copyMakeBorder(imagePyramid[level], temp, border, border, border, border,
BORDER_REFLECT_101+BORDER_ISOLATED);
if (!mask.empty())
copyMakeBorder(maskPyramid[level], masktemp, border, border, border, border,
BORDER_CONSTANT+BORDER_ISOLATED);
} }
else else
{ {
copyMakeBorder(image, temp, border, border, border, border, copyMakeBorder(image, temp, border, border, border, border,
BORDER_REFLECT_101); BORDER_REFLECT_101);
image.copyTo(imagePyramid[level]);
if( !mask.empty() ) if( !mask.empty() )
mask.copyTo(maskPyramid[level]); copyMakeBorder(mask, masktemp, border, border, border, border,
BORDER_CONSTANT+BORDER_ISOLATED);
} }
if( !mask.empty() )
copyMakeBorder(maskPyramid[level], masktemp, border, border, border, border,
BORDER_CONSTANT+BORDER_ISOLATED);
} }
// Pre-compute the keypoints (we keep the best over all scales, so this has to be done beforehand // Pre-compute the keypoints (we keep the best over all scales, so this has to be done beforehand

View File

@ -1091,3 +1091,51 @@ TEST( Features2d_DescriptorMatcher_FlannBased, regression )
CV_DescriptorMatcherTest test( "descriptor-matcher-flann-based", new FlannBasedMatcher, 0.04f ); CV_DescriptorMatcherTest test( "descriptor-matcher-flann-based", new FlannBasedMatcher, 0.04f );
test.safe_run(); test.safe_run();
} }
TEST(Features2D_ORB, _1996)
{
cv::Ptr<cv::FeatureDetector> fd = cv::FeatureDetector::create("ORB");
cv::Ptr<cv::DescriptorExtractor> de = cv::DescriptorExtractor::create("ORB");
Mat image = cv::imread(string(cvtest::TS::ptr()->get_data_path()) + "shared/lena.jpg");
ASSERT_FALSE(image.empty());
Mat roi(image.size(), CV_8UC1, Scalar(0));
Point poly[] = {Point(100, 20), Point(300, 50), Point(400, 200), Point(10, 500)};
fillConvexPoly(roi, poly, int(sizeof(poly) / sizeof(poly[0])), Scalar(255));
std::vector<cv::KeyPoint> keypoints;
fd->detect(image, keypoints, roi);
cv::Mat descriptors;
de->compute(image, keypoints, descriptors);
//image.setTo(Scalar(255,255,255), roi);
int roiViolations = 0;
for(std::vector<cv::KeyPoint>::const_iterator kp = keypoints.begin(); kp != keypoints.end(); ++kp)
{
int x = cvRound(kp->pt.x);
int y = cvRound(kp->pt.y);
ASSERT_LE(0, x);
ASSERT_LE(0, y);
ASSERT_GT(image.cols, x);
ASSERT_GT(image.rows, y);
// if (!roi.at<uchar>(y,x))
// {
// roiViolations++;
// circle(image, kp->pt, 3, Scalar(0,0,255));
// }
}
// if(roiViolations)
// {
// imshow("img", image);
// waitKey();
// }
ASSERT_EQ(0, roiViolations);
}