OpenCLBackendWrapper::update(ld.outputBlobsWrappers, umats);
}
#endif
- Range chrange[] = { Range::all(), Range::all(), Range::all(), Range::all() };
++
+#ifdef HAVE_CUDA
+ if (preferableBackend == DNN_BACKEND_CUDA)
+ ld.outputBlobsWrappers[0] = wrap(output);
+#endif
+ std::vector<Range> chrange(output.dims, Range::all());
++
int ofs = 0;
for( i = 0; i < ninputs; i++ )
{
}
}
- GainCompensator compensator;
- compensator.feed(block_corners, block_images, block_masks);
- std::vector<double> gains = compensator.gains();
- gain_maps_.resize(num_images);
+ if (getUpdateGain() || int(gain_maps_.size()) != num_images)
+ {
+ Compensator compensator;
+ compensator.setNrFeeds(getNrFeeds());
+ compensator.feed(block_corners, block_images, block_masks);
- Mat_<float> ker(1, 3);
- ker(0,0) = 0.25; ker(0,1) = 0.5; ker(0,2) = 0.25;
+ gain_maps_.clear();
+ gain_maps_.resize(num_images);
- int bl_idx = 0;
- for (int img_idx = 0; img_idx < num_images; ++img_idx)
- {
- Size bl_per_img = bl_per_imgs[img_idx];
- gain_maps_[img_idx].create(bl_per_img, CV_32F);
+ Mat_<float> ker(1, 3);
+ ker(0, 0) = 0.25; ker(0, 1) = 0.5; ker(0, 2) = 0.25;
+ int bl_idx = 0;
+ for (int img_idx = 0; img_idx < num_images; ++img_idx)
{
- Mat_<float> gain_map = gain_maps_[img_idx].getMat(ACCESS_WRITE);
- for (int by = 0; by < bl_per_img.height; ++by)
- for (int bx = 0; bx < bl_per_img.width; ++bx, ++bl_idx)
- gain_map(by, bx) = static_cast<float>(gains[bl_idx]);
- }
+ Size bl_per_img = bl_per_imgs[img_idx];
+ UMat gain_map = getGainMap(compensator, bl_idx, bl_per_img);
+ bl_idx += bl_per_img.width*bl_per_img.height;
+
+ for (int i=0; i<nr_gain_filtering_iterations_; ++i)
- sepFilter2D(gain_map, gain_map, CV_32F, ker, ker);
++ {
++ UMat tmp;
++ sepFilter2D(gain_map, tmp, CV_32F, ker, ker);
++ swap(gain_map, tmp);
++ }
- // 2 smooth passes
- UMat result;
- sepFilter2D(gain_maps_[img_idx], result, CV_32F, ker, ker);
- UMat result2;
- sepFilter2D(result, result2, CV_32F, ker, ker);
- swap(gain_maps_[img_idx], result2);
+ gain_maps_[img_idx] = gain_map;
+ }
}
}