Merge pull request #1526 from vpisarev:linedetector_python

This commit is contained in:
Roman Donchenko 2013-10-01 19:49:16 +04:00 committed by OpenCV Buildbot
commit 184ae873d4
6 changed files with 24 additions and 23 deletions

View File

@ -509,11 +509,11 @@ Line segment detector class, following the algorithm described at [Rafael12]_.
.. ocv:class:: LineSegmentDetector : public Algorithm
createLineSegmentDetectorPtr
----------------------------
createLineSegmentDetector
-------------------------
Creates a smart pointer to a LineSegmentDetector object and initializes it.
.. ocv:function:: Ptr<LineSegmentDetector> createLineSegmentDetectorPtr(int _refine = LSD_REFINE_STD, double _scale = 0.8, double _sigma_scale = 0.6, double _quant = 2.0, double _ang_th = 22.5, double _log_eps = 0, double _density_th = 0.7, int _n_bins = 1024)
.. ocv:function:: Ptr<LineSegmentDetector> createLineSegmentDetector(int _refine = LSD_REFINE_STD, double _scale = 0.8, double _sigma_scale = 0.6, double _quant = 2.0, double _ang_th = 22.5, double _log_eps = 0, double _density_th = 0.7, int _n_bins = 1024)
:param _refine: The way found lines will be refined:

View File

