From b0d457cdb02a4b09543da6beb5c01edb44dc9dea Mon Sep 17 00:00:00 2001 From: Alexey Spizhevoy Date: Thu, 16 Feb 2012 12:00:17 +0000 Subject: [PATCH] Minor refactoring --- modules/gpu/include/opencv2/gpu/gpu.hpp | 14 +++++++------- modules/gpu/src/optical_flow_farneback.cpp | 18 +++++++++--------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/modules/gpu/include/opencv2/gpu/gpu.hpp b/modules/gpu/include/opencv2/gpu/gpu.hpp index 20ce90239f..ebfb5bf914 100644 --- a/modules/gpu/include/opencv2/gpu/gpu.hpp +++ b/modules/gpu/include/opencv2/gpu/gpu.hpp @@ -1850,14 +1850,14 @@ public: { frames_[0].release(); frames_[1].release(); - I_[0].release(); - I_[1].release(); + pyrLevel_[0].release(); + pyrLevel_[1].release(); M_.release(); bufM_.release(); - R_[0].release(); - R_[1].release(); - tmp_[0].release(); - tmp_[1].release(); + polyCoefs_[0].release(); + polyCoefs_[1].release(); + blurredFrame_[0].release(); + blurredFrame_[1].release(); pyramid0_.clear(); pyramid1_.clear(); } @@ -1878,7 +1878,7 @@ private: GpuMat& M, GpuMat &bufM, int blockSize, bool updateMatrices, Stream streams[]); GpuMat frames_[2]; - GpuMat I_[2], M_, bufM_, R_[2], tmp_[2]; + GpuMat pyrLevel_[2], M_, bufM_, polyCoefs_[2], blurredFrame_[2]; std::vector pyramid0_, pyramid1_; }; diff --git a/modules/gpu/src/optical_flow_farneback.cpp b/modules/gpu/src/optical_flow_farneback.cpp index 6d61e04cf5..9e6622250c 100644 --- a/modules/gpu/src/optical_flow_farneback.cpp +++ b/modules/gpu/src/optical_flow_farneback.cpp @@ -339,15 +339,15 @@ void cv::gpu::FarnebackOpticalFlow::operator ()( } else { - GpuMat tmp[2] = + GpuMat blurredFrame[2] = { - allocMatFromBuf(size.height, size.width, CV_32F, tmp_[0]), - allocMatFromBuf(size.height, size.width, CV_32F, tmp_[1]) + allocMatFromBuf(size.height, size.width, CV_32F, blurredFrame_[0]), + allocMatFromBuf(size.height, size.width, CV_32F, blurredFrame_[1]) }; - GpuMat I[2] = + GpuMat pyrLevel[2] = { - allocMatFromBuf(height, width, CV_32F, I_[0]), - allocMatFromBuf(height, width, CV_32F, I_[1]) + allocMatFromBuf(height, width, CV_32F, pyrLevel_[0]), + allocMatFromBuf(height, width, CV_32F, pyrLevel_[1]) }; Mat g = getGaussianKernel(smoothSize, sigma, CV_32F); @@ -356,16 +356,16 @@ void cv::gpu::FarnebackOpticalFlow::operator ()( for (int i = 0; i < 2; i++) { device::optflow_farneback::gaussianBlurGpu( - frames_[i], smoothSize/2, tmp[i], BORDER_REFLECT101_GPU, S(streams[i])); + frames_[i], smoothSize/2, blurredFrame[i], BORDER_REFLECT101_GPU, S(streams[i])); #if ENABLE_GPU_RESIZE - resize(tmp[i], I[i], Size(width, height), INTER_LINEAR, streams[i]); + resize(blurredFrame[i], pyrLevel[i], Size(width, height), INTER_LINEAR, streams[i]); #else Mat tmp1, tmp2; tmp[i].download(tmp1); resize(tmp1, tmp2, Size(width, height), INTER_LINEAR); I[i].upload(tmp2); #endif - device::optflow_farneback::polynomialExpansionGpu(I[i], polyN, R[i], S(streams[i])); + device::optflow_farneback::polynomialExpansionGpu(pyrLevel[i], polyN, R[i], S(streams[i])); } }