3

I need to train a cascaded classifier to detect vehicles and different viewing angles. I'm using OpenCV.

Some of the angles that I need to capture cause the placement of the vehicle within the image to be diagonal, as shown below:

enter image description here

Now the problem with this is that because the vehicle is diagonally placed across the image, then there's a lot of unnecessary background which I can't crop out simply because images have to be rectangular. Is there another way to build positive samples for diagonally placed angles/perspectives of objects? I do need the classifier to be able to recognize this specific view of an object. It isn't so bad in the car above, because a car doesn't have a huge difference between its length and width. But if I do the same with a truck for example, which is several times longer than it is wide, then the images end up having more background than object of interest in them, like below. I'm worried about whether this is good or bad for classification, and if there's any solution.

Will a classifier recognize a specific angle of a vehicle regardless of which way it's rotated on the background? And in that case, would it be better to rotate the entire truck image such that the truck is horizontal/vertical, then clip the rest of the image?

enter image description here

user961627
  • 12,379
  • 42
  • 136
  • 210

1 Answers1

6

Q: Will a classifier recognize a specific angle of a vehicle regardless of which way it's rotated on the background?

A: Nope. A classifier cannot recognize a specific angle of vehicle regardless of what way it is rotated. (Talking about Haar-like features here).There is a concept created to introduce tilted 45° Haar-like feature to improve "dimensionality" which is pretty successful from research papers I read on it in the past.

There was also an attempt to introduce generic rotated haar-like features, but it was pretty much unsuccessful from my memory. However if you are going to use super high resolution image, chances are it will work. But I won't bet money on it.

Q: To your whole problem

A: Background in positive image samples may not necessarily affect detection badly. From case to case basis, it may actually help in your detection.

My solution(if you really have to use classifiers), at least for image based detection, is to make use of OpenCV rotate() function. Where you keep rotating the image from 1° to 360°(like maybe 10° each time) and keep applying the classifiers each time. Detection time may take slightly longer, but I don't think it will be more than a few seconds.

For video wise, it will be super laggy if I am not wrong. Do give it a shot if time permits.

Another thing I wish to raise is that your vehicles(like the truck and the car), have very different features. If I were you, I would split them into different classifiers and run them at the same time for vehicle detection (Done it before with 3 different classifiers, eyes, hand and face with real time results).

If you are intending to train them into one classifier, it may or may not work, so do look into my suggestion to be on the safe side.

You may also want to look at this links: http://docs.opencv.org/modules/objdetect/doc/latent_svm.html (classifier more commonly used for objects detection. I always used haar, so have no experience in regards to this clasifier. Sorry)

http://www.araa.asn.au/acra/acra2006/papers/paper_5_63.pdf (rotation-based, contradicts my answer a little. But I stand on my case that if the image's resolution is not high enough, there maybe a lot of rounding errors.)

Hope my answer helped you. Good luck (: Do comment if you need anymore help or anything is unclear.

rockinfresh
  • 2,068
  • 4
  • 28
  • 46
  • Thanks a lot. That definitely helped. Yes I am using different classifiers, I have 3 different classifiers for each different type of vehicle. About haar features, I am thinking of using HoG instead, because I learned that for Haar features, all the positive samples need to be lined up so that for eg. tyres always show up in the same relative spot, etc. Is that true? It seems difficult and very tedious given that I have about 1000 samples. – user961627 Feb 04 '14 at 14:06
  • 1
    @user961627, Yup.That's true for an ideal Haar classifier. It's best that the positive samples are always in the same relative spot. Are you using object marker to mark out the vehicles? If so, then your problem is kind of solved? if you are talking about the vehicle being randomly placed diagonally at different part of the image. But it's still going to be tedious though. Maybe about 2 to 5 seconds to mark one image. – rockinfresh Feb 06 '14 at 04:39
  • HoG should work too. While I am not too sure about the accuracy of HoG, I do know that Haar Classifier is faster than HoG in terms of detection time. – rockinfresh Feb 06 '14 at 04:41
  • What about negative samples? http://stackoverflow.com/questions/22419545/negative-sample-image-dimensions-for-training-cascaded-classifier-in-opencv – user961627 Mar 15 '14 at 04:30