haarcascade with tbb bug (Feature #1185)


Added by Meng Wang over 13 years ago. Updated over 13 years ago.


Status:Done Start date:
Priority:Normal Due date:
Assignee:Vadim Pisarevsky % Done:

0%

Category:objdetect
Target version:-
Difficulty: Pull request:

Description

This bug is related to the objdetect module, specifically, haarcascade when TBB is enabled. It can be reproduced through the use of facedetct example.

Steps to reproduce:
1. Build OpenCV with examples from a fresh checkout (r5830 used), with tbb support.
2. Run

./facedetect <any picture>
3. You get the following segfault message

This program demonstrates the cascade recognizer. Now you can use Haar or LBP features.
This classifier can recognize many ~rigid objects, it's most known use is for faces.
Usage:
./facedetect [--cascade=<cascade_path> this is the primary trained classifier such as frontal face]
[--nested-cascade[=nested_cascade_path this an optional secondary classifier such as eyes]]
[--scale=<image scale greater or equal to 1, try 1.3 for example>
[filename|camera_index]

see facedetect.cmd for one call:
./facedetect --cascade="../../data/haarcascades/haarcascade_frontalface_alt.xml" --nested-cascade="../../data/haarcascades/haarcascade_eye.xml" --scale=1.3
Hit any key to quit.
Using OpenCV version 2.3.1

Processing 1 /Users/mengw/Desktop/negro.jpg
init done
opengl support available
In image read
OpenCV Error: Assertion failed (y == 0 || (data && dims >= 1 && (unsigned)y < (unsigned)size.pr0)) in ptr, file /Users/mengw/projects/opencv-svn-trunk-withdata/opencv/modules/core/include/opencv2/core/mat.hpp, line 442
OpenCV Error: Assertion failed (y == 0 || (data && dims >= 1 && (unsigned)y < (unsigned)size.pr0)) in ptr, file /Users/mengw/projects/opencv-svn-trunk-withdata/opencv/modules/core/include/opencv2/core/mat.hpp, line 442
terminate called after throwing an instance of 'tbb::captured_exception'
what(): /Users/mengw/projects/opencv-svn-trunk-withdata/opencv/modules/core/include/opencv2/core/mat.hpp:442: error: (-215) y == 0 || (data && dims >= 1 && (unsigned)y < (unsigned)size.pr0) in function ptr

Abort trap

Workaround:

I found that the problem does not occur when tbb is not used. Further inspection shows that it is due to an absence of size check in modules/objdetect/src/haar.cpp in the paralleled version (cv::HaarDetectObjects_ScaleImage_Invoker::operator()) Use the following patch solves the problem.

852a853,856

if (y2 <= y1 || sum1.cols <= 1 + winSize0.width)
return;


opencv_haar_patch.patch - Patch file for modules/objdetect/haar.cpp (115 Bytes) Meng Wang, 2011-07-02 01:15 am


Associated revisions

Revision b0aae19f
Added by Vadim Pisarevsky over 13 years ago

probably fixed parallel face detector (i.e. built with TBB), ticket #1185. Thanks to mengw for the patch

Revision ea6002eb
Added by Andrey Pavlenko over 11 years ago

Merge pull request #1185 from znah:cumpute_method_for_2_4

History

Updated by Vadim Pisarevsky over 13 years ago

thanks! your patch has been applied in r5922

  • Status changed from Open to Done
  • (deleted custom field) set to fixed

Also available in: Atom PDF