replaced GPU -> CUDA

This commit is contained in:
Vladislav Vinogradov
2013-07-24 13:55:18 +04:00
parent 3c34b24f1f
commit fd88654b45
172 changed files with 2434 additions and 2436 deletions

View File

@@ -52,7 +52,7 @@ using namespace cv::superres::detail;
#if !defined(HAVE_CUDA) || !defined(HAVE_OPENCV_CUDAARITHM) || !defined(HAVE_OPENCV_CUDAWARPING) || !defined(HAVE_OPENCV_CUDAFILTERS)
Ptr<SuperResolution> cv::superres::createSuperResolution_BTVL1_GPU()
Ptr<SuperResolution> cv::superres::createSuperResolution_BTVL1_CUDA()
{
CV_Error(Error::StsNotImplemented, "The called functionality is disabled for current build or platform");
return Ptr<SuperResolution>();
@@ -207,10 +207,10 @@ namespace
funcs[src.channels()](src, dst, ksize);
}
class BTVL1_GPU_Base
class BTVL1_CUDA_Base
{
public:
BTVL1_GPU_Base();
BTVL1_CUDA_Base();
void process(const std::vector<GpuMat>& src, GpuMat& dst,
const std::vector<std::pair<GpuMat, GpuMat> >& forwardMotions, const std::vector<std::pair<GpuMat, GpuMat> >& backwardMotions,
@@ -256,7 +256,7 @@ namespace
GpuMat regTerm_;
};
BTVL1_GPU_Base::BTVL1_GPU_Base()
BTVL1_CUDA_Base::BTVL1_CUDA_Base()
{
scale_ = 4;
iterations_ = 180;
@@ -268,7 +268,7 @@ namespace
blurSigma_ = 0.0;
#ifdef HAVE_OPENCV_CUDAOPTFLOW
opticalFlow_ = createOptFlow_Farneback_GPU();
opticalFlow_ = createOptFlow_Farneback_CUDA();
#else
opticalFlow_ = createOptFlow_Farneback();
#endif
@@ -281,7 +281,7 @@ namespace
curAlpha_ = -1.0;
}
void BTVL1_GPU_Base::process(const std::vector<GpuMat>& src, GpuMat& dst,
void BTVL1_CUDA_Base::process(const std::vector<GpuMat>& src, GpuMat& dst,
const std::vector<std::pair<GpuMat, GpuMat> >& forwardMotions, const std::vector<std::pair<GpuMat, GpuMat> >& backwardMotions,
int baseIdx)
{
@@ -377,7 +377,7 @@ namespace
highRes_(inner).copyTo(dst);
}
void BTVL1_GPU_Base::collectGarbage()
void BTVL1_CUDA_Base::collectGarbage()
{
filters_.clear();
@@ -401,12 +401,12 @@ namespace
////////////////////////////////////////////////////////////
class BTVL1_GPU : public SuperResolution, private BTVL1_GPU_Base
class BTVL1_CUDA : public SuperResolution, private BTVL1_CUDA_Base
{
public:
AlgorithmInfo* info() const;
BTVL1_GPU();
BTVL1_CUDA();
void collectGarbage();
@@ -438,7 +438,7 @@ namespace
GpuMat finalOutput_;
};
CV_INIT_ALGORITHM(BTVL1_GPU, "SuperResolution.BTVL1_GPU",
CV_INIT_ALGORITHM(BTVL1_CUDA, "SuperResolution.BTVL1_CUDA",
obj.info()->addParam(obj, "scale", obj.scale_, false, 0, 0, "Scale factor.");
obj.info()->addParam(obj, "iterations", obj.iterations_, false, 0, 0, "Iteration count.");
obj.info()->addParam(obj, "tau", obj.tau_, false, 0, 0, "Asymptotic value of steepest descent method.");
@@ -450,12 +450,12 @@ namespace
obj.info()->addParam(obj, "temporalAreaRadius", obj.temporalAreaRadius_, false, 0, 0, "Radius of the temporal search area.");
obj.info()->addParam<DenseOpticalFlowExt>(obj, "opticalFlow", obj.opticalFlow_, false, 0, 0, "Dense optical flow algorithm."));
BTVL1_GPU::BTVL1_GPU()
BTVL1_CUDA::BTVL1_CUDA()
{
temporalAreaRadius_ = 4;
}
void BTVL1_GPU::collectGarbage()
void BTVL1_CUDA::collectGarbage()
{
curFrame_.release();
prevFrame_.release();
@@ -471,10 +471,10 @@ namespace
finalOutput_.release();
SuperResolution::collectGarbage();
BTVL1_GPU_Base::collectGarbage();
BTVL1_CUDA_Base::collectGarbage();
}
void BTVL1_GPU::initImpl(Ptr<FrameSource>& frameSource)
void BTVL1_CUDA::initImpl(Ptr<FrameSource>& frameSource)
{
const int cacheSize = 2 * temporalAreaRadius_ + 1;
@@ -495,7 +495,7 @@ namespace
outPos_ = -1;
}
void BTVL1_GPU::processImpl(Ptr<FrameSource>& frameSource, OutputArray _output)
void BTVL1_CUDA::processImpl(Ptr<FrameSource>& frameSource, OutputArray _output)
{
if (outPos_ >= storePos_)
{
@@ -523,7 +523,7 @@ namespace
}
}
void BTVL1_GPU::readNextFrame(Ptr<FrameSource>& frameSource)
void BTVL1_CUDA::readNextFrame(Ptr<FrameSource>& frameSource)
{
frameSource->nextFrame(curFrame_);
@@ -545,7 +545,7 @@ namespace
curFrame_.copyTo(prevFrame_);
}
void BTVL1_GPU::processFrame(int idx)
void BTVL1_CUDA::processFrame(int idx)
{
const int startIdx = std::max(idx - temporalAreaRadius_, 0);
const int procIdx = idx;
@@ -576,9 +576,9 @@ namespace
}
}
Ptr<SuperResolution> cv::superres::createSuperResolution_BTVL1_GPU()
Ptr<SuperResolution> cv::superres::createSuperResolution_BTVL1_CUDA()
{
return new BTVL1_GPU;
return new BTVL1_CUDA;
}
#endif // HAVE_CUDA

View File

@@ -197,11 +197,11 @@ Ptr<FrameSource> cv::superres::createFrameSource_Camera(int deviceId)
#endif // HAVE_OPENCV_HIGHGUI
//////////////////////////////////////////////////////
// VideoFrameSource_GPU
// VideoFrameSource_CUDA
#ifndef HAVE_OPENCV_CUDACODEC
Ptr<FrameSource> cv::superres::createFrameSource_Video_GPU(const String& fileName)
Ptr<FrameSource> cv::superres::createFrameSource_Video_CUDA(const String& fileName)
{
(void) fileName;
CV_Error(cv::Error::StsNotImplemented, "The called functionality is disabled for current build or platform");
@@ -212,10 +212,10 @@ Ptr<FrameSource> cv::superres::createFrameSource_Video_GPU(const String& fileNam
namespace
{
class VideoFrameSource_GPU : public FrameSource
class VideoFrameSource_CUDA : public FrameSource
{
public:
VideoFrameSource_GPU(const String& fileName);
VideoFrameSource_CUDA(const String& fileName);
void nextFrame(OutputArray frame);
void reset();
@@ -226,12 +226,12 @@ namespace
GpuMat frame_;
};
VideoFrameSource_GPU::VideoFrameSource_GPU(const String& fileName) : fileName_(fileName)
VideoFrameSource_CUDA::VideoFrameSource_CUDA(const String& fileName) : fileName_(fileName)
{
reset();
}
void VideoFrameSource_GPU::nextFrame(OutputArray _frame)
void VideoFrameSource_CUDA::nextFrame(OutputArray _frame)
{
if (_frame.kind() == _InputArray::GPU_MAT)
{
@@ -249,13 +249,13 @@ namespace
}
}
void VideoFrameSource_GPU::reset()
void VideoFrameSource_CUDA::reset()
{
reader_ = cudacodec::createVideoReader(fileName_);
}
}
Ptr<FrameSource> cv::superres::createFrameSource_Video_GPU(const String& fileName)
Ptr<FrameSource> cv::superres::createFrameSource_Video_CUDA(const String& fileName)
{
return new VideoFrameSource(fileName);
}

View File

@@ -345,25 +345,25 @@ Ptr<DenseOpticalFlowExt> cv::superres::createOptFlow_DualTVL1()
#ifndef HAVE_OPENCV_CUDAOPTFLOW
Ptr<DenseOpticalFlowExt> cv::superres::createOptFlow_Farneback_GPU()
Ptr<DenseOpticalFlowExt> cv::superres::createOptFlow_Farneback_CUDA()
{
CV_Error(cv::Error::StsNotImplemented, "The called functionality is disabled for current build or platform");
return Ptr<DenseOpticalFlowExt>();
}
Ptr<DenseOpticalFlowExt> cv::superres::createOptFlow_DualTVL1_GPU()
Ptr<DenseOpticalFlowExt> cv::superres::createOptFlow_DualTVL1_CUDA()
{
CV_Error(cv::Error::StsNotImplemented, "The called functionality is disabled for current build or platform");
return Ptr<DenseOpticalFlowExt>();
}
Ptr<DenseOpticalFlowExt> cv::superres::createOptFlow_Brox_GPU()
Ptr<DenseOpticalFlowExt> cv::superres::createOptFlow_Brox_CUDA()
{
CV_Error(cv::Error::StsNotImplemented, "The called functionality is disabled for current build or platform");
return Ptr<DenseOpticalFlowExt>();
}
Ptr<DenseOpticalFlowExt> cv::superres::createOptFlow_PyrLK_GPU()
Ptr<DenseOpticalFlowExt> cv::superres::createOptFlow_PyrLK_CUDA()
{
CV_Error(cv::Error::StsNotImplemented, "The called functionality is disabled for current build or platform");
return Ptr<DenseOpticalFlowExt>();
@@ -437,16 +437,16 @@ namespace
}
///////////////////////////////////////////////////////////////////
// Brox_GPU
// Brox_CUDA
namespace
{
class Brox_GPU : public GpuOpticalFlow
class Brox_CUDA : public GpuOpticalFlow
{
public:
AlgorithmInfo* info() const;
Brox_GPU();
Brox_CUDA();
void collectGarbage();
@@ -464,7 +464,7 @@ namespace
BroxOpticalFlow alg_;
};
CV_INIT_ALGORITHM(Brox_GPU, "DenseOpticalFlowExt.Brox_GPU",
CV_INIT_ALGORITHM(Brox_CUDA, "DenseOpticalFlowExt.Brox_CUDA",
obj.info()->addParam(obj, "alpha", obj.alpha_, false, 0, 0, "Flow smoothness");
obj.info()->addParam(obj, "gamma", obj.gamma_, false, 0, 0, "Gradient constancy importance");
obj.info()->addParam(obj, "scaleFactor", obj.scaleFactor_, false, 0, 0, "Pyramid scale factor");
@@ -472,7 +472,7 @@ namespace
obj.info()->addParam(obj, "outerIterations", obj.outerIterations_, false, 0, 0, "Number of warping iterations (number of pyramid levels)");
obj.info()->addParam(obj, "solverIterations", obj.solverIterations_, false, 0, 0, "Number of linear system solver iterations"));
Brox_GPU::Brox_GPU() : GpuOpticalFlow(CV_32FC1), alg_(0.197f, 50.0f, 0.8f, 10, 77, 10)
Brox_CUDA::Brox_CUDA() : GpuOpticalFlow(CV_32FC1), alg_(0.197f, 50.0f, 0.8f, 10, 77, 10)
{
alpha_ = alg_.alpha;
gamma_ = alg_.gamma;
@@ -482,7 +482,7 @@ namespace
solverIterations_ = alg_.solver_iterations;
}
void Brox_GPU::impl(const GpuMat& input0, const GpuMat& input1, GpuMat& dst1, GpuMat& dst2)
void Brox_CUDA::impl(const GpuMat& input0, const GpuMat& input1, GpuMat& dst1, GpuMat& dst2)
{
alg_.alpha = static_cast<float>(alpha_);
alg_.gamma = static_cast<float>(gamma_);
@@ -494,29 +494,29 @@ namespace
alg_(input0, input1, dst1, dst2);
}
void Brox_GPU::collectGarbage()
void Brox_CUDA::collectGarbage()
{
alg_.buf.release();
GpuOpticalFlow::collectGarbage();
}
}
Ptr<DenseOpticalFlowExt> cv::superres::createOptFlow_Brox_GPU()
Ptr<DenseOpticalFlowExt> cv::superres::createOptFlow_Brox_CUDA()
{
return new Brox_GPU;
return new Brox_CUDA;
}
///////////////////////////////////////////////////////////////////
// PyrLK_GPU
// PyrLK_CUDA
namespace
{
class PyrLK_GPU : public GpuOpticalFlow
class PyrLK_CUDA : public GpuOpticalFlow
{
public:
AlgorithmInfo* info() const;
PyrLK_GPU();
PyrLK_CUDA();
void collectGarbage();
@@ -531,19 +531,19 @@ namespace
PyrLKOpticalFlow alg_;
};
CV_INIT_ALGORITHM(PyrLK_GPU, "DenseOpticalFlowExt.PyrLK_GPU",
CV_INIT_ALGORITHM(PyrLK_CUDA, "DenseOpticalFlowExt.PyrLK_CUDA",
obj.info()->addParam(obj, "winSize", obj.winSize_);
obj.info()->addParam(obj, "maxLevel", obj.maxLevel_);
obj.info()->addParam(obj, "iterations", obj.iterations_));
PyrLK_GPU::PyrLK_GPU() : GpuOpticalFlow(CV_8UC1)
PyrLK_CUDA::PyrLK_CUDA() : GpuOpticalFlow(CV_8UC1)
{
winSize_ = alg_.winSize.width;
maxLevel_ = alg_.maxLevel;
iterations_ = alg_.iters;
}
void PyrLK_GPU::impl(const GpuMat& input0, const GpuMat& input1, GpuMat& dst1, GpuMat& dst2)
void PyrLK_CUDA::impl(const GpuMat& input0, const GpuMat& input1, GpuMat& dst1, GpuMat& dst2)
{
alg_.winSize.width = winSize_;
alg_.winSize.height = winSize_;
@@ -553,29 +553,29 @@ namespace
alg_.dense(input0, input1, dst1, dst2);
}
void PyrLK_GPU::collectGarbage()
void PyrLK_CUDA::collectGarbage()
{
alg_.releaseMemory();
GpuOpticalFlow::collectGarbage();
}
}
Ptr<DenseOpticalFlowExt> cv::superres::createOptFlow_PyrLK_GPU()
Ptr<DenseOpticalFlowExt> cv::superres::createOptFlow_PyrLK_CUDA()
{
return new PyrLK_GPU;
return new PyrLK_CUDA;
}
///////////////////////////////////////////////////////////////////
// Farneback_GPU
// Farneback_CUDA
namespace
{
class Farneback_GPU : public GpuOpticalFlow
class Farneback_CUDA : public GpuOpticalFlow
{
public:
AlgorithmInfo* info() const;
Farneback_GPU();
Farneback_CUDA();
void collectGarbage();
@@ -594,7 +594,7 @@ namespace
FarnebackOpticalFlow alg_;
};
CV_INIT_ALGORITHM(Farneback_GPU, "DenseOpticalFlowExt.Farneback_GPU",
CV_INIT_ALGORITHM(Farneback_CUDA, "DenseOpticalFlowExt.Farneback_CUDA",
obj.info()->addParam(obj, "pyrScale", obj.pyrScale_);
obj.info()->addParam(obj, "numLevels", obj.numLevels_);
obj.info()->addParam(obj, "winSize", obj.winSize_);
@@ -603,7 +603,7 @@ namespace
obj.info()->addParam(obj, "polySigma", obj.polySigma_);
obj.info()->addParam(obj, "flags", obj.flags_));
Farneback_GPU::Farneback_GPU() : GpuOpticalFlow(CV_8UC1)
Farneback_CUDA::Farneback_CUDA() : GpuOpticalFlow(CV_8UC1)
{
pyrScale_ = alg_.pyrScale;
numLevels_ = alg_.numLevels;
@@ -614,7 +614,7 @@ namespace
flags_ = alg_.flags;
}
void Farneback_GPU::impl(const GpuMat& input0, const GpuMat& input1, GpuMat& dst1, GpuMat& dst2)
void Farneback_CUDA::impl(const GpuMat& input0, const GpuMat& input1, GpuMat& dst1, GpuMat& dst2)
{
alg_.pyrScale = pyrScale_;
alg_.numLevels = numLevels_;
@@ -627,29 +627,29 @@ namespace
alg_(input0, input1, dst1, dst2);
}
void Farneback_GPU::collectGarbage()
void Farneback_CUDA::collectGarbage()
{
alg_.releaseMemory();
GpuOpticalFlow::collectGarbage();
}
}
Ptr<DenseOpticalFlowExt> cv::superres::createOptFlow_Farneback_GPU()
Ptr<DenseOpticalFlowExt> cv::superres::createOptFlow_Farneback_CUDA()
{
return new Farneback_GPU;
return new Farneback_CUDA;
}
///////////////////////////////////////////////////////////////////
// DualTVL1_GPU
// DualTVL1_CUDA
namespace
{
class DualTVL1_GPU : public GpuOpticalFlow
class DualTVL1_CUDA : public GpuOpticalFlow
{
public:
AlgorithmInfo* info() const;
DualTVL1_GPU();
DualTVL1_CUDA();
void collectGarbage();
@@ -666,10 +666,10 @@ namespace
int iterations_;
bool useInitialFlow_;
OpticalFlowDual_TVL1_GPU alg_;
OpticalFlowDual_TVL1_CUDA alg_;
};
CV_INIT_ALGORITHM(DualTVL1_GPU, "DenseOpticalFlowExt.DualTVL1_GPU",
CV_INIT_ALGORITHM(DualTVL1_CUDA, "DenseOpticalFlowExt.DualTVL1_CUDA",
obj.info()->addParam(obj, "tau", obj.tau_);
obj.info()->addParam(obj, "lambda", obj.lambda_);
obj.info()->addParam(obj, "theta", obj.theta_);
@@ -679,7 +679,7 @@ namespace
obj.info()->addParam(obj, "iterations", obj.iterations_);
obj.info()->addParam(obj, "useInitialFlow", obj.useInitialFlow_));
DualTVL1_GPU::DualTVL1_GPU() : GpuOpticalFlow(CV_8UC1)
DualTVL1_CUDA::DualTVL1_CUDA() : GpuOpticalFlow(CV_8UC1)
{
tau_ = alg_.tau;
lambda_ = alg_.lambda;
@@ -691,7 +691,7 @@ namespace
useInitialFlow_ = alg_.useInitialFlow;
}
void DualTVL1_GPU::impl(const GpuMat& input0, const GpuMat& input1, GpuMat& dst1, GpuMat& dst2)
void DualTVL1_CUDA::impl(const GpuMat& input0, const GpuMat& input1, GpuMat& dst1, GpuMat& dst2)
{
alg_.tau = tau_;
alg_.lambda = lambda_;
@@ -705,16 +705,16 @@ namespace
alg_(input0, input1, dst1, dst2);
}
void DualTVL1_GPU::collectGarbage()
void DualTVL1_CUDA::collectGarbage()
{
alg_.collectGarbage();
GpuOpticalFlow::collectGarbage();
}
}
Ptr<DenseOpticalFlowExt> cv::superres::createOptFlow_DualTVL1_GPU()
Ptr<DenseOpticalFlowExt> cv::superres::createOptFlow_DualTVL1_CUDA()
{
return new DualTVL1_GPU;
return new DualTVL1_CUDA;
}
#endif // HAVE_OPENCV_CUDAOPTFLOW