Skip to content

Commit

Permalink
enforce CASCADE_FIND_BIGGEST_OBJECT
Browse files Browse the repository at this point in the history
  • Loading branch information
jklontz committed Oct 7, 2015
1 parent a580a10 commit 267315b
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions openbr/plugins/metadata/cascade.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,17 @@ class CascadeTransform : public MetaTransform
if (ROCMode) cascade->detectMultiScale(m, rects, rejectLevels, levelWeights, 1.2, minNeighbors, flags | CASCADE_SCALE_IMAGE, Size(minSize, minSize), Size(), true);
else cascade->detectMultiScale(m, rects, 1.2, minNeighbors, flags, Size(minSize, minSize));

// It appears that flags is ignored for new model files:
// http://docs.opencv.org/modules/objdetect/doc/cascade_classification.html#cascadeclassifier-detectmultiscale
if ((flags == CASCADE_FIND_BIGGEST_OBJECT) && (rects.size() > 1)) {
Rect biggest = rects[0];
for (size_t j=0; j<rects.size(); j++)
if (rects[j].area() > biggest.area())
biggest = rects[j];
rects.clear();
rects.push_back(biggest);
}

bool empty = false;
if (!enrollAll && rects.empty()) {
empty = true;
Expand Down

6 comments on commit 267315b

@jklontz
Copy link
Member Author

@jklontz jklontz commented on 267315b Oct 7, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sklum @JordanCheney FYI this surfaced when I upgraded the OpenCV cascade models to those provided in 2.4.11 (a580a10). IMO this represents a somewhat serious performance regression, so I think I will revert at least the alt2 model. Looking into it some more...

@jklontz
Copy link
Member Author

@jklontz jklontz commented on 267315b Oct 7, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok the post mortem on this issue is that the haar cascades we used previously in OpenBR were the "old" ones. I've updated models.tar.gz one more time so that the "old" version of haarcascade_frontalface_alt2.xml is packaged instead of the "new" version. I also saw minor accuracy degradations in the "new" version of this file. For all other cascade files the "new" version is packaged.

@JordanCheney
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jklontz The other option here is to move to our in house cascades officially instead of the OpenCV versions.

@jklontz
Copy link
Member Author

@jklontz jklontz commented on 267315b Oct 7, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Im ready to do that as soon as someone is willing to publish a cascade that is clearly better than the OpenCV ones :)

@JordanCheney
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sklum do you have anything that is releasable or should I tackle this when I have time?

@sklum
Copy link
Member

@sklum sklum commented on 267315b Oct 8, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nothing releasable.

Please sign in to comment.