Ask Your Question
3

Please give directions on how to apply createGeneralizedHoughBallard()

asked 2015-05-28 09:42:22 -0600

Sheng Liu gravatar image

updated 2015-09-01 10:46:38 -0600

Recently I find the Ptr<GeneralizedHoughBallard> cv::createGeneralizedHoughBallard () and Ptr<GeneralizedHoughGuil> cv::createGeneralizedHoughGuil () here. It is said they can detect arbitrary shapes and bidimensional shape. But I don't know how to use them. Could anyone provide some specific examples or give me some directions on how to apply them?

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
1

answered 2015-05-29 02:01:52 -0600

berak gravatar image

updated 2015-05-29 02:07:03 -0600

here's some (very sloppy, sorry for that) attempt, let's just try some template matching:

image description

Mat m = imread("im/6JULySd.png",0);
//Rect r(37,18,37,61);
//yea, i'm cheating, that's the 2nd '1', it did not work so easily with the 1st ;)
Rect r(182,19,42,63); 
Mat templ(m,r);

Ptr<GeneralizedHough> gh = createGeneralizedHoughBallard();
//Ptr<GeneralizedHough> gh = createGeneralizedHoughGuil();
gh->setTemplate(templ);
Mat_<Vec4f> pos; //an array of (x,y,1,0) tuples
gh->detect(m,pos);
cerr << pos << endl;
for (int i=0; i<pos.total(); i++)
{
    Vec4f p = pos.at<Vec4f>(i);
    circle(m,Point(p[0],p[1]),r.height/2,Scalar(255),2);
}


[59, 50, 1, 0, 203, 50, 1, 0]

image description

(well, again, this example is a cheat from the 1st line to the last. in real life, you'd have to improve a lot of params, like angles, distances, cannyThresholds and what not. feel free, to improve, and come back !)

edit flag offensive delete link more

Comments

1

Thanks for your help.

Sheng Liu gravatar imageSheng Liu ( 2015-05-29 05:35:22 -0600 )edit

Question Tools

2 followers

Stats

Asked: 2015-05-28 09:42:22 -0600

Seen: 655 times

Last updated: May 29 '15