当我调用cv :: ogl :: Texture2D的copyFrom方法时,我注意到明显的GPU / cuda内存使用量增加了。这是opencv的错误还是我做错了什么?
代码段如下所示:
cv::ogl::Texture2D ofTexU;
cv::ogl::Texture2D ofTexV;
ofTexU.create( cv::Size( imgW, imgH), cv::ogl::Texture2D::Format::RGB );
ofTexV.create( cv::Size( imgW, imgH), cv::ogl::Texture2D::Format::RGB );
cv::gpu::GpuMat gpuMatU;
cv::gpu::GpuMat gpuMatV;
gpuMatU.create( cv::Size( imgW, imgH), CV_32FC3 );
gpuMatV.create( cv::Size( imgW, imgH), CV_32FC3 );
...// some processing code
while( 1 ) {
// The following two lines introduced GPU memory increase, and it's keep increasing
// If commented out, everything looks fine
ofTexU.copyFrom( gpuMatU );
ofTexV.copyFrom( gpuMatV );
}
BTW,我使用cudaMemGetInfo来获取GPU内存使用情况,如下所示。我正在使用OpenCV 2.4.6,使用OpenGL和Cuda支持编译。
size_t free_byte, total_byte ;
cudaError cuda_status = cudaMemGetInfo( &free_byte, &total_byte ) ;
if ( cudaSuccess != cuda_status ){
printf("Error: cudaMemGetInfo fails, %s \n", cudaGetErrorString(cuda_status) );
exit(1);
}