Minor refactoring
This commit is contained in:
parent
b0bf54e713
commit
b0d457cdb0
@ -1850,14 +1850,14 @@ public:
|
|||||||
{
|
{
|
||||||
frames_[0].release();
|
frames_[0].release();
|
||||||
frames_[1].release();
|
frames_[1].release();
|
||||||
I_[0].release();
|
pyrLevel_[0].release();
|
||||||
I_[1].release();
|
pyrLevel_[1].release();
|
||||||
M_.release();
|
M_.release();
|
||||||
bufM_.release();
|
bufM_.release();
|
||||||
R_[0].release();
|
polyCoefs_[0].release();
|
||||||
R_[1].release();
|
polyCoefs_[1].release();
|
||||||
tmp_[0].release();
|
blurredFrame_[0].release();
|
||||||
tmp_[1].release();
|
blurredFrame_[1].release();
|
||||||
pyramid0_.clear();
|
pyramid0_.clear();
|
||||||
pyramid1_.clear();
|
pyramid1_.clear();
|
||||||
}
|
}
|
||||||
@ -1878,7 +1878,7 @@ private:
|
|||||||
GpuMat& M, GpuMat &bufM, int blockSize, bool updateMatrices, Stream streams[]);
|
GpuMat& M, GpuMat &bufM, int blockSize, bool updateMatrices, Stream streams[]);
|
||||||
|
|
||||||
GpuMat frames_[2];
|
GpuMat frames_[2];
|
||||||
GpuMat I_[2], M_, bufM_, R_[2], tmp_[2];
|
GpuMat pyrLevel_[2], M_, bufM_, polyCoefs_[2], blurredFrame_[2];
|
||||||
std::vector<GpuMat> pyramid0_, pyramid1_;
|
std::vector<GpuMat> pyramid0_, pyramid1_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -339,15 +339,15 @@ void cv::gpu::FarnebackOpticalFlow::operator ()(
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
GpuMat tmp[2] =
|
GpuMat blurredFrame[2] =
|
||||||
{
|
{
|
||||||
allocMatFromBuf(size.height, size.width, CV_32F, tmp_[0]),
|
allocMatFromBuf(size.height, size.width, CV_32F, blurredFrame_[0]),
|
||||||
allocMatFromBuf(size.height, size.width, CV_32F, tmp_[1])
|
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, pyrLevel_[0]),
|
||||||
allocMatFromBuf(height, width, CV_32F, I_[1])
|
allocMatFromBuf(height, width, CV_32F, pyrLevel_[1])
|
||||||
};
|
};
|
||||||
|
|
||||||
Mat g = getGaussianKernel(smoothSize, sigma, CV_32F);
|
Mat g = getGaussianKernel(smoothSize, sigma, CV_32F);
|
||||||
@ -356,16 +356,16 @@ void cv::gpu::FarnebackOpticalFlow::operator ()(
|
|||||||
for (int i = 0; i < 2; i++)
|
for (int i = 0; i < 2; i++)
|
||||||
{
|
{
|
||||||
device::optflow_farneback::gaussianBlurGpu(
|
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
|
#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
|
#else
|
||||||
Mat tmp1, tmp2;
|
Mat tmp1, tmp2;
|
||||||
tmp[i].download(tmp1);
|
tmp[i].download(tmp1);
|
||||||
resize(tmp1, tmp2, Size(width, height), INTER_LINEAR);
|
resize(tmp1, tmp2, Size(width, height), INTER_LINEAR);
|
||||||
I[i].upload(tmp2);
|
I[i].upload(tmp2);
|
||||||
#endif
|
#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]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user