ORB crashes when no keypoints are available (Bug #3878)


Added by Philipp Hasper over 10 years ago. Updated over 10 years ago.


Status:Done Start date:2014-08-22
Priority:High Due date:
Assignee:Vadim Pisarevsky % Done:

100%

Category:features2d
Target version:3.0-beta
Affected version:branch 'master' (3.0-dev) Operating System:Any
Difficulty:Easy HW Platform:Any
Pull request:https://github.com/Itseez/opencv/pull/3151

Description

ORB crashes in debug mode with a vector subscript out of range exception when no keypoint could be detected. I believe this is because of
template<typename _Tp> inline void copyVectorToUMat(const std::vector<_Tp>& v, OutputArray um)
{
if(v.empty())
um.release();
Mat(1, (int)(v.size()*sizeof(v[0])), CV_8U, (void*)&v[0]).copyTo(um);
} @
in Orb.cpp:
if v is empty, v0 fails - which is not tragic in release because of the multiplication with v.size().
To resolve this, we need to add an else.

However, I think the case of no keypoints being in the image should be handled a little higher up in the chain, too - maye in the function computeKeyPoints() directly after line 807:

std::vector<Vec3i> ukeypoints_buf;

nkeypoints = (int)allKeypoints.size();
@if(nkeypoints == 0)
//quit further processing


Associated revisions

Revision 109b6965
Added by Vadim Pisarevsky almost 10 years ago

Merge pull request #3878 from mshabunin:fix-python

History

Updated by Philipp Hasper over 10 years ago

  • % Done changed from 0 to 100
  • Status changed from New to Done

Also available in: Atom PDF