Ask Your Question
0

OpenCV HaarTraining Positive images background

asked 2017-05-30 04:20:34 -0600

Hi all!

I have a few questions about background in positive images for haartraining.

  1. Is it good to have only the desired object in the positive image or to have also some portion of different possible backgrounds?
  2. If it's better to have only the desired object what is the best way to crop it if it has some specific shape? I mean a situation when you can't dispose of all the background because the object is not rectangular? Is it good just to make this background transparent?
edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
1

answered 2017-05-30 05:52:30 -0600

berak gravatar image

while it's technically possible, to generate synthetic positives from a single image, this method won't lead to an accurate training result.

instead, collect a few hundred positives manually (maybe using the opencv_annotation tool), and leave the original background intact.

you don't need to crop the images, but you have to give a list of imagenames/rects to opencv_createsamples. then decide on appropriate width and height for the training.

edit flag offensive delete link more

Comments

Just wanted to clarify some things:

  1. I use many positive images but almost all of them are synthetic (a simple picture of black and white downloaded from Internet) and only few of them I created using a camera. Is this a mistake and should I always make photos or use opencv__annotation?

  2. You say that I don't need to crop an image. But there are many sources that say that we need to reduce an image as much as possible to contain only the object we want to recognize (because all the other information is treated as positive as well and it worsens the training result)? So, as I understand, the best way is to restrict the image to contain only the object and do nothing if there's some portion of background left, isn't it?

Ihor Zabrotsky gravatar imageIhor Zabrotsky ( 2017-05-30 07:16:22 -0600 )edit
1

2: yea, but you do that by e.g. selecting the closest fitting bounding box in the annotation tool.

berak gravatar imageberak ( 2017-05-30 07:31:18 -0600 )edit

And what about 1 - should I stop using all those synthetic images?

Ihor Zabrotsky gravatar imageIhor Zabrotsky ( 2017-05-30 07:41:22 -0600 )edit

we have no idea, what your images are, or what you're trying to detect

berak gravatar imageberak ( 2017-05-30 07:44:43 -0600 )edit

Synthetic images help if you have large datasets and you want to generate conditions that do not occur often, as seen in many deep learning pipelines. However, cascades work on fairly small datasets, but only if the data used for training is actually meaningful. The artificial tweaking is not good in that case. In my experience of using the cascades for 4 years, using valid actual naturally occuring data works better in 99% of all applications I made based on them.

StevenPuttemans gravatar imageStevenPuttemans ( 2017-05-31 04:16:53 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2017-05-30 04:20:34 -0600

Seen: 473 times

Last updated: May 30 '17