Problem with HOGDescriptor (Bug #2695)


Added by Subho Banerjee about 12 years ago. Updated over 11 years ago.


Status:Cancelled Start date:2013-01-13
Priority:Normal Due date:
Assignee:Subho Banerjee % Done:

0%

Category:objdetect
Target version:Next Hackathon
Affected version:2.4.0 - 2.4.4 Operating System:
Difficulty: HW Platform:
Pull request:

Description

I am running OpenCV 2.4.3(Compiled from homebrew with tbb/opencl enabled) on Mac OS X 10.8.
I am trying to use the cv::HOGDescriptor to detect pedestrians in a video sequence.

This is the code I am using to do the detection and paint a bounding box.

cv::VideoCapture input("file.avi");
assert(input.isOpened());
cv::HOGDescriptor body;
assert(body.load("hogcascade_pedestrians.xml"));
cv::Mat frame, gray;
cv::namedWindow("video");
while (input.read(frame)) {
vector<cv::Rect> rects;
cv::cvtColor(frame, gray, cv::COLOR_RGB2GRAY);
cv::equalizeHist(gray, gray);
body.detectMultiScale(gray, rects);
for (unsigned int i=0;i<rects.size();i++) {
cv::rectangle(frame, cv::Point(rects[i].x, rects[i].y),
cv::Point(rects[i].x+rects[i].width, rects[i].y+rects[i].height),
cv::Scalar(255, 0, 255));
}
cv::imshow("video", frame);
}

However, when the execution reaches the line `body.detectMultiScale(gray, rects);`, I get the an error and the whole application crashes

libc++abi.dylib: terminate called throwing an exception
[1] 92156 abort ../bin/DetectPedestrians

What is going wrong? I cannot seem to get any new information from the `gdb` or `lldb` outputs. I am compiling with the code with a CMake build, so I guess this isn't a problem with the linking.

Here is a stack trace from the thread that crashed -

Thread 0 Crashed:: Dispatch queue: com.apple.root.default-priority
0 libsystem_kernel.dylib 0x00007fff8c001212 _pthread_kill + 10
1 libsystem_c.dylib 0x00007fff8e7afaf4 pthread_kill + 90
2 libsystem_c.dylib 0x00007fff8e7f3dce abort + 143
3 libc++abi.dylib 0x00007fff94096a17 abort_message + 257
4 libc++abi.dylib 0x00007fff940943c6 default_terminate() + 28
5 libobjc.A.dylib 0x00007fff8e11f887 _objc_terminate() + 111
6 libc++.1.dylib 0x00007fff96b0b8fe std::terminate() + 20
7 libobjc.A.dylib 0x00007fff8e11f5de objc_terminate + 9
8 libdispatch.dylib 0x00007fff8c4ecfa0 _dispatch_client_callout2 + 28
9 libdispatch.dylib 0x00007fff8c4ed686 _dispatch_apply_serial + 28
10 libdispatch.dylib 0x00007fff8c4e80b6 _dispatch_client_callout + 8
11 libdispatch.dylib 0x00007fff8c4ebae8 _dispatch_sync_f_invoke + 39
12 libopencv_core.2.4.3.dylib 0x0000000101d5d900 cv::parallel_for
(cv::Range const&, cv::ParallelLoopBody const&, double) + 116
13 libopencv_objdetect.2.4.3.dylib 0x000000010257fa21 cv::HOGDescriptor::detectMultiScale(cv::Mat const&, std::vector<cv::Rect_<int>, std::allocator<cv::Rect_<int> > >&, std::vector<double, std::allocator<double> >&, double, cv::Size_<int>, cv::Size_<int>, double, double, bool) const + 559
14 libopencv_objdetect.2.4.3.dylib 0x000000010257fdc2 cv::HOGDescriptor::detectMultiScale(cv::Mat const&, std::vector<cv::Rect_<int>, std::allocator<cv::Rect_<int> > >&, double, cv::Size_<int>, cv::Size_<int>, double, double, bool) const + 80
15 DetectPedestrians 0x0000000101a7886c main + 2572 (detect.cpp:41)
16 libdyld.dylib 0x00007fff8d89f7e1 start + 1

On a Linux system(OpenCV 2.4.3 compiled with TBB support), the same code gives me an error saying -

OpenCV Error: Assertion failed (dsize.area() || (inv_scale_x > 0 && inv_scale_y > 0)) in resize, file /home/subho/OpenCV/OpenCV-2.4.3/modules/imgproc/src/imgwarp.cpp, line 1726
terminate called after throwing an instance of 'tbb::captured_exception'
what(): /home/subho/OpenCV/OpenCV-2.4.3/modules/imgproc/src/imgwarp.cpp:1726: error: (-215) dsize.area() || (inv_scale_x > 0 && inv_scale_y > 0) in function resize

History

Updated by Marina Kolpakova about 12 years ago

  • Category set to objdetect

Updated by Marina Kolpakova about 12 years ago

  • Assignee set to Marina Kolpakova

Updated by Vadim Pisarevsky about 12 years ago

  • Affected version set to 2.4.3
  • Target version deleted ()

Updated by Vadim Pisarevsky about 12 years ago

  • Assignee deleted (Marina Kolpakova)

Updated by Marina Kolpakova about 12 years ago

I think your problem is in line

cv::equalizeHist(gray, gray);

You should separate source and destination matrices.
cv::Mat normalized;
cv::equalizeHist(gray, normalized);

Updated by Marina Kolpakova about 12 years ago

  • Assignee set to Marina Kolpakova

Updated by Kirill Kornyakov about 12 years ago

Subho, did Marina's suggestion help?

  • Target version set to 2.4.4
  • Priority changed from High to Normal
  • Assignee changed from Marina Kolpakova to Subho Banerjee

Updated by Andrey Kamaev about 12 years ago

  • Target version changed from 2.4.4 to Next Hackathon

Updated by Kirill Kornyakov over 11 years ago

Please reopen if the issue reproduces

  • Status changed from Open to Cancelled
  • Affected version changed from 2.4.3 to 2.4.0 - 2.4.4

Also available in: Atom PDF