Reputation: 127
I'm working on a image classification project and wanted to calculate the HOG feature of an image by using the OpenCV HOGDescriptor. There are some samples available online, but they didn't work for me. There was an open_stackdumpfile-error that wasn't comprehensible to me. I set up a new, empty project to identify the error, and this is where I get stuck:
#include <cstdio>
#include <stdlib.h>
#include <iostream>
#include "opencv2\opencv.hpp"
#define IMG_PATH "D:\\ImageDatabase\\IMG_0024.png"
using namespace std;
int main(void) {
cout << "hi!" << endl;
cv::Mat mat = cv::imread(IMG_PATH);
// show the image
cv::namedWindow("Image", CV_WINDOW_AUTOSIZE);
cv::moveWindow("Image", 0, 0);
cv::imshow("Image", mat);
cv::HOGDescriptor hog;
vector<float> descriptors;
hog.compute(mat, descriptors);
cout << "finished." << endl;
cv::waitKey(0);
cout << "bye." << endl;
return EXIT_SUCCESS;
}
The descriptors are calculated and the vector is filled with values. That's the output:
hi!
finished.
bye.
1 [main] TestProject 5932 open_stackdumpfile: Dumping stack trace to TestProject.exe.stackdump
The stackdump file just looks like this:
Stack trace:
Frame Function Args
Do you have any idea, why this error occurs, what it means and how I can resolve it? I am working on a Windows 7 machine with Cygwin, and tried both OpenCV 2.4.1 and 2.4.6, but the error remains the same.
Every hint on what I could have done wrong is appreciated!
[edit] The compiler options etc. look like this:
make all
rm -f TestProject.o TestProject.exe
g++ -O2 -g -Wall -fmessage-length=0 -I/cygdrive/D/VZE/Tools/opencv246/opencv/build/include -I/cygdrive/D/VZE/Tools/opencv246/opencv/build/include/opencv -I/cygdrive/D/VZE/Tools/opencv246/opencv/build/include/opencv2 -c -o TestProject.o TestProject.cpp
g++ -o TestProject.exe TestProject.o -L/cygdrive/D/VZE/Tools/opencv246/opencv/build/x86/mingw/bin -lopencv_highgui246 -lopencv_core246 -lopencv_imgproc246 -lopencv_objdetect246
Upvotes: 2
Views: 9103
Reputation: 127
This question is quite old, but still has a few views and maybe this could help some people:
First of all, I didn't have a real solution. Everything was fine with the code, there was a problem with the setup.
The program crashed when the std::vector<float> descriptors
went out of scope. Somehow OpenCV kept a handle on it, I don't know why or how. I also experienced this type of error with some other methods such as computing SIFT descriptors etc.
I assumed some fault with the precompiled OpenCV versions on Cygwin. Avoiding Cygwin by switching to Ubuntu or Visual Studio solved the problem for me. Maybe compiling OpenCV manually could solve the problem, too.
Upvotes: 1
Reputation: 41
I cant test this under the same conditions as I tested your code under WinXP,32Bit,MSVC++-2010-SP1,OpenCV 2.4.5 prebuilt binaries build\x86\vc10\bin
The error does not appear there. I found some examples doing resize the image to the hog.cellSize
. But that does not seem to be very important.
You should try to compile the opencv samples for HOG.
opencv\samples\ocl\hog.cpp
opencv\samples\gpu\hog.cpp
Both are working with an appropriate graphic card and self-build opencv.
If you are really suffering from that issue I could try to run the example on a real linux. But first try to build it with debug information:
ommit the -O2 !
g++ -g3 -D_DEBUG ...
then use a debugger gdb,ddd,kdbg
before that compile your opencv with the Debug version:
cmake -DCMAKE_BUILD_TYPE=Debug ../opencv
make && make install
If you like to have a great example of opencv HOG
Upvotes: 0