Ask Your Question
0

Strange error in HOGDescriptor::compute()

asked 2017-11-06 11:30:40 -0500

updated 2017-11-08 04:07:00 -0500

Hello,

I'm trying to use HOGDescriptor, but in some of my projects compute() method always throws exception -215. Here is my code:

cv::Mat loaded = cv::imread("D:/raw/filtered/knot_neg/33.jpg", cv::IMREAD_GRAYSCALE);
cv::HOGDescriptor hog;
std::vector<cv::Point> location;
std::vector<float> descriptors;
hog.compute(loaded, descriptors, cv::Size(8, 8), cv::Size(0, 0), location);

When i try to debug, i found strange corruption of HOGDescriptor parameters in cv code.

HOGDescriptor data in my code: image description

I read many articles about -215 exception in the compute() method which says to "set HOGDescriptor parameters properly". But it doesn't help because the parameters i set changes like this in compute() method: image description

What could lead to such behavior? How could I fix it? OpenCV 3.3.0/3.3.1 x86 build from source.

UPD. This bug came from "nodave.h" header of LIBNODAVE library. When i include this header before opencv headers i get this bug.

edit retag flag offensive close merge delete

Comments

please do NOT post screenshots of your code here. replace them with a TEXT version.

berak gravatar imageberak ( 2017-11-06 11:39:26 -0500 )edit

It is not screenshots of my code. It's screenshots of debug data. Text version of my code is above screenshots.

another_newbie gravatar imageanother_newbie ( 2017-11-06 11:51:54 -0500 )edit

opencv version, compiler, os ?

berak gravatar imageberak ( 2017-11-06 12:00:17 -0500 )edit

"OpenCV 3.3.0/3.3.1 x86 build from source." Win 7 and 10 Compiler MSVC 2015

another_newbie gravatar imageanother_newbie ( 2017-11-06 12:06:53 -0500 )edit

did you miss, that the default window size of the HOGDescriptor is 64x128 ? so you have to:

  • change it, if you need a different size here (from the constructor)
  • resize your image to the windowsize
berak gravatar imageberak ( 2017-11-08 04:20:51 -0500 )edit

1 answer

Sort by ยป oldest newest most voted
0

answered 2017-11-08 08:17:16 -0500

updated 2017-11-08 08:21:45 -0500

I know default window size. And i try many sizes and many image resolutions. It doesn't work, because HOGDescriptor structure is corrupted. All data in structure is moved by size of int in the memory in runtime. {64, 128} {16,16} {8,8} 9(nbins)... => {128,16} {16,8} {8,9} 1... Reason of this bug was in header of another library. Author used #pragma pack(1) and forgot to pop it. Problem solved.

edit flag offensive delete link more
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2017-11-06 11:30:40 -0500

Seen: 106 times

Last updated: Nov 08 '17