Opencv 3.0 HOGDescriptor , the “compute” function runtime error when using Release Mode in vs 2008

asked 2015-03-18 07:32:14 -0600

Chauncey gravatar image

updated 2015-03-19 02:06:08 -0600

I'm using Opencv 3.0+ Vs2008, (win*86 PC).I want to use HOGDescriptor in opencv to do some research, but the code throws exception in Release mode in VS2008. At the same time the code runs well in Deubug mode .Here is my code:

#include "stdafx.h"
#include <opencv2/opencv.hpp>
#include<string>
#include<iostream>
#include<vector>
using namespace std;
using namespace cv;
int main()
{
    string imagePath="E:/test/3.jpg";
    Mat img=imread(imagePath,IMREAD_GRAYSCALE);
    if (img.empty())
    {
        cout<<"Can't read image,please check!"<<endl;
        return -1;
    }
    HOGDescriptor hog;
    vector< Point > location;
    vector< float > descriptors;
    hog.compute( img, descriptors, Size( 8, 8 ), Size( 0, 0 ), location );
    return 0;   
}

I debug the code step by step, I doubt Opencv source codes have bugs. I find that in "hog.cpp" in line 586 throw exceptions, here is the code : ......

for (; i <= blockSize.height - 4; i += 4)
{
   __m128 t = _mm_sub_ps(_mm_cvtepi32_ps(idx), _bh);
   t = _mm_mul_ps(t, t);
   idx = _mm_add_epi32(idx, ifour);
   _mm_storeu_ps(_di + i, t);
}

the code "i <= blockSize.height - 4" runtime error. I think my Code Project' property is right, in term : "c/c++"--code generation, runtime library is "Multi-threaded DLL (/MD)" in release mode . Is there anybody who knows this problems? Thank you for your help!

edit retag flag offensive close merge delete

Comments

1

Mat img=imread(imagePath,COLOR_RGB2GRAY); // <-- COLOR_RGB2GRAY is wrong here. should be IMREAD_GRAYSCALE

(still can reproduce it here)

berak gravatar imageberak ( 2015-03-18 08:28:07 -0600 )edit
1

damn heisenbug ;( !!

berak gravatar imageberak ( 2015-03-18 10:58:26 -0600 )edit

Sorry, COLOR_RGB2GRAY should be IMREAD_GRAYSCALE, but the error is still there!

Chauncey gravatar imageChauncey ( 2015-03-19 02:08:27 -0600 )edit

yes, error is still there.

berak gravatar imageberak ( 2015-03-19 02:11:00 -0600 )edit
1

let me check if error still there

sturkmen gravatar imagesturkmen ( 2017-10-03 04:02:35 -0600 )edit