added OpenCL accelerated warpers
This commit is contained in:
@@ -71,8 +71,11 @@ static void printUsage()
|
||||
" --preview\n"
|
||||
" Run stitching in the preview mode. Works faster than usual mode,\n"
|
||||
" but output image will have lower resolution.\n"
|
||||
" --try_gpu (yes|no)\n"
|
||||
" Try to use GPU. The default value is 'no'. All default values\n"
|
||||
" --try_cuda (yes|no)\n"
|
||||
" Try to use CUDA. The default value is 'no'. All default values\n"
|
||||
" are for CPU mode.\n"
|
||||
" --try_ocl (yes|no)\n"
|
||||
" Try to use OpenCL. The default value is 'no'. All default values\n"
|
||||
" are for CPU mode.\n"
|
||||
"\nMotion Estimation Flags:\n"
|
||||
" --work_megapix <float>\n"
|
||||
@@ -123,7 +126,8 @@ static void printUsage()
|
||||
// Default command line args
|
||||
vector<String> img_names;
|
||||
bool preview = false;
|
||||
bool try_gpu = false;
|
||||
bool try_cuda = false;
|
||||
bool try_ocl = false;
|
||||
double work_megapix = 0.6;
|
||||
double seam_megapix = 0.1;
|
||||
double compose_megapix = -1;
|
||||
@@ -161,15 +165,28 @@ static int parseCmdArgs(int argc, char** argv)
|
||||
{
|
||||
preview = true;
|
||||
}
|
||||
else if (string(argv[i]) == "--try_gpu")
|
||||
else if (string(argv[i]) == "--try_cuda")
|
||||
{
|
||||
if (string(argv[i + 1]) == "no")
|
||||
try_gpu = false;
|
||||
try_cuda = false;
|
||||
else if (string(argv[i + 1]) == "yes")
|
||||
try_gpu = true;
|
||||
try_cuda = true;
|
||||
else
|
||||
{
|
||||
cout << "Bad --try_gpu flag value\n";
|
||||
cout << "Bad --try_cuda flag value\n";
|
||||
return -1;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
else if (string(argv[i]) == "--try_ocl")
|
||||
{
|
||||
if (string(argv[i + 1]) == "no")
|
||||
try_ocl = false;
|
||||
else if (string(argv[i + 1]) == "yes")
|
||||
try_ocl = true;
|
||||
else
|
||||
{
|
||||
cout << "Bad --try_ocl flag value\n";
|
||||
return -1;
|
||||
}
|
||||
i++;
|
||||
@@ -357,7 +374,7 @@ int main(int argc, char* argv[])
|
||||
if (features_type == "surf")
|
||||
{
|
||||
#ifdef HAVE_OPENCV_NONFREE
|
||||
if (try_gpu && cuda::getCudaEnabledDeviceCount() > 0)
|
||||
if (try_cuda && cuda::getCudaEnabledDeviceCount() > 0)
|
||||
finder = makePtr<SurfFeaturesFinderGpu>();
|
||||
else
|
||||
#endif
|
||||
@@ -430,7 +447,7 @@ int main(int argc, char* argv[])
|
||||
t = getTickCount();
|
||||
#endif
|
||||
vector<MatchesInfo> pairwise_matches;
|
||||
BestOf2NearestMatcher matcher(try_gpu, match_conf);
|
||||
BestOf2NearestMatcher matcher(try_cuda, match_conf);
|
||||
matcher(features, pairwise_matches);
|
||||
matcher.collectGarbage();
|
||||
LOGLN("Pairwise matching, time: " << ((getTickCount() - t) / getTickFrequency()) << " sec");
|
||||
@@ -552,8 +569,17 @@ int main(int argc, char* argv[])
|
||||
// Warp images and their masks
|
||||
|
||||
Ptr<WarperCreator> warper_creator;
|
||||
if (try_ocl)
|
||||
{
|
||||
if (warp_type == "plane")
|
||||
warper_creator = makePtr<cv::PlaneWarperOcl>();
|
||||
else if (warp_type == "cylindrical")
|
||||
warper_creator = makePtr<cv::CylindricalWarperOcl>();
|
||||
else if (warp_type == "spherical")
|
||||
warper_creator = makePtr<cv::SphericalWarperOcl>();
|
||||
}
|
||||
#ifdef HAVE_OPENCV_CUDAWARPING
|
||||
if (try_gpu && cuda::getCudaEnabledDeviceCount() > 0)
|
||||
else if (try_cuda && cuda::getCudaEnabledDeviceCount() > 0)
|
||||
{
|
||||
if (warp_type == "plane")
|
||||
warper_creator = makePtr<cv::PlaneWarperGpu>();
|
||||
@@ -636,7 +662,7 @@ int main(int argc, char* argv[])
|
||||
else if (seam_find_type == "gc_color")
|
||||
{
|
||||
#ifdef HAVE_OPENCV_CUDA
|
||||
if (try_gpu && cuda::getCudaEnabledDeviceCount() > 0)
|
||||
if (try_cuda && cuda::getCudaEnabledDeviceCount() > 0)
|
||||
seam_finder = makePtr<detail::GraphCutSeamFinderGpu>(GraphCutSeamFinderBase::COST_COLOR);
|
||||
else
|
||||
#endif
|
||||
@@ -645,7 +671,7 @@ int main(int argc, char* argv[])
|
||||
else if (seam_find_type == "gc_colorgrad")
|
||||
{
|
||||
#ifdef HAVE_OPENCV_CUDA
|
||||
if (try_gpu && cuda::getCudaEnabledDeviceCount() > 0)
|
||||
if (try_cuda && cuda::getCudaEnabledDeviceCount() > 0)
|
||||
seam_finder = makePtr<detail::GraphCutSeamFinderGpu>(GraphCutSeamFinderBase::COST_COLOR_GRAD);
|
||||
else
|
||||
#endif
|
||||
@@ -755,11 +781,11 @@ int main(int argc, char* argv[])
|
||||
|
||||
if (!blender)
|
||||
{
|
||||
blender = Blender::createDefault(blend_type, try_gpu);
|
||||
blender = Blender::createDefault(blend_type, try_cuda);
|
||||
Size dst_sz = resultRoi(corners, sizes).size();
|
||||
float blend_width = sqrt(static_cast<float>(dst_sz.area())) * blend_strength / 100.f;
|
||||
if (blend_width < 1.f)
|
||||
blender = Blender::createDefault(Blender::NO, try_gpu);
|
||||
blender = Blender::createDefault(Blender::NO, try_cuda);
|
||||
else if (blend_type == Blender::MULTI_BAND)
|
||||
{
|
||||
MultiBandBlender* mb = dynamic_cast<MultiBandBlender*>(blender.get());
|
||||
|
Reference in New Issue
Block a user