Fix segFault when no lines found in BinaryDescriptor

pull/855/head
Vladislav Sovrasov 8 years ago
parent f3ca1a2f08
commit 862e03c43b
  1. 5
      modules/line_descriptor/src/binary_descriptor.cpp
  2. 15
      modules/line_descriptor/test/test_descriptors_regression.cpp

@ -2196,6 +2196,11 @@ int BinaryDescriptor::EDLineDetector::EdgeDrawing( cv::Mat &image, EdgeChains &e
"numofedgePixel1 = " << offsetPFirst << ", numofedgePixel2 = " << offsetPSecond << ", MaxNumOfEdgePixel=" << edgePixelArraySize << std::endl;
return -1;
}
if( !(offsetPFirst && offsetPSecond) )
{
std::cout << "Edge drawing Error: lines not found" << std::endl;
return -1;
}
/*now all the edge information are stored in pFirstPartEdgeX_, pFirstPartEdgeY_,
*pFirstPartEdgeS_, pSecondPartEdgeX_, pSecondPartEdgeY_, pSecondPartEdgeS_;

@ -372,3 +372,18 @@ TEST( BinaryDescriptor_Descriptors, regression )
CV_BD_DescriptorsTest<Hamming> test( std::string( "lbd_descriptors_cameraman" ), 1 );
test.safe_run();
}
/****************************************************************************************\
* Other tests *
\****************************************************************************************/
TEST( BinaryDescriptor, no_lines_found )
{
Mat Image = Mat::zeros(100, 100, CV_8U);
Ptr<line_descriptor::BinaryDescriptor> binDescriptor =
line_descriptor::BinaryDescriptor::createBinaryDescriptor();
std::vector<cv::line_descriptor::KeyLine> keyLines;
binDescriptor->detect(Image, keyLines);
ASSERT_EQ(keyLines.size(), 0u);
}

Loading…
Cancel
Save