Ask Your Question

TobiasNoell's profile - activity

2015-06-04 08:48:06 -0600 received badge  Teacher (source)
2015-06-03 04:56:31 -0600 received badge  Self-Learner (source)
2015-06-02 11:13:16 -0600 answered a question Parralel creation of cv::Mat crashes? Bug?

Meanwhile I was digging a little bit further into the problem and I really think there is a bug in OpenCV.

In Mat::create the following code is executed

MatAllocator *a = allocator, *a0 = getStdAllocator();

which calls getStdAllocator. This is implemented as:

MatAllocator* Mat::getStdAllocator()
{
    static MatAllocator * allocator = new StdMatAllocator();
    return allocator;
}

i.e. returning a static local variable. When getStdAllocator() is executed in parallel this may crash (in my case it simply sometimes returns NULL).

I can get my example running by ensuring that the static local variable is initialized first, i.e.

cv::MatAllocator *a0 = cv::Mat::getStdAllocator();

#pragma omp parallel for
for(int i = 0; i < 100; i++)
{
    cv::Mat blub;
    blub.create(3456, 5184, 16);
    cout << ".";
}

But it seems to be fixed here already: http://code.opencv.org/issues/4189

2015-05-25 08:01:35 -0600 asked a question Parralel creation of cv::Mat crashes? Bug?

Hi there,

I'm using OpenCV 3.0rc1 and Windows 7 (Visual Studio 2010) My problem is that the following code crashes randomly when using OpenMP for parallization. If I remove the OpenMP loop parallelization everything works fine.

#pragma omp parallel for
for(int i = 0; i < 100; i++)
{
    cv::Mat blub;
    blub.create(3456, 5184, 16);
    cout << ".";
}

The following exception is thrown OpenCV Error: Assertion failed (u != 0) in cv::Mat::create, file src\matrix.cpp, line 412

Can anyone reproduce / confirm this behavior?