ofThread stalls on cv::gpu calls (GpuMat::upload).

Hello all,

Seems I can’t run opencv::gpu functions in an ofThread?

I have some expensive opencv functions that I have optimized using opencv::gpu. This has worked really well, and processing is down to about 1second, but I need to keep them from blocking rendering. I’m just now moving my code over from the main thread into a ofThread, when I found my cv::gpu functions don’t seem to work. These functions internally spawn their own pthreads, which could be the issue?

Can I use ofThread and cv::gpu functions, or should I drop ofImage and use pthreads directly in ofx, if that is even possible? I did some pthread stuff in plain C a few years ago…

Attached is the threaded example with the addition of some opencv GPU calls. (tested on Linux, ofx 0071 and 0074)

Thanks.

threadExample-cvGpu.zip

Seems the problem is on the openCV / GPU side, as the attached simple pthread code shows the same problem.

I compiled with: g++ -std=c++0x -ggdb -lopencv_gpu -o test test.cpp pkg-config opencv --cflags --libs

test.cpp

I forgot how long it takes for the first CUDA call to return because of the on the fly compilation.
Everything does work, there is just a quite long wait after the first call.