mirror of
https://github.com/opencv/opencv.git
synced 2025-01-18 22:44:02 +08:00
fix: estimateChessboardSharpness triggers out of range test
Problem is that iter1 += tcols, iter2 += tcols are called without check. row < trows - 1 check is processed after increment in "for" statements.
This commit is contained in:
parent
034a5f140c
commit
d594e72586
@ -3323,14 +3323,16 @@ cv::Scalar Chessboard::Board::calcEdgeSharpness(cv::InputArray _img,float rise_d
|
||||
// build vertical lines
|
||||
for(int col = 1;col< tcols-1;++col)
|
||||
{
|
||||
std::vector<cv::Point2f>::const_iterator iter1 = centers.begin()+col;
|
||||
std::vector<cv::Point2f>::const_iterator iter2 = iter1+tcols;
|
||||
for(int row= 0;row<trows-1;++row,iter1+=tcols,iter2+=tcols)
|
||||
pairs.push_back(std::make_pair(*iter1,*iter2));
|
||||
// avoid using iterators to not trigger out of range
|
||||
int i1 = col;
|
||||
int i2 = i1 + tcols;
|
||||
for (int row = 0; row < trows - 1; ++row, i1 += tcols, i2 += tcols)
|
||||
{
|
||||
pairs.push_back(std::make_pair(centers[i1], centers[i2]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// calc edge response for each line
|
||||
cv::Rect rect(0,0,img.cols,img.rows);
|
||||
std::vector<std::pair<cv::Point2f,cv::Point2f> >::const_iterator iter = pairs.begin();
|
||||
|
Loading…
Reference in New Issue
Block a user