Ask Your Question
0

positive image cropping haar cascades

asked 2016-11-07 11:33:50 -0600

rors100 gravatar image

Hi,

Im taking my first steps in making a haar cascade for custom object recognition. Ive spent time getting a fair bit of data and wrote some preprocessing scripts to convert videos to frames. My next step is to crop the object of interes in order to create some positive training examples. I have a few questions which i genuinely have looked around for answers online - i'm slightly confused:-

  1. I read i should aim to keep the aspect ratio the same (http://note.sonots.com/SciSoftware/ha...) - does this mean the same as the original frame OR for all images that i want to use for positive training examples (i.e. frames from completely different videos)

  2. Size - aspect ratio and sizing are obviously not the same. So again do i need to ensure my positive samples are all the same height and width (im pretty sure they should be but thought worth double checking).

  3. Negative samples - should these all be the same aspect ratio and / or size?

I understand this is a probably a very low level/ silly question however it's been far from clear what best practice is here!

Thanks

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
1

answered 2016-11-09 06:09:47 -0600

updated 2016-11-09 06:10:48 -0600

Let me reply to your questions, since I got quite the background using the specific technique

  1. Part one of question one is complete bullshit. Your ROI of your objects should correspond to the physical dimensions in real life and thus that width/height ratio, but not correspond to the image dimensions in which it was captured.
  2. Second part of question one is partially right. In the createsamples step, it will basically take your annotations and rescale them to the model dimensions. If your ratio is quite fluxuating, then all your samples will be rescaled to a fixed size ratio, introducing undesired deformations. Think of deforming a flat rectangle to a square model size. It will push together all data in some direction.
  3. Like said, answer on question 2 is that ratio should be about same during annotation. Enforcing the ratio to all samples will be done by the opencv_createsamples tool.
  4. No - negative images can be as random as you want!

Also I collected all my own good practices in a book chapter, in the OpenCV 3 Blueprints book. It might come in handy for you!

edit flag offensive delete link more

Comments

Hi,

Thanks for the answer - good feedback.

I ran the classifier for two days attempting to train it based around a width of 40 and height of 80. It ran for 15 out of 20 stages but then hung. I decided to cancel the training after a day at stage 14 and compiled what i had into a haar xml. Unfortunately it does not seem to be detecting anything!

Im going to try again and use the cloud to speed up training time!

rors100 gravatar imagerors100 ( 2016-11-09 10:43:38 -0600 )edit

ok actually i take that back - it is working (kind of....) its just not that accurate right now.

It hung at the 15th stage plus it took ages to train so to improve im thinking:

Add in more negatives and more positives. I do have them and now this size issue has been clarified i can get a bunch more positives in the mix. Initially i had 1030 negatives and 80 positives. I will also add in some variety to my negatives. The use case i have in mind is quite specific so i used a lot of negatives from that environment however im thinking now i should add in some more negatives from different environments.

Deploy via the the cloud for faster training time. My local device was out of action for two days.

rors100 gravatar imagerors100 ( 2016-11-09 12:31:49 -0600 )edit

@rors100 if you want more valuable feedback, update your question with sample data, training commands, parameters and training output. It is kind of the only we to give you situation specific information. That being said, stick to application specific negatives and positives, that should do the trick, heck I am focussing my PhD around that concept.

StevenPuttemans gravatar imageStevenPuttemans ( 2016-11-10 02:16:11 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2016-11-07 11:33:50 -0600

Seen: 1,174 times

Last updated: Nov 09 '16