@@ -673,7 +673,7 @@ class ORB_Impl : public ORB
673
673
void setEdgeThreshold (int edgeThreshold_) { edgeThreshold = edgeThreshold_; }
674
674
int getEdgeThreshold () const { return edgeThreshold; }
675
675
676
- void setFirstLevel (int firstLevel_) { firstLevel = firstLevel_; }
676
+ void setFirstLevel (int firstLevel_) { CV_Assert (firstLevel >= 0 ); firstLevel = firstLevel_; }
677
677
int getFirstLevel () const { return firstLevel; }
678
678
679
679
void setWTA_K (int wta_k_) { wta_k = wta_k_; }
@@ -1014,7 +1014,7 @@ void ORB_Impl::detectAndCompute( InputArray _image, InputArray _mask,
1014
1014
1015
1015
int level_dy = image.rows + border*2 ;
1016
1016
Point level_ofs (0 ,0 );
1017
- Size bufSize ((image.cols + border*2 + 15 ) & -16 , 0 );
1017
+ Size bufSize ((cvRound ( image.cols / getScale ( 0 , firstLevel, scaleFactor)) + border*2 + 15 ) & -16 , 0 );
1018
1018
1019
1019
for ( level = 0 ; level < nLevels; level++ )
1020
1020
{
@@ -1082,8 +1082,11 @@ void ORB_Impl::detectAndCompute( InputArray _image, InputArray _mask,
1082
1082
copyMakeBorder (mask, extMask, border, border, border, border,
1083
1083
BORDER_CONSTANT+BORDER_ISOLATED);
1084
1084
}
1085
- prevImg = currImg;
1086
- prevMask = currMask;
1085
+ if (level > firstLevel)
1086
+ {
1087
+ prevImg = currImg;
1088
+ prevMask = currMask;
1089
+ }
1087
1090
}
1088
1091
1089
1092
if ( useOCL )
@@ -1194,6 +1197,7 @@ void ORB_Impl::detectAndCompute( InputArray _image, InputArray _mask,
1194
1197
Ptr<ORB> ORB::create (int nfeatures, float scaleFactor, int nlevels, int edgeThreshold,
1195
1198
int firstLevel, int wta_k, int scoreType, int patchSize, int fastThreshold)
1196
1199
{
1200
+ CV_Assert (firstLevel >= 0 );
1197
1201
return makePtr<ORB_Impl>(nfeatures, scaleFactor, nlevels, edgeThreshold,
1198
1202
firstLevel, wta_k, scoreType, patchSize, fastThreshold);
1199
1203
}
0 commit comments