Ask Your Question

Revision history [back]

This is not an answer. Adding a program that crashes on Windows 10 with opencv-3.0.0-rc1 and VS 2013.

#define CONCURRENT_CVT_COLOR

std::condition_variable c0;
std::mutex m0;

void testthread(void)
{
#ifdef CONCURRENT_CVT_COLOR
    // Make the lock local, so that it doesn't wait to get the lock from multiple threads.
    std::mutex m0;
#endif
    std::unique_lock<std::mutex> l(m0);
    c0.wait(l);
    cv::Mat m_in(cv::Size(2048, 1536), CV_8U);
    cv::Mat m_out(cv::Size(2048, 1536), CV_8UC3);
    cv::cvtColor(m_in, m_out, CV_GRAY2RGB);
}

int main(void)
{
    unsigned int nthreads = 2;

    std::vector<std::thread> threads(nthreads);

    for (unsigned int i = 0; i < nthreads; i++)
        threads[i] = std::thread(testthread);

    Sleep(100);
    c0.notify_all();

    for (unsigned int i = 0; i < nthreads; i++)
        threads[i].join();

    return(1);
}

If CONCURRENT_CVT_COLOR is not defined, then the program does not crash. Thanks pistachio for your solution.