Transparency (alpha) handling in cascade training?
Since I was not getting good recognition results (on aerial photography of cattle on fields), I tried to use transparency in the positives, to let the cows stand out more. Ultimately, I want to count the cows on the image.
But using transparency is a dumb idea, it seems, and I would just like to confirm that
- transparency in the positive images is ignored by the createsamples and traincascade tools
- only the -bgcolor and -bgthresh of createsamples determine what is considered transparent
Is that correct?
The problem I see is that the background of the positive cow images vary a lot (gras vs. sand, gras texture, etc.), so I will have an issue specifying a single -bgcolor. Before I set out to mask the background, I'd like to know how to do it correctly.
Thanks, nobi
EDIT: Here are samples of the images I use:
Overview of field, from which cows (and calves) should be counted (cropped):
Positive image, extracted from one of the overview images:
Resulting sample file (since .vec cannot be uploaded, this is a screenshot of a .vec file):
The sample file is not one created from the positive image - because opencv_createsamples renames the files, I cannot easily find the corresponding one.
What you can clearly see in the sample file is the background of the positive, which could lead to the (very) low recognition rate (actually, zero).
I don't think transparency will improve much the results, unless it clearly divides the cattle from the background. I would separate cows vs ground based on the cow's color, since it varies less, to get 'True' groups of cows, and then create artificial positives and negatives by copy-paste of True groups into photos of varied fields for positives vs empty or cluttered fields with other animals, houses, etc. for negatives. Just an idea.
@berak, thanks for the hints. I saw your answer to the linked question, but our photography is from above, so the cow is seen only from above (neck and back), instead of the front view shown in the linked question. I'll try to add a sample positive.
@bio_c, that's what I tried (I think ;-) Unfortunately, we have Black Angus, which don't differ much from their shadows, and as far as I've seen, color is anyway reduced to greyscale, isn't it? The "copy-paste of True groups into photos of varied fields" is done automagically by the opencv_createsamples program, I figure - or what would you use? I prepared samples with (trial, comic cow) positives on transparent background, but the opencv_createsamples would ignore the transparency in the positives so that the samples still don't show the silhouette nicely....
Basically you need to train your own part based object model, which is impossible through OpenCV if I am remembering correct. Like @berak said, your object is far from rigid so forget rigid models. They will never reach satisfying results!
@StevenPuttemans Thanks for the clear statement, but - since I am new to computer vision - can you give me some pointers to "non-rigid" models? I thought the pedestrian, face, cat, etc. recognition videos found on youtube were created with this technique... wrong assumption?