@ -904,7 +904,7 @@ protected:
Point2f bottomRight;
};
class LineSegmentDetector : public Algorithm
class CV_EXPORTS_W LineSegmentDetector : public Algorithm
{
public:
/**
@ -926,7 +926,7 @@ public:
* * 1 corresponds to 0.1 mean false alarms
* This vector will be calculated _only_ when the objects type is REFINE_ADV
*/
virtual void detect(InputArray _image, OutputArray _lines,
CV_WRAP virtual void detect(InputArray _image, OutputArray _lines,
OutputArray width = noArray(), OutputArray prec = noArray(),
OutputArray nfa = noArray()) = 0;
@ -937,7 +937,7 @@ public:
* Should have the size of the image, where the lines were found
* @param lines The lines that need to be drawn
*/
virtual void drawSegments(InputOutputArray _image, InputArray lines) = 0;
CV_WRAP virtual void drawSegments(InputOutputArray _image, InputArray lines) = 0;
/**
* Draw both vectors on the image canvas. Uses blue for lines 1 and red for lines 2.
@ -949,13 +949,13 @@ public:
* Should have the size of the image, where the lines were found
* @return The number of mismatching pixels between lines1 and lines2.
*/
virtual int compareSegments(const Size& size, InputArray lines1, InputArray lines2, InputOutputArray _image = noArray()) = 0;
CV_WRAP virtual int compareSegments(const Size& size, InputArray lines1, InputArray lines2, InputOutputArray _image = noArray()) = 0;
virtual ~LineSegmentDetector() {};
};
//! Returns a pointer to a LineSegmentDetector class.
CV_EXPORTS Ptr<LineSegmentDetector> createLineSegmentDetectorPtr(
CV_EXPORTS_W Ptr<LineSegmentDetector> createLineSegmentDetector(
int _refine = LSD_REFINE_STD, double _scale = 0.8,
double _sigma_scale = 0.6, double _quant = 2.0, double _ang_th = 22.5,
double _log_eps = 0, double _density_th = 0.7, int _n_bins = 1024);

View File

@ -388,7 +388,7 @@ private:
/////////////////////////////////////////////////////////////////////////////////////////
CV_EXPORTS Ptr<LineSegmentDetector> createLineSegmentDetectorPtr(
CV_EXPORTS Ptr<LineSegmentDetector> createLineSegmentDetector(
int _refine, double _scale, double _sigma_scale, double _quant, double _ang_th,
double _log_eps, double _density_th, int _n_bins)
{

View File

@ -110,7 +110,7 @@ TEST_F(Imgproc_LSD_ADV, whiteNoise)
for (int i = 0; i < EPOCHS; ++i)
{
GenerateWhiteNoise(test_image);
Ptr<LineSegmentDetector> detector = createLineSegmentDetectorPtr(LSD_REFINE_ADV);
Ptr<LineSegmentDetector> detector = createLineSegmentDetector(LSD_REFINE_ADV);
detector->detect(test_image, lines);
if(40u >= lines.size()) ++passedtests;
@ -123,7 +123,7 @@ TEST_F(Imgproc_LSD_ADV, constColor)
for (int i = 0; i < EPOCHS; ++i)
{
GenerateConstColor(test_image);
Ptr<LineSegmentDetector> detector = createLineSegmentDetectorPtr(LSD_REFINE_ADV);
Ptr<LineSegmentDetector> detector = createLineSegmentDetector(LSD_REFINE_ADV);
detector->detect(test_image, lines);
if(0u == lines.size()) ++passedtests;
@ -137,7 +137,7 @@ TEST_F(Imgproc_LSD_ADV, lines)
{
const unsigned int numOfLines = 1;
GenerateLines(test_image, numOfLines);
Ptr<LineSegmentDetector> detector = createLineSegmentDetectorPtr(LSD_REFINE_ADV);
Ptr<LineSegmentDetector> detector = createLineSegmentDetector(LSD_REFINE_ADV);
detector->detect(test_image, lines);
if(numOfLines * 2 == lines.size()) ++passedtests; // * 2 because of Gibbs effect
@ -150,7 +150,7 @@ TEST_F(Imgproc_LSD_ADV, rotatedRect)
for (int i = 0; i < EPOCHS; ++i)
{
GenerateRotatedRect(test_image);
Ptr<LineSegmentDetector> detector = createLineSegmentDetectorPtr(LSD_REFINE_ADV);
Ptr<LineSegmentDetector> detector = createLineSegmentDetector(LSD_REFINE_ADV);
detector->detect(test_image, lines);
if(2u <= lines.size()) ++passedtests;
@ -163,7 +163,7 @@ TEST_F(Imgproc_LSD_STD, whiteNoise)
for (int i = 0; i < EPOCHS; ++i)
{
GenerateWhiteNoise(test_image);
Ptr<LineSegmentDetector> detector = createLineSegmentDetectorPtr(LSD_REFINE_STD);
Ptr<LineSegmentDetector> detector = createLineSegmentDetector(LSD_REFINE_STD);
detector->detect(test_image, lines);
if(50u >= lines.size()) ++passedtests;
@ -176,7 +176,7 @@ TEST_F(Imgproc_LSD_STD, constColor)
for (int i = 0; i < EPOCHS; ++i)
{
GenerateConstColor(test_image);
Ptr<LineSegmentDetector> detector = createLineSegmentDetectorPtr(LSD_REFINE_STD);
Ptr<LineSegmentDetector> detector = createLineSegmentDetector(LSD_REFINE_STD);
detector->detect(test_image, lines);
if(0u == lines.size()) ++passedtests;
@ -190,7 +190,7 @@ TEST_F(Imgproc_LSD_STD, lines)
{
const unsigned int numOfLines = 1;
GenerateLines(test_image, numOfLines);
Ptr<LineSegmentDetector> detector = createLineSegmentDetectorPtr(LSD_REFINE_STD);
Ptr<LineSegmentDetector> detector = createLineSegmentDetector(LSD_REFINE_STD);
detector->detect(test_image, lines);
if(numOfLines * 2 == lines.size()) ++passedtests; // * 2 because of Gibbs effect
@ -203,7 +203,7 @@ TEST_F(Imgproc_LSD_STD, rotatedRect)
for (int i = 0; i < EPOCHS; ++i)
{
GenerateRotatedRect(test_image);
Ptr<LineSegmentDetector> detector = createLineSegmentDetectorPtr(LSD_REFINE_STD);
Ptr<LineSegmentDetector> detector = createLineSegmentDetector(LSD_REFINE_STD);
detector->detect(test_image, lines);
if(4u <= lines.size()) ++passedtests;
@ -216,7 +216,7 @@ TEST_F(Imgproc_LSD_NONE, whiteNoise)
for (int i = 0; i < EPOCHS; ++i)
{
GenerateWhiteNoise(test_image);
Ptr<LineSegmentDetector> detector = createLineSegmentDetectorPtr(LSD_REFINE_STD);
Ptr<LineSegmentDetector> detector = createLineSegmentDetector(LSD_REFINE_STD);
detector->detect(test_image, lines);
if(50u >= lines.size()) ++passedtests;
@ -229,7 +229,7 @@ TEST_F(Imgproc_LSD_NONE, constColor)
for (int i = 0; i < EPOCHS; ++i)
{
GenerateConstColor(test_image);
Ptr<LineSegmentDetector> detector = createLineSegmentDetectorPtr(LSD_REFINE_NONE);
Ptr<LineSegmentDetector> detector = createLineSegmentDetector(LSD_REFINE_NONE);
detector->detect(test_image, lines);
if(0u == lines.size()) ++passedtests;
@ -243,7 +243,7 @@ TEST_F(Imgproc_LSD_NONE, lines)
{
const unsigned int numOfLines = 1;
GenerateLines(test_image, numOfLines);
Ptr<LineSegmentDetector> detector = createLineSegmentDetectorPtr(LSD_REFINE_NONE);
Ptr<LineSegmentDetector> detector = createLineSegmentDetector(LSD_REFINE_NONE);
detector->detect(test_image, lines);
if(numOfLines * 2 == lines.size()) ++passedtests; // * 2 because of Gibbs effect
@ -256,7 +256,7 @@ TEST_F(Imgproc_LSD_NONE, rotatedRect)
for (int i = 0; i < EPOCHS; ++i)
{
GenerateRotatedRect(test_image);
Ptr<LineSegmentDetector> detector = createLineSegmentDetectorPtr(LSD_REFINE_NONE);
Ptr<LineSegmentDetector> detector = createLineSegmentDetector(LSD_REFINE_NONE);
detector->detect(test_image, lines);
if(8u <= lines.size()) ++passedtests;

View File

@ -137,6 +137,7 @@ typedef Ptr<StereoSGBM> Ptr_StereoSGBM;
typedef Ptr<cv::softcascade::ChannelFeatureBuilder> Ptr_ChannelFeatureBuilder;
typedef Ptr<CLAHE> Ptr_CLAHE;
typedef Ptr<LineSegmentDetector > Ptr_LineSegmentDetector;
typedef SimpleBlobDetector::Params SimpleBlobDetector_Params;

View File

@ -30,9 +30,9 @@ int main(int argc, char** argv)
// Create and LSD detector with standard or no refinement.
#if 1
Ptr<LineSegmentDetector> ls = createLineSegmentDetectorPtr(LSD_REFINE_STD);
Ptr<LineSegmentDetector> ls = createLineSegmentDetector(LSD_REFINE_STD);
#else
Ptr<LineSegmentDetector> ls = createLineSegmentDetectorPtr(LSD_REFINE_NONE);
Ptr<LineSegmentDetector> ls = createLineSegmentDetector(LSD_REFINE_NONE);
#endif
double start = double(getTickCount());