Uninitialised value in cv::MeanshiftGrouping::moveToMode() (Bug #2685)


Added by Siegfried Hochdorfer about 12 years ago. Updated about 12 years ago.


Status:Done Start date:2013-01-08
Priority:Normal Due date:
Assignee:Ivan Korolev % Done:

0%

Category:objdetect
Target version:2.4.4 Estimated time:0.25 hour
Affected version:2.4.3 Operating System:
Difficulty: HW Platform:
Pull request:

Description

Hi, it seems that there is a bug in cv::MeanshiftGrouping::moveToMode(). I got the following error after running my program with valgrind.

==24580== Conditional jump or move depends on uninitialised value(s)
==24580==    at 0x695F37E: cv::MeanshiftGrouping::moveToMode(cv::Point3_<double>) const (cascadedetect.cpp:361)
==24580==    by 0x695E951: cv::MeanshiftGrouping::MeanshiftGrouping(cv::Point3_<double> const&, std::vector<cv::Point3_<double>, std::allocator<cv::Point3_<double> > > const&, std::vector<double, std::allocator<double> > const&, double, int) (cascadedetect.cpp:253)
==24580==    by 0x695F955: cv::groupRectangles_meanshift(std::vector<cv::Rect_<int>, std::allocator<cv::Rect_<int> > >&, double, std::vector<double, std::allocator<double> >*, std::vector<double, std::allocator<double> >&, cv::Size_<int>) (cascadedetect.cpp:404)
==24580==    by 0x695FD74: cv::groupRectangles_meanshift(std::vector<cv::Rect_<int>, std::allocator<cv::Rect_<int> > >&, std::vector<double, std::allocator<double> >&, std::vector<double, std::allocator<double> >&, double, cv::Size_<int>) (cascadedetect.cpp:444)

...

==24580==    by 0x43AE39: main (main.cpp:381)

I think the bug is that the member double MeanshiftGrouping::modeEps defined at cascadedetect.cpp:295 is not initialized in the constructor of MeanshiftGrouping but then used in cv::MeanshiftGrouping::moveToMode(Point3d aPt) (cascadedetect.cpp:361).


crop001001a.png - File from INRIA Person database (30.8 kB) Siegfried Hochdorfer, 2013-01-11 10:15 am


Associated revisions

Revision f0b0d4e8
Added by Roman Donchenko almost 11 years ago

Merge pull request #2685 from znah:ocl_control_py

History

Updated by Daniil Osokin about 12 years ago

Hi, Siegfried!
Please add a test sample to reproduce this. You can send a pull request with fix to OpenCV, it speeds up fixing.

Updated by Siegfried Hochdorfer about 12 years ago

Hi Daniil,

here is an example to reproduce the bug.

#include <iostream>
#include <opencv2/opencv.hpp>

using namespace std;

int main()
{
  cv::Mat input_image = cv::imread("crop001001a.png");

  cv::HOGDescriptor hog;
  hog.setSVMDetector(cv::HOGDescriptor::getDefaultPeopleDetector());

  vector<cv::Rect> locations;
  cv::Size winStride = cv::Size();
  cv::Size padding = cv::Size();
  const double scale = 1.05;
  const double finalThreshold = 0.0;
  const bool meanShiftGrouping = true;
  hog.detectMultiScale(input_image, locations, 0, winStride, padding, scale, finalThreshold, meanShiftGrouping);

  return 0;
}

If you run this example with valgrind you get the following error message:

==3755== Conditional jump or move depends on uninitialised value(s)
==3755==    at 0x5BCD37E: cv::MeanshiftGrouping::moveToMode(cv::Point3_<double>) const (cascadedetect.cpp:361)
==3755==    by 0x5BCC951: cv::MeanshiftGrouping::MeanshiftGrouping(cv::Point3_<double> const&, std::vector<cv::Point3_<double>, std::allocator<cv::Point3_<double> > > const&, std::vector<double, std::allocator<double> > const&, double, int) (cascadedetect.cpp:253)
==3755==    by 0x5BCD955: cv::groupRectangles_meanshift(std::vector<cv::Rect_<int>, std::allocator<cv::Rect_<int> > >&, double, std::vector<double, std::allocator<double> >*, std::vector<double, std::allocator<double> >&, cv::Size_<int>) (cascadedetect.cpp:404)
==3755==    by 0x5BCDD74: cv::groupRectangles_meanshift(std::vector<cv::Rect_<int>, std::allocator<cv::Rect_<int> > >&, std::vector<double, std::allocator<double> >&, std::vector<double, std::allocator<double> >&, double, cv::Size_<int>) (cascadedetect.cpp:444)
==3755==    by 0x5C13A4E: 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 (hog.cpp:1059)
==3755==    by 0x5C13C6F: 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 (hog.cpp:1073)
==3755==    by 0x401D1A: main (main.cpp:19)

The member modeEps is used uninitialized in cascadedetect.cpp:361 (see: http://code.opencv.org/projects/opencv/repository/revisions/master/entry/modules/objdetect/src/cascadedetect.cpp#L361)

Since I am not familiar with the MeanshiftGrouping class I can not provide a patch to solve the problem. But I guess that the MeanshiftGrouping::modeEps member (see http://code.opencv.org/projects/opencv/repository/revisions/master/entry/modules/objdetect/src/cascadedetect.cpp#L295) should be initialized with the unnamed double parameter from the MeanshiftGrouping constuctor (see http://code.opencv.org/projects/opencv/repository/revisions/master/entry/modules/objdetect/src/cascadedetect.cpp#L239).

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 Ivan Korolev about 12 years ago

  • Assignee set to Ivan Korolev

Updated by Ivan Korolev about 12 years ago

The bug was fixed by Siegfried Hochdorfer in commit:82a9f9a.

  • Status changed from Open to Done

Updated by Kirill Kornyakov about 12 years ago

  • Target version set to 2.4.4

Also available in: Atom PDF