Ask Your Question

pollausen85's profile - activity

2020-11-30 01:18:31 -0600 received badge  Notable Question (source)
2020-05-24 17:56:45 -0600 received badge  Popular Question (source)
2016-04-20 05:14:20 -0600 received badge  Editor (source)
2016-04-20 03:47:50 -0600 commented answer OpenCV Error: Assertion failed using calcHist

Thanks! I did what you suggested, now my code is:

//Create matrix stromal pop
    cv::Mat stromalHistogram(1, i_stromalIID.size(), CV_32F);
    float* ref_ptr = stromalHistogram.ptr<float>(0);
    std::copy(i_stromalIID.begin(), i_stromalIID.end(), stdext::checked_array_iterator<float*>(ref_ptr, stromalHistogram.cols));

and std::vector<double> hist_out now is std::vector<float> hist_out.

Unfortunately nothing changed. Any other suggestions?

2016-04-19 16:40:47 -0600 asked a question OpenCV Error: Assertion failed using calcHist

I'm trying to calculate the histogram of a matrix composed by only one row. I wrote this code in VS2015:

//Create matrix stromal pop
    cv::Mat stromalHistogram(1, i_stromalIID.size(), CV_32F);
    float * ref_ptr = stromalHistogram.ptr<float>(0);
    std::copy(i_stromalIID.begin(), i_stromalIID.end(), stdext::checked_array_iterator<float *>(ref_ptr, stromalHistogram.cols));

#ifdef _DEBUG
    std::cout << "Matrix =" << std::endl << stromalHistogram << std::endl;
#endif

    // calculate histogram for stromal pop
    auto itRangesRef = std::minmax_element(i_stromalIID.begin(), i_stromalIID.end());
    float stromalRanges[] = {*itRangesRef.first, *itRangesRef.second};
    const float * rangesRef[] = { stromalRanges };
    const int channel = 0;
    const int histSize = 256;
    std::vector<float> hist_out;
    cv::calcHist(&stromalHistogram, 1, &channel, cv::Mat(), hist_out, 1, &histSize, rangesRef);

i_stromalIID is a std::vector<double> passed from the extern. The cv::Mat stromalHistogram is filled correctly because when I print it, everything is as I expected (1 row, 1204 columns). But when the program runs the cv::calcHist, I receive the following error:

OpenCV Error: Assertion failed (d == 2 && (sizes[0] == 1 || sizes[1] == 1 || sizes[0]*sizes[1] == 0)) in cv::_OutputArray::create, file D:\Development\lib\OpenCV3.1\opencv-master\modules\core\src\matrix.cpp, line 2363

I tried to debug the OpenCV code, and the error is in cv::calcHist when it tries to do:

void cv::calcHist( const Mat* images, int nimages, const int* channels,
                   InputArray _mask, OutputArray _hist, int dims, const int* histSize,
                   const float** ranges, bool uniform, bool accumulate )
{
      .....
      .....

      _hist.create(dims, histSize, CV_32F);
}

Then inside matrix.cpp is called:

void _OutputArray::create(int d, const int* sizes, int mtype, int i,
                          bool allowTransposed, int fixedDepthMask) const
{
      .....
      .....

      if( k == STD_VECTOR || k == STD_VECTOR_VECTOR )
      {
        CV_Assert( d == 2 && (sizes[0] == 1 || sizes[1] == 1 || sizes[0]*sizes[1] == 0) );
        .....
        .....
      }
}

And this assert fails because d in my case is equal to 1.

What am I doing wrong?

2016-04-14 11:06:48 -0600 commented answer Build opencv 3.1 with Visual Studio 2008

As a workaround I surrounded the __cpuidex call with:

#if _MSC_VER >=1600
   __cpuidex(cpuid_data, 7, 0);
#endif

In this way since in my case _MSC_VER = 1500 the compiler skip this call, and I was able to compile successfully.

2016-04-14 10:12:52 -0600 commented answer Build opencv 3.1 with Visual Studio 2008

Thanks! In order to report this bug should I follow the link you posted above?

2016-04-14 09:44:58 -0600 commented answer Build opencv 3.1 with Visual Studio 2008

This is the complete error: ..\..\..\Development\lib\OpenCV3.1\opencv-master\modules\core\src\system.cpp(298) : error C3861: '__cpuidex': identifier not found and specific line is:

#if defined _MSC_VER && (defined _M_IX86 || defined _M_X64)
        __cpuidex(cpuid_data, 7, 0);

In my case _MSC_VER = 1500 and _M_IX86 = 600.

2016-04-14 09:21:16 -0600 commented answer Build opencv 3.1 with Visual Studio 2008

My OS is 64bit but I'm trying to compile x86.

2016-04-14 08:57:46 -0600 commented answer Build opencv 3.1 with Visual Studio 2008

With your help I solved errors related to stdint.h and data(), but I still have the error about the __cpuidex and the problem is in modules\core\src\system.cpp. Do you have other suggestions?

2016-04-14 02:50:11 -0600 asked a question Build opencv 3.1 with Visual Studio 2008

I'm trying to build Opencv 3.1 with Visual Studio 2008 but I get some errors as:

  • stdint.h not found

  • __cpuidex not defined

  • data() is not a member function of std::vector

Is it possible buld Opencv 3.1 with VS2008? If yes, what do I have to do? If no, which is the last version compatible with VS2008? Thanks!

2016-04-13 04:10:37 -0600 received badge  Supporter (source)
2016-04-13 04:10:32 -0600 received badge  Scholar (source)
2016-04-13 03:26:09 -0600 asked a question Create opencv_world310.lib for x86

I'm trying to compile opencv3.1 for x86 application using VS2015. Everything goes okay but when the building is done,inside the lib folder, I get all the libraries while I would like to get only the opencv_world310.lib as in the x64 folder. What am I doing wrong? Is there some options to use? Thanks!