Commit 965b3759 authored by Daniel Angelov's avatar Daniel Angelov

Update on the class to reflect the review. Split the class into virtual and…

Update on the class to reflect the review. Split the class into virtual and implementation. change of name to LineSegmentDetector, using Input/Output-Arrays, general clean ups.
parent 694d9ff2
This diff is collapsed.
This diff is collapsed.
......@@ -23,26 +23,26 @@ protected:
virtual void SetUp();
};
class LSD_ADV: public LSDBase
class Imgproc_LSD_ADV: public LSDBase
{
public:
LSD_ADV() {};
Imgproc_LSD_ADV() {};
protected:
};
class LSD_STD: public LSDBase
class Imgproc_LSD_STD: public LSDBase
{
public:
LSD_STD() {};
Imgproc_LSD_STD() {};
protected:
};
class LSD_NONE: public LSDBase
class Imgproc_LSD_NONE: public LSDBase
{
public:
LSD_NONE() {};
Imgproc_LSD_NONE() {};
protected:
};
......@@ -92,7 +92,7 @@ void LSDBase::GenerateRotatedRect(Mat& image)
rRect.points(vertices);
for (int i = 0; i < 4; i++)
{
line(image, vertices[i], vertices[(i + 1) % 4], Scalar(255));
line(image, vertices[i], vertices[(i + 1) % 4], Scalar(255), 3);
}
}
......@@ -103,110 +103,113 @@ void LSDBase::SetUp()
}
TEST_F(LSD_ADV, whiteNoise)
TEST_F(Imgproc_LSD_ADV, whiteNoise)
{
GenerateWhiteNoise(test_image);
LSD detector(LSD_REFINE_ADV);
detector.detect(test_image, lines);
LineSegmentDetector* detector = createLineSegmentDetectorPtr(LSD_REFINE_ADV);
detector->detect(test_image, lines);
ASSERT_GE((unsigned int)(40), lines.size());
}
TEST_F(LSD_ADV, constColor)
TEST_F(Imgproc_LSD_ADV, constColor)
{
GenerateConstColor(test_image);
LSD detector(LSD_REFINE_ADV);
detector.detect(test_image, lines);
LineSegmentDetector* detector = createLineSegmentDetectorPtr(LSD_REFINE_ADV);
detector->detect(test_image, lines);
ASSERT_EQ((unsigned int)(0), lines.size());
}
TEST_F(LSD_ADV, lines)
TEST_F(Imgproc_LSD_ADV, lines)
{
const unsigned int numOfLines = 3;
GenerateLines(test_image, numOfLines);
LSD detector(LSD_REFINE_ADV);
detector.detect(test_image, lines);
LineSegmentDetector* detector = createLineSegmentDetectorPtr(LSD_REFINE_ADV);
detector->detect(test_image, lines);
ASSERT_EQ(numOfLines * 2, lines.size()); // * 2 because of Gibbs effect
}
TEST_F(LSD_ADV, rotatedRect)
TEST_F(Imgproc_LSD_ADV, rotatedRect)
{
GenerateRotatedRect(test_image);
LSD detector(LSD_REFINE_ADV);
detector.detect(test_image, lines);
ASSERT_LE((unsigned int)(4), lines.size());
LineSegmentDetector* detector = createLineSegmentDetectorPtr(LSD_REFINE_ADV);
detector->detect(test_image, lines);
ASSERT_LE((unsigned int)(2), lines.size());
}
TEST_F(LSD_STD, whiteNoise)
TEST_F(Imgproc_LSD_STD, whiteNoise)
{
GenerateWhiteNoise(test_image);
LSD detector(LSD_REFINE_STD);
detector.detect(test_image, lines);
LineSegmentDetector* detector = createLineSegmentDetectorPtr(LSD_REFINE_STD);
detector->detect(test_image, lines);
ASSERT_GE((unsigned int)(50), lines.size());
}
TEST_F(LSD_STD, constColor)
TEST_F(Imgproc_LSD_STD, constColor)
{
GenerateConstColor(test_image);
LSD detector(LSD_REFINE_STD);
detector.detect(test_image, lines);
LineSegmentDetector* detector = createLineSegmentDetectorPtr(LSD_REFINE_STD);
detector->detect(test_image, lines);
ASSERT_EQ((unsigned int)(0), lines.size());
}
TEST_F(LSD_STD, lines)
TEST_F(Imgproc_LSD_STD, lines)
{
const unsigned int numOfLines = 3; //1
GenerateLines(test_image, numOfLines);
LSD detector(LSD_REFINE_STD);
detector.detect(test_image, lines);
LineSegmentDetector* detector = createLineSegmentDetectorPtr(LSD_REFINE_STD);
detector->detect(test_image, lines);
ASSERT_EQ(numOfLines * 2, lines.size()); // * 2 because of Gibbs effect
}
TEST_F(LSD_STD, rotatedRect)
TEST_F(Imgproc_LSD_STD, rotatedRect)
{
GenerateRotatedRect(test_image);
LSD detector(LSD_REFINE_STD);
detector.detect(test_image, lines);
ASSERT_EQ((unsigned int)(8), lines.size());
LineSegmentDetector* detector = createLineSegmentDetectorPtr(LSD_REFINE_STD);
detector->detect(test_image, lines);
ASSERT_LE((unsigned int)(4), lines.size());
}
TEST_F(LSD_NONE, whiteNoise)
TEST_F(Imgproc_LSD_NONE, whiteNoise)
{
GenerateWhiteNoise(test_image);
LSD detector(LSD_REFINE_NONE);
detector.detect(test_image, lines);
LineSegmentDetector* detector = createLineSegmentDetectorPtr(LSD_REFINE_STD);
detector->detect(test_image, lines);
ASSERT_GE((unsigned int)(50), lines.size());
}
TEST_F(LSD_NONE, constColor)
TEST_F(Imgproc_LSD_NONE, constColor)
{
GenerateConstColor(test_image);
LSD detector(LSD_REFINE_NONE);
detector.detect(test_image, lines);
LineSegmentDetector* detector = createLineSegmentDetectorPtr(LSD_REFINE_NONE);
detector->detect(test_image, lines);
ASSERT_EQ((unsigned int)(0), lines.size());
}
TEST_F(LSD_NONE, lines)
TEST_F(Imgproc_LSD_NONE, lines)
{
const unsigned int numOfLines = 3; //1
GenerateLines(test_image, numOfLines);
LSD detector(LSD_REFINE_NONE);
detector.detect(test_image, lines);
LineSegmentDetector* detector = createLineSegmentDetectorPtr(LSD_REFINE_NONE);
detector->detect(test_image, lines);
ASSERT_EQ(numOfLines * 2, lines.size()); // * 2 because of Gibbs effect
}
TEST_F(LSD_NONE, rotatedRect)
TEST_F(Imgproc_LSD_NONE, rotatedRect)
{
GenerateRotatedRect(test_image);
LSD detector(LSD_REFINE_NONE);
detector.detect(test_image, lines);
ASSERT_EQ((unsigned int)(8), lines.size());
LineSegmentDetector* detector = createLineSegmentDetectorPtr(LSD_REFINE_NONE);
detector->detect(test_image, lines);
ASSERT_LE((unsigned int)(8), lines.size());
}
......@@ -22,28 +22,28 @@ int main(int argc, char** argv)
Mat image = imread(in, IMREAD_GRAYSCALE);
// Create and LSD detector with std refinement.
LSD lsd_std(LSD_REFINE_STD);
LineSegmentDetector* lsd_std = createLineSegmentDetectorPtr(LSD_REFINE_STD);
double start = double(getTickCount());
vector<Vec4i> lines_std;
lsd_std.detect(image, lines_std);
lsd_std->detect(image, lines_std);
double duration_ms = (double(getTickCount()) - start) * 1000 / getTickFrequency();
std::cout << "OpenCV STD (blue) - " << duration_ms << " ms." << std::endl;
// Create an LSD detector with no refinement applied.
LSD lsd_none(LSD_REFINE_NONE);
LineSegmentDetector* lsd_none = createLineSegmentDetectorPtr(LSD_REFINE_NONE);
start = double(getTickCount());
vector<Vec4i> lines_none;
lsd_none.detect(image, lines_none);
lsd_none->detect(image, lines_none);
duration_ms = (double(getTickCount()) - start) * 1000 / getTickFrequency();
std::cout << "OpenCV NONE (red)- " << duration_ms << " ms." << std::endl;
std::cout << "Overlapping pixels are shown in purple." << std::endl;
Mat difference = Mat::zeros(image.size(), CV_8UC1);
LSD::compareSegments(image.size(), lines_std, lines_none, &difference);
lsd_none->compareSegments(image.size(), lines_std, lines_none, &difference);
imshow("Line difference", difference);
Mat drawnLines(image);
LSD::drawSegments(drawnLines, lines_std);
lsd_none->drawSegments(drawnLines, lines_std);
imshow("Standard refinement", drawnLines);
waitKey();
......
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