Skip to content

Commit

Permalink
Merge pull request #7852 from savuor:fix/orb_rotation
Browse files Browse the repository at this point in the history
  • Loading branch information
vpisarev committed Dec 19, 2016
2 parents 01de65c + 13b9dd3 commit c64ac42
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
4 changes: 3 additions & 1 deletion modules/features2d/src/orb.cpp
Expand Up @@ -970,7 +970,9 @@ void ORB_Impl::detectAndCompute( InputArray _image, InputArray _mask,
//ROI handling
const int HARRIS_BLOCK_SIZE = 9;
int halfPatchSize = patchSize / 2;
int border = std::max(edgeThreshold, std::max(halfPatchSize, HARRIS_BLOCK_SIZE/2))+1;
// sqrt(2.0) is for handling patch rotation
int descPatchSize = cvCeil(halfPatchSize*sqrt(2.0));
int border = std::max(edgeThreshold, std::max(descPatchSize, HARRIS_BLOCK_SIZE/2))+1;

bool useOCL = ocl::useOpenCL() && OCL_FORCE_CHECK(_image.isUMat() || _descriptors.isUMat());

Expand Down
33 changes: 33 additions & 0 deletions modules/features2d/test/test_orb.cpp
Expand Up @@ -90,3 +90,36 @@ TEST(Features2D_ORB, _1996)

ASSERT_EQ(0, roiViolations);
}

TEST(Features2D_ORB, crash)
{
cv::Mat image = cv::Mat::zeros(cv::Size(1920, 1080), CV_8UC3);

int nfeatures = 8000;
float orbScaleFactor = 1.2f;
int nlevels = 18;
int edgeThreshold = 4;
int firstLevel = 0;
int WTA_K = 2;
int scoreType = cv::ORB::HARRIS_SCORE;
int patchSize = 47;
int fastThreshold = 20;

Ptr<ORB> orb = cv::ORB::create(nfeatures, orbScaleFactor, nlevels, edgeThreshold, firstLevel, WTA_K, scoreType, patchSize, fastThreshold);

std::vector<cv::KeyPoint> keypoints;
cv::Mat descriptors;

cv::KeyPoint kp;
kp.pt.x = 443;
kp.pt.y = 5;
kp.size = 47;
kp.angle = 53.4580612f;
kp.response = 0.0000470733867f;
kp.octave = 0;
kp.class_id = -1;

keypoints.push_back(kp);

ASSERT_NO_THROW(orb->compute(image, keypoints, descriptors));
}

0 comments on commit c64ac42

Please sign in to comment.