Commit bd619c55 authored by Alexander Alekhin's avatar Alexander Alekhin

Merge pull request #868 from sovrasov:line_descr_crash_fix

parents 47fbdd0d 0cd4ff44
......@@ -511,7 +511,15 @@ void BinaryDescriptor::detectImpl( const Mat& imageSrc, std::vector<KeyLine>& ke
{
for ( size_t keyCounter = 0; keyCounter < keylines.size(); keyCounter++ )
{
KeyLine kl = keylines[keyCounter];
KeyLine& kl = keylines[keyCounter];
//due to imprecise floating point scaling in the pyramid a little overflow can occur in line coordinates,
//especially on big images. It will be fixed here
kl.startPointX = (float)std::min((int)kl.startPointX, mask.cols - 1);
kl.startPointY = (float)std::min((int)kl.startPointY, mask.rows - 1);
kl.endPointX = (float)std::min((int)kl.endPointX, mask.cols - 1);
kl.endPointY = (float)std::min((int)kl.endPointY, mask.rows - 1);
if( mask.at < uchar > ( (int) kl.startPointY, (int) kl.startPointX ) == 0 && mask.at < uchar > ( (int) kl.endPointY, (int) kl.endPointX ) == 0 )
keylines.erase( keylines.begin() + keyCounter );
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment