1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-31 00:03:03 +04:00

Merge pull request #10646 from take1014:master

* Add a new interface for hough transform

* Fixed warning code

* Fix HoughLinesUsingSetOfPoints based on HoughLinesStandard

* Delete memset

* Rename HoughLinesUsingSetOfPoints and add common function

* Fix test error

* Change static function name

* Change using CV_Assert instead of if-block and add integer test case

* I solve the conflict and delete 'std :: tr1' and changed it to use 'tuple'

* I deleted std::tr1::get and changed int to use 'get'

* Fixed sample code

* revert test_main.cpp

* Delete sample code in comment and add snippets

* Change file name

* Delete static function

* Fixed build error
This commit is contained in:
take1014
2018-02-09 04:54:43 +09:00
committed by Alexander Alekhin
parent d56b2b56fb
commit 03407a9da0
4 changed files with 235 additions and 20 deletions
+78
View File
@@ -139,6 +139,29 @@ public:
}
};
typedef tuple<double, double, double, double> HoughLinesPointSetInput_t;
class HoughLinesPointSetTest : public testing::TestWithParam<HoughLinesPointSetInput_t>
{
protected:
void run_test();
double Rho;
double Theta;
double rhoMin, rhoMax, rhoStep;
double thetaMin, thetaMax, thetaStep;
public:
HoughLinesPointSetTest()
{
rhoMin = get<0>(GetParam());
rhoMax = get<1>(GetParam());
rhoStep = (rhoMax - rhoMin) / 360.0f;
thetaMin = get<2>(GetParam());
thetaMax = get<3>(GetParam());
thetaStep = CV_PI / 180.0f;
Rho = 320.00000;
Theta = 1.04719;
}
};
void BaseHoughLineTest::run_test(int type)
{
string filename = cvtest::TS::ptr()->get_data_path() + picture_name;
@@ -195,6 +218,50 @@ void BaseHoughLineTest::run_test(int type)
#endif
}
void HoughLinesPointSetTest::run_test(void)
{
Mat lines_f, lines_i;
vector<Point2f> pointf;
vector<Point2i> pointi;
vector<Vec3d> line_polar_f, line_polar_i;
const float Points[20][2] = {
{ 0.0f, 369.0f }, { 10.0f, 364.0f }, { 20.0f, 358.0f }, { 30.0f, 352.0f },
{ 40.0f, 346.0f }, { 50.0f, 341.0f }, { 60.0f, 335.0f }, { 70.0f, 329.0f },
{ 80.0f, 323.0f }, { 90.0f, 318.0f }, { 100.0f, 312.0f }, { 110.0f, 306.0f },
{ 120.0f, 300.0f }, { 130.0f, 295.0f }, { 140.0f, 289.0f }, { 150.0f, 284.0f },
{ 160.0f, 277.0f }, { 170.0f, 271.0f }, { 180.0f, 266.0f }, { 190.0f, 260.0f }
};
// Float
for (int i = 0; i < 20; i++)
{
pointf.push_back(Point2f(Points[i][0],Points[i][1]));
}
HoughLinesPointSet(pointf, lines_f, 20, 1,
rhoMin, rhoMax, rhoStep,
thetaMin, thetaMax, thetaStep);
lines_f.copyTo( line_polar_f );
// Integer
for( int i = 0; i < 20; i++ )
{
pointi.push_back( Point2i( (int)Points[i][0], (int)Points[i][1] ) );
}
HoughLinesPointSet( pointi, lines_i, 20, 1,
rhoMin, rhoMax, rhoStep,
thetaMin, thetaMax, thetaStep );
lines_i.copyTo( line_polar_i );
EXPECT_EQ((int)(line_polar_f.at(0).val[1] * 100000.0f), (int)(Rho * 100000.0f));
EXPECT_EQ((int)(line_polar_f.at(0).val[2] * 100000.0f), (int)(Theta * 100000.0f));
EXPECT_EQ((int)(line_polar_i.at(0).val[1] * 100000.0f), (int)(Rho * 100000.0f));
EXPECT_EQ((int)(line_polar_i.at(0).val[2] * 100000.0f), (int)(Theta * 100000.0f));
}
TEST_P(StandartHoughLinesTest, regression)
{
run_test(STANDART);
@@ -205,6 +272,11 @@ TEST_P(ProbabilisticHoughLinesTest, regression)
run_test(PROBABILISTIC);
}
TEST_P(HoughLinesPointSetTest, regression)
{
run_test();
}
INSTANTIATE_TEST_CASE_P( ImgProc, StandartHoughLinesTest, testing::Combine(testing::Values( "shared/pic5.png", "../stitching/a1.png" ),
testing::Values( 1, 10 ),
testing::Values( 0.05, 0.1 ),
@@ -219,4 +291,10 @@ INSTANTIATE_TEST_CASE_P( ImgProc, ProbabilisticHoughLinesTest, testing::Combine(
testing::Values( 0, 4 )
));
INSTANTIATE_TEST_CASE_P( Imgproc, HoughLinesPointSetTest, testing::Combine(testing::Values( 0.0f, 120.0f ),
testing::Values( 360.0f, 480.0f ),
testing::Values( 0.0f, (CV_PI / 18.0f) ),
testing::Values( (CV_PI / 2.0f), (CV_PI * 5.0f / 12.0f) )
));
}} // namespace