Ask Your Question

yann's profile - activity

2012-08-01 09:43:04 -0500 asked a question Problem with FarnebackOpticalFlow / DeviceInfo

I'm having a problem with the cv::gp::FarnebackOpticalFlow class.

I built OpenCV 2.4.2 with CUDA support on a 32bit Windows machine. Everything works fine, my old projects as well as the sample program "farneback_optical_flow_gpu.exe" (that was built together with OpenCV2.4.2).

But, so far, I haven't managed to successfuly include FarnebackOpticalFlow in one of my own projects.

I can compile the code, but the programm always stops due to a write acess violation once it reaches the constructor (the line cv::gpu::FarnebackOpticalFlow d_calc;):

"Exception at 0x760ed36f, code: 0xe06d7363: C++ exception, flags=0x1 (execution cannot be continued) in cudart32_42_9!_cudaMutexOperation"

The source of the problem seems to be this function (gpumat.cpp, line 296 ff.):

void cv::gpu::DeviceInfo::query()
    cudaDeviceProp prop;
    cudaSafeCall(cudaGetDeviceProperties(&prop, device_id_));
    name_ =;
    multi_processor_count_ = prop.multiProcessorCount;
    majorVersion_ = prop.major;
    minorVersion_ = prop.minor;

But cudaGetDeviceProperties(&prop, device_id_) on its own works just fine (and returns the right values) when I include it somewhere else.

I tried building my own version of "farneback_optical_flow_gpu.exe" using the original code and encountered the problem described above (with both Microsoft Visual C++ 2010 Express and QT Creator).

I'm pretty sure that the code itself isn't the problem, the working .exe and my version include the same libraries from the same places (DependencyWalker), and were build by the same compiler.

What am I missing?