Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Tetragramm
GitHub Repository: Tetragramm/opencv
Path: blob/master/modules/superres/src/btv_l1_cuda.cpp
16339 views
1
/*M///////////////////////////////////////////////////////////////////////////////////////
2
//
3
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
4
//
5
// By downloading, copying, installing or using the software you agree to this license.
6
// If you do not agree to this license, do not download, install,
7
// copy or use the software.
8
//
9
//
10
// License Agreement
11
// For Open Source Computer Vision Library
12
//
13
// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
14
// Copyright (C) 2009, Willow Garage Inc., all rights reserved.
15
// Third party copyrights are property of their respective owners.
16
//
17
// Redistribution and use in source and binary forms, with or without modification,
18
// are permitted provided that the following conditions are met:
19
//
20
// * Redistribution's of source code must retain the above copyright notice,
21
// this list of conditions and the following disclaimer.
22
//
23
// * Redistribution's in binary form must reproduce the above copyright notice,
24
// this list of conditions and the following disclaimer in the documentation
25
// and/or other materials provided with the distribution.
26
//
27
// * The name of the copyright holders may not be used to endorse or promote products
28
// derived from this software without specific prior written permission.
29
//
30
// This software is provided by the copyright holders and contributors "as is" and
31
// any express or implied warranties, including, but not limited to, the implied
32
// warranties of merchantability and fitness for a particular purpose are disclaimed.
33
// In no event shall the Intel Corporation or contributors be liable for any direct,
34
// indirect, incidental, special, exemplary, or consequential damages
35
// (including, but not limited to, procurement of substitute goods or services;
36
// loss of use, data, or profits; or business interruption) however caused
37
// and on any theory of liability, whether in contract, strict liability,
38
// or tort (including negligence or otherwise) arising in any way out of
39
// the use of this software, even if advised of the possibility of such damage.
40
//
41
//M*/
42
43
// S. Farsiu , D. Robinson, M. Elad, P. Milanfar. Fast and robust multiframe super resolution.
44
// Dennis Mitzel, Thomas Pock, Thomas Schoenemann, Daniel Cremers. Video Super Resolution using Duality Based TV-L1 Optical Flow.
45
46
#include "precomp.hpp"
47
48
using namespace cv;
49
using namespace cv::cuda;
50
using namespace cv::superres;
51
using namespace cv::superres::detail;
52
53
#if !defined(HAVE_CUDA) || !defined(HAVE_OPENCV_CUDAARITHM) || !defined(HAVE_OPENCV_CUDAWARPING) || !defined(HAVE_OPENCV_CUDAFILTERS)
54
55
Ptr<SuperResolution> cv::superres::createSuperResolution_BTVL1_CUDA()
56
{
57
CV_Error(Error::StsNotImplemented, "The called functionality is disabled for current build or platform");
58
}
59
60
#else // HAVE_CUDA
61
62
namespace btv_l1_cudev
63
{
64
void buildMotionMaps(PtrStepSzf forwardMotionX, PtrStepSzf forwardMotionY,
65
PtrStepSzf backwardMotionX, PtrStepSzf bacwardMotionY,
66
PtrStepSzf forwardMapX, PtrStepSzf forwardMapY,
67
PtrStepSzf backwardMapX, PtrStepSzf backwardMapY);
68
69
template <int cn>
70
void upscale(const PtrStepSzb src, PtrStepSzb dst, int scale, cudaStream_t stream);
71
72
void diffSign(PtrStepSzf src1, PtrStepSzf src2, PtrStepSzf dst, cudaStream_t stream);
73
74
void loadBtvWeights(const float* weights, size_t count);
75
template <int cn> void calcBtvRegularization(PtrStepSzb src, PtrStepSzb dst, int ksize);
76
}
77
78
namespace
79
{
80
void calcRelativeMotions(const std::vector<std::pair<GpuMat, GpuMat> >& forwardMotions, const std::vector<std::pair<GpuMat, GpuMat> >& backwardMotions,
81
std::vector<std::pair<GpuMat, GpuMat> >& relForwardMotions, std::vector<std::pair<GpuMat, GpuMat> >& relBackwardMotions,
82
int baseIdx, Size size)
83
{
84
const int count = static_cast<int>(forwardMotions.size());
85
86
relForwardMotions.resize(count);
87
relForwardMotions[baseIdx].first.create(size, CV_32FC1);
88
relForwardMotions[baseIdx].first.setTo(Scalar::all(0));
89
relForwardMotions[baseIdx].second.create(size, CV_32FC1);
90
relForwardMotions[baseIdx].second.setTo(Scalar::all(0));
91
92
relBackwardMotions.resize(count);
93
relBackwardMotions[baseIdx].first.create(size, CV_32FC1);
94
relBackwardMotions[baseIdx].first.setTo(Scalar::all(0));
95
relBackwardMotions[baseIdx].second.create(size, CV_32FC1);
96
relBackwardMotions[baseIdx].second.setTo(Scalar::all(0));
97
98
for (int i = baseIdx - 1; i >= 0; --i)
99
{
100
cuda::add(relForwardMotions[i + 1].first, forwardMotions[i].first, relForwardMotions[i].first);
101
cuda::add(relForwardMotions[i + 1].second, forwardMotions[i].second, relForwardMotions[i].second);
102
103
cuda::add(relBackwardMotions[i + 1].first, backwardMotions[i + 1].first, relBackwardMotions[i].first);
104
cuda::add(relBackwardMotions[i + 1].second, backwardMotions[i + 1].second, relBackwardMotions[i].second);
105
}
106
107
for (int i = baseIdx + 1; i < count; ++i)
108
{
109
cuda::add(relForwardMotions[i - 1].first, backwardMotions[i].first, relForwardMotions[i].first);
110
cuda::add(relForwardMotions[i - 1].second, backwardMotions[i].second, relForwardMotions[i].second);
111
112
cuda::add(relBackwardMotions[i - 1].first, forwardMotions[i - 1].first, relBackwardMotions[i].first);
113
cuda::add(relBackwardMotions[i - 1].second, forwardMotions[i - 1].second, relBackwardMotions[i].second);
114
}
115
}
116
117
void upscaleMotions(const std::vector<std::pair<GpuMat, GpuMat> >& lowResMotions, std::vector<std::pair<GpuMat, GpuMat> >& highResMotions, int scale)
118
{
119
highResMotions.resize(lowResMotions.size());
120
121
for (size_t i = 0; i < lowResMotions.size(); ++i)
122
{
123
cuda::resize(lowResMotions[i].first, highResMotions[i].first, Size(), scale, scale, INTER_CUBIC);
124
cuda::resize(lowResMotions[i].second, highResMotions[i].second, Size(), scale, scale, INTER_CUBIC);
125
126
cuda::multiply(highResMotions[i].first, Scalar::all(scale), highResMotions[i].first);
127
cuda::multiply(highResMotions[i].second, Scalar::all(scale), highResMotions[i].second);
128
}
129
}
130
131
void buildMotionMaps(const std::pair<GpuMat, GpuMat>& forwardMotion, const std::pair<GpuMat, GpuMat>& backwardMotion,
132
std::pair<GpuMat, GpuMat>& forwardMap, std::pair<GpuMat, GpuMat>& backwardMap)
133
{
134
forwardMap.first.create(forwardMotion.first.size(), CV_32FC1);
135
forwardMap.second.create(forwardMotion.first.size(), CV_32FC1);
136
137
backwardMap.first.create(forwardMotion.first.size(), CV_32FC1);
138
backwardMap.second.create(forwardMotion.first.size(), CV_32FC1);
139
140
btv_l1_cudev::buildMotionMaps(forwardMotion.first, forwardMotion.second,
141
backwardMotion.first, backwardMotion.second,
142
forwardMap.first, forwardMap.second,
143
backwardMap.first, backwardMap.second);
144
}
145
146
void upscale(const GpuMat& src, GpuMat& dst, int scale, Stream& stream)
147
{
148
typedef void (*func_t)(const PtrStepSzb src, PtrStepSzb dst, int scale, cudaStream_t stream);
149
static const func_t funcs[] =
150
{
151
0, btv_l1_cudev::upscale<1>, 0, btv_l1_cudev::upscale<3>, btv_l1_cudev::upscale<4>
152
};
153
154
CV_Assert( src.channels() == 1 || src.channels() == 3 || src.channels() == 4 );
155
156
dst.create(src.rows * scale, src.cols * scale, src.type());
157
dst.setTo(Scalar::all(0));
158
159
const func_t func = funcs[src.channels()];
160
161
func(src, dst, scale, StreamAccessor::getStream(stream));
162
}
163
164
void diffSign(const GpuMat& src1, const GpuMat& src2, GpuMat& dst, Stream& stream)
165
{
166
dst.create(src1.size(), src1.type());
167
168
btv_l1_cudev::diffSign(src1.reshape(1), src2.reshape(1), dst.reshape(1), StreamAccessor::getStream(stream));
169
}
170
171
void calcBtvWeights(int btvKernelSize, double alpha, std::vector<float>& btvWeights)
172
{
173
const size_t size = btvKernelSize * btvKernelSize;
174
175
btvWeights.resize(size);
176
177
const int ksize = (btvKernelSize - 1) / 2;
178
const float alpha_f = static_cast<float>(alpha);
179
180
for (int m = 0, ind = 0; m <= ksize; ++m)
181
{
182
for (int l = ksize; l + m >= 0; --l, ++ind)
183
btvWeights[ind] = pow(alpha_f, std::abs(m) + std::abs(l));
184
}
185
186
btv_l1_cudev::loadBtvWeights(&btvWeights[0], size);
187
}
188
189
void calcBtvRegularization(const GpuMat& src, GpuMat& dst, int btvKernelSize)
190
{
191
typedef void (*func_t)(PtrStepSzb src, PtrStepSzb dst, int ksize);
192
static const func_t funcs[] =
193
{
194
0,
195
btv_l1_cudev::calcBtvRegularization<1>,
196
0,
197
btv_l1_cudev::calcBtvRegularization<3>,
198
btv_l1_cudev::calcBtvRegularization<4>
199
};
200
201
dst.create(src.size(), src.type());
202
dst.setTo(Scalar::all(0));
203
204
const int ksize = (btvKernelSize - 1) / 2;
205
206
funcs[src.channels()](src, dst, ksize);
207
}
208
209
class BTVL1_CUDA_Base : public cv::superres::SuperResolution
210
{
211
public:
212
BTVL1_CUDA_Base();
213
214
void process(const std::vector<GpuMat>& src, GpuMat& dst,
215
const std::vector<std::pair<GpuMat, GpuMat> >& forwardMotions, const std::vector<std::pair<GpuMat, GpuMat> >& backwardMotions,
216
int baseIdx);
217
218
void collectGarbage();
219
220
inline int getScale() const CV_OVERRIDE { return scale_; }
221
inline void setScale(int val) CV_OVERRIDE { scale_ = val; }
222
inline int getIterations() const CV_OVERRIDE { return iterations_; }
223
inline void setIterations(int val) CV_OVERRIDE { iterations_ = val; }
224
inline double getTau() const CV_OVERRIDE { return tau_; }
225
inline void setTau(double val) CV_OVERRIDE { tau_ = val; }
226
inline double getLabmda() const CV_OVERRIDE { return lambda_; }
227
inline void setLabmda(double val) CV_OVERRIDE { lambda_ = val; }
228
inline double getAlpha() const CV_OVERRIDE { return alpha_; }
229
inline void setAlpha(double val) CV_OVERRIDE { alpha_ = val; }
230
inline int getKernelSize() const CV_OVERRIDE { return btvKernelSize_; }
231
inline void setKernelSize(int val) CV_OVERRIDE { btvKernelSize_ = val; }
232
inline int getBlurKernelSize() const CV_OVERRIDE { return blurKernelSize_; }
233
inline void setBlurKernelSize(int val) CV_OVERRIDE { blurKernelSize_ = val; }
234
inline double getBlurSigma() const CV_OVERRIDE { return blurSigma_; }
235
inline void setBlurSigma(double val) CV_OVERRIDE { blurSigma_ = val; }
236
inline int getTemporalAreaRadius() const CV_OVERRIDE { return temporalAreaRadius_; }
237
inline void setTemporalAreaRadius(int val) CV_OVERRIDE { temporalAreaRadius_ = val; }
238
inline Ptr<cv::superres::DenseOpticalFlowExt> getOpticalFlow() const CV_OVERRIDE { return opticalFlow_; }
239
inline void setOpticalFlow(const Ptr<cv::superres::DenseOpticalFlowExt>& val) CV_OVERRIDE { opticalFlow_ = val; }
240
241
protected:
242
int scale_;
243
int iterations_;
244
double lambda_;
245
double tau_;
246
double alpha_;
247
int btvKernelSize_;
248
int blurKernelSize_;
249
double blurSigma_;
250
int temporalAreaRadius_;
251
Ptr<cv::superres::DenseOpticalFlowExt> opticalFlow_;
252
253
private:
254
std::vector<Ptr<cuda::Filter> > filters_;
255
int curBlurKernelSize_;
256
double curBlurSigma_;
257
int curSrcType_;
258
259
std::vector<float> btvWeights_;
260
int curBtvKernelSize_;
261
double curAlpha_;
262
263
std::vector<std::pair<GpuMat, GpuMat> > lowResForwardMotions_;
264
std::vector<std::pair<GpuMat, GpuMat> > lowResBackwardMotions_;
265
266
std::vector<std::pair<GpuMat, GpuMat> > highResForwardMotions_;
267
std::vector<std::pair<GpuMat, GpuMat> > highResBackwardMotions_;
268
269
std::vector<std::pair<GpuMat, GpuMat> > forwardMaps_;
270
std::vector<std::pair<GpuMat, GpuMat> > backwardMaps_;
271
272
GpuMat highRes_;
273
274
std::vector<Stream> streams_;
275
std::vector<GpuMat> diffTerms_;
276
std::vector<GpuMat> a_, b_, c_;
277
GpuMat regTerm_;
278
};
279
280
BTVL1_CUDA_Base::BTVL1_CUDA_Base()
281
{
282
scale_ = 4;
283
iterations_ = 180;
284
lambda_ = 0.03;
285
tau_ = 1.3;
286
alpha_ = 0.7;
287
btvKernelSize_ = 7;
288
blurKernelSize_ = 5;
289
blurSigma_ = 0.0;
290
291
#ifdef HAVE_OPENCV_CUDAOPTFLOW
292
opticalFlow_ = createOptFlow_Farneback_CUDA();
293
#else
294
opticalFlow_ = createOptFlow_Farneback();
295
#endif
296
temporalAreaRadius_ = 0;
297
298
curBlurKernelSize_ = -1;
299
curBlurSigma_ = -1.0;
300
curSrcType_ = -1;
301
302
curBtvKernelSize_ = -1;
303
curAlpha_ = -1.0;
304
}
305
306
void BTVL1_CUDA_Base::process(const std::vector<GpuMat>& src, GpuMat& dst,
307
const std::vector<std::pair<GpuMat, GpuMat> >& forwardMotions, const std::vector<std::pair<GpuMat, GpuMat> >& backwardMotions,
308
int baseIdx)
309
{
310
CV_Assert( scale_ > 1 );
311
CV_Assert( iterations_ > 0 );
312
CV_Assert( tau_ > 0.0 );
313
CV_Assert( alpha_ > 0.0 );
314
CV_Assert( btvKernelSize_ > 0 && btvKernelSize_ <= 16 );
315
CV_Assert( blurKernelSize_ > 0 );
316
CV_Assert( blurSigma_ >= 0.0 );
317
318
// update blur filter and btv weights
319
320
if (filters_.size() != src.size() || blurKernelSize_ != curBlurKernelSize_ || blurSigma_ != curBlurSigma_ || src[0].type() != curSrcType_)
321
{
322
filters_.resize(src.size());
323
for (size_t i = 0; i < src.size(); ++i)
324
filters_[i] = cuda::createGaussianFilter(src[0].type(), -1, Size(blurKernelSize_, blurKernelSize_), blurSigma_);
325
curBlurKernelSize_ = blurKernelSize_;
326
curBlurSigma_ = blurSigma_;
327
curSrcType_ = src[0].type();
328
}
329
330
if (btvWeights_.empty() || btvKernelSize_ != curBtvKernelSize_ || alpha_ != curAlpha_)
331
{
332
calcBtvWeights(btvKernelSize_, alpha_, btvWeights_);
333
curBtvKernelSize_ = btvKernelSize_;
334
curAlpha_ = alpha_;
335
}
336
337
// calc motions between input frames
338
339
calcRelativeMotions(forwardMotions, backwardMotions, lowResForwardMotions_, lowResBackwardMotions_, baseIdx, src[0].size());
340
341
upscaleMotions(lowResForwardMotions_, highResForwardMotions_, scale_);
342
upscaleMotions(lowResBackwardMotions_, highResBackwardMotions_, scale_);
343
344
forwardMaps_.resize(highResForwardMotions_.size());
345
backwardMaps_.resize(highResForwardMotions_.size());
346
for (size_t i = 0; i < highResForwardMotions_.size(); ++i)
347
buildMotionMaps(highResForwardMotions_[i], highResBackwardMotions_[i], forwardMaps_[i], backwardMaps_[i]);
348
349
// initial estimation
350
351
const Size lowResSize = src[0].size();
352
const Size highResSize(lowResSize.width * scale_, lowResSize.height * scale_);
353
354
cuda::resize(src[baseIdx], highRes_, highResSize, 0, 0, INTER_CUBIC);
355
356
// iterations
357
358
streams_.resize(src.size());
359
diffTerms_.resize(src.size());
360
a_.resize(src.size());
361
b_.resize(src.size());
362
c_.resize(src.size());
363
364
for (int i = 0; i < iterations_; ++i)
365
{
366
for (size_t k = 0; k < src.size(); ++k)
367
{
368
// a = M * Ih
369
cuda::remap(highRes_, a_[k], backwardMaps_[k].first, backwardMaps_[k].second, INTER_NEAREST, BORDER_REPLICATE, Scalar(), streams_[k]);
370
// b = HM * Ih
371
filters_[k]->apply(a_[k], b_[k], streams_[k]);
372
// c = DHF * Ih
373
cuda::resize(b_[k], c_[k], lowResSize, 0, 0, INTER_NEAREST, streams_[k]);
374
375
diffSign(src[k], c_[k], c_[k], streams_[k]);
376
377
// a = Dt * diff
378
upscale(c_[k], a_[k], scale_, streams_[k]);
379
// b = HtDt * diff
380
filters_[k]->apply(a_[k], b_[k], streams_[k]);
381
// diffTerm = MtHtDt * diff
382
cuda::remap(b_[k], diffTerms_[k], forwardMaps_[k].first, forwardMaps_[k].second, INTER_NEAREST, BORDER_REPLICATE, Scalar(), streams_[k]);
383
}
384
385
if (lambda_ > 0)
386
{
387
calcBtvRegularization(highRes_, regTerm_, btvKernelSize_);
388
cuda::addWeighted(highRes_, 1.0, regTerm_, -tau_ * lambda_, 0.0, highRes_);
389
}
390
391
for (size_t k = 0; k < src.size(); ++k)
392
{
393
streams_[k].waitForCompletion();
394
cuda::addWeighted(highRes_, 1.0, diffTerms_[k], tau_, 0.0, highRes_);
395
}
396
}
397
398
Rect inner(btvKernelSize_, btvKernelSize_, highRes_.cols - 2 * btvKernelSize_, highRes_.rows - 2 * btvKernelSize_);
399
highRes_(inner).copyTo(dst);
400
}
401
402
void BTVL1_CUDA_Base::collectGarbage()
403
{
404
filters_.clear();
405
406
lowResForwardMotions_.clear();
407
lowResBackwardMotions_.clear();
408
409
highResForwardMotions_.clear();
410
highResBackwardMotions_.clear();
411
412
forwardMaps_.clear();
413
backwardMaps_.clear();
414
415
highRes_.release();
416
417
diffTerms_.clear();
418
a_.clear();
419
b_.clear();
420
c_.clear();
421
regTerm_.release();
422
}
423
424
////////////////////////////////////////////////////////////
425
426
class BTVL1_CUDA : public BTVL1_CUDA_Base
427
{
428
public:
429
BTVL1_CUDA();
430
431
void collectGarbage();
432
433
protected:
434
void initImpl(Ptr<FrameSource>& frameSource);
435
void processImpl(Ptr<FrameSource>& frameSource, OutputArray output);
436
437
private:
438
void readNextFrame(Ptr<FrameSource>& frameSource);
439
void processFrame(int idx);
440
441
GpuMat curFrame_;
442
GpuMat prevFrame_;
443
444
std::vector<GpuMat> frames_;
445
std::vector<std::pair<GpuMat, GpuMat> > forwardMotions_;
446
std::vector<std::pair<GpuMat, GpuMat> > backwardMotions_;
447
std::vector<GpuMat> outputs_;
448
449
int storePos_;
450
int procPos_;
451
int outPos_;
452
453
std::vector<GpuMat> srcFrames_;
454
std::vector<std::pair<GpuMat, GpuMat> > srcForwardMotions_;
455
std::vector<std::pair<GpuMat, GpuMat> > srcBackwardMotions_;
456
GpuMat finalOutput_;
457
};
458
459
BTVL1_CUDA::BTVL1_CUDA()
460
{
461
temporalAreaRadius_ = 4;
462
}
463
464
void BTVL1_CUDA::collectGarbage()
465
{
466
curFrame_.release();
467
prevFrame_.release();
468
469
frames_.clear();
470
forwardMotions_.clear();
471
backwardMotions_.clear();
472
outputs_.clear();
473
474
srcFrames_.clear();
475
srcForwardMotions_.clear();
476
srcBackwardMotions_.clear();
477
finalOutput_.release();
478
479
SuperResolution::collectGarbage();
480
BTVL1_CUDA_Base::collectGarbage();
481
}
482
483
void BTVL1_CUDA::initImpl(Ptr<FrameSource>& frameSource)
484
{
485
const int cacheSize = 2 * temporalAreaRadius_ + 1;
486
487
frames_.resize(cacheSize);
488
forwardMotions_.resize(cacheSize);
489
backwardMotions_.resize(cacheSize);
490
outputs_.resize(cacheSize);
491
492
storePos_ = -1;
493
494
for (int t = -temporalAreaRadius_; t <= temporalAreaRadius_; ++t)
495
readNextFrame(frameSource);
496
497
for (int i = 0; i <= temporalAreaRadius_; ++i)
498
processFrame(i);
499
500
procPos_ = temporalAreaRadius_;
501
outPos_ = -1;
502
}
503
504
void BTVL1_CUDA::processImpl(Ptr<FrameSource>& frameSource, OutputArray _output)
505
{
506
if (outPos_ >= storePos_)
507
{
508
_output.release();
509
return;
510
}
511
512
readNextFrame(frameSource);
513
514
if (procPos_ < storePos_)
515
{
516
++procPos_;
517
processFrame(procPos_);
518
}
519
520
++outPos_;
521
const GpuMat& curOutput = at(outPos_, outputs_);
522
523
if (_output.kind() == _InputArray::CUDA_GPU_MAT)
524
curOutput.convertTo(_output.getGpuMatRef(), CV_8U);
525
else
526
{
527
curOutput.convertTo(finalOutput_, CV_8U);
528
arrCopy(finalOutput_, _output);
529
}
530
}
531
532
void BTVL1_CUDA::readNextFrame(Ptr<FrameSource>& frameSource)
533
{
534
frameSource->nextFrame(curFrame_);
535
536
if (curFrame_.empty())
537
return;
538
539
++storePos_;
540
curFrame_.convertTo(at(storePos_, frames_), CV_32F);
541
542
if (storePos_ > 0)
543
{
544
std::pair<GpuMat, GpuMat>& forwardMotion = at(storePos_ - 1, forwardMotions_);
545
std::pair<GpuMat, GpuMat>& backwardMotion = at(storePos_, backwardMotions_);
546
547
opticalFlow_->calc(prevFrame_, curFrame_, forwardMotion.first, forwardMotion.second);
548
opticalFlow_->calc(curFrame_, prevFrame_, backwardMotion.first, backwardMotion.second);
549
}
550
551
curFrame_.copyTo(prevFrame_);
552
}
553
554
void BTVL1_CUDA::processFrame(int idx)
555
{
556
const int startIdx = std::max(idx - temporalAreaRadius_, 0);
557
const int procIdx = idx;
558
const int endIdx = std::min(startIdx + 2 * temporalAreaRadius_, storePos_);
559
560
const int count = endIdx - startIdx + 1;
561
562
srcFrames_.resize(count);
563
srcForwardMotions_.resize(count);
564
srcBackwardMotions_.resize(count);
565
566
int baseIdx = -1;
567
568
for (int i = startIdx, k = 0; i <= endIdx; ++i, ++k)
569
{
570
if (i == procIdx)
571
baseIdx = k;
572
573
srcFrames_[k] = at(i, frames_);
574
575
if (i < endIdx)
576
srcForwardMotions_[k] = at(i, forwardMotions_);
577
if (i > startIdx)
578
srcBackwardMotions_[k] = at(i, backwardMotions_);
579
}
580
581
process(srcFrames_, at(idx, outputs_), srcForwardMotions_, srcBackwardMotions_, baseIdx);
582
}
583
}
584
585
Ptr<SuperResolution> cv::superres::createSuperResolution_BTVL1_CUDA()
586
{
587
return makePtr<BTVL1_CUDA>();
588
}
589
590
#endif // HAVE_CUDA
591
592