Ask Your Question
0

Can Haar or Cascade classifiers be accurate enough in detecting object size?

asked 2016-12-18 16:37:31 -0600

ajs gravatar image

updated 2017-08-19 04:04:20 -0600

I'm trying to detect ping pong ball using my own trained Haar classifier(not so good one) and then to calculate ball distance from camera.I calibrated camera and used those parameters alongside with known ball dimensions in real world and ball size on picture,and the formula works fine when I detect ball just the right. The problem is Haar classifier sometimes detect ball slightly smaller, and sometimes slightly bigger then it is in picture so I got wrong distance values.Like here: image description

My question is, can Haar or Cascade classifiers be used for this purpose, or they are here only to detect that there is object but can't detect the exact size? Will the classifier trained on larger set of images be more accurate here?(currently using haar trained on 730 positives and 1870 negatives images on 12 stages)

edit retag flag offensive close merge delete

3 answers

Sort by ยป oldest newest most voted
2

answered 2016-12-19 02:12:43 -0600

Even though Haar cascade returns the Object boundary, It is not Accurate! I would not rely on that results alone! Especially when you are trying to find the distance/depth from the image, you need more accuracy!

So i recommend you to take that as a input and then threshold your image ROI to find the Exact size of your Ball.

edit flag offensive delete link more

Comments

Nice thinking, but I wish to be able to measure distance in different conditions(lighting, background), so wouldn't I then need different threshold values for different cases? That's one of problems why I started to work with machine learning algorithms at first.

ajs gravatar imageajs ( 2016-12-22 10:39:48 -0600 )edit

Of course it has to be dynamic! Moreover it is a plain white ball so estimating wont be that difficult!

Balaji R gravatar imageBalaji R ( 2016-12-22 20:18:55 -0600 )edit
1

answered 2017-02-19 22:10:03 -0600

Netsai Chibuku gravatar image

I agree with the answer by Balaji R. To answer your exact question, the Haar classifier can only detect that there is an object, but cannot detect the exact size. That is because each scale of the classifier will match objects that are the same size as the classifier window , or a bit smaller, or a bit larger. (This is a strength of Haar classifier, it does not miss objects that fall in the gap between 2 scales!) The classifier does not know the size of the match (even in pixels), only the size of the classifier window that matched, which will be very rough estimated.

As Balaji R said. You should do a threshold on your image in the area of the match (possibly adaptive threshold) to get the ball silhouette, then measure the ball area in pixels (it is more accurate than diameter), then determine the distance. You should also undistort the camera image, because otherwise the area and shape of the silhouette will change by lens distortion, and will not correspond accurate to distance.

edit flag offensive delete link more
0

answered 2019-01-30 15:58:28 -0600

That's a pretty cool idea, but I agree with Balaji R, Haar cascades are generally too inaccurate. Can you post/send me the Haar cascade you are using? I am trying to do a project with pin pong ball detection and yours seems to work pretty well. I am on Github @rohan2017. Thanks

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2016-12-18 16:37:31 -0600

Seen: 1,987 times

Last updated: Feb 19 '17