refactored border interpolation in gpu module
This commit is contained in:
63
modules/gpu/src/border_interpolate.cpp
Normal file
63
modules/gpu/src/border_interpolate.cpp
Normal file
@@ -0,0 +1,63 @@
|
|||||||
|
/*M///////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
||||||
|
//
|
||||||
|
// By downloading, copying, installing or using the software you agree to this license.
|
||||||
|
// If you do not agree to this license, do not download, install,
|
||||||
|
// copy or use the software.
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// License Agreement
|
||||||
|
// For Open Source Computer Vision Library
|
||||||
|
//
|
||||||
|
// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
|
||||||
|
// Copyright (C) 2009, Willow Garage Inc., all rights reserved.
|
||||||
|
// Third party copyrights are property of their respective owners.
|
||||||
|
//
|
||||||
|
// Redistribution and use in source and binary forms, with or without modification,
|
||||||
|
// are permitted provided that the following conditions are met:
|
||||||
|
//
|
||||||
|
// * Redistribution's of source code must retain the above copyright notice,
|
||||||
|
// this list of conditions and the following disclaimer.
|
||||||
|
//
|
||||||
|
// * Redistribution's in binary form must reproduce the above copyright notice,
|
||||||
|
// this list of conditions and the following disclaimer in the documentation
|
||||||
|
// and/or other materials provided with the distribution.
|
||||||
|
//
|
||||||
|
// * The name of the copyright holders may not be used to endorse or promote products
|
||||||
|
// derived from this software without specific prior written permission.
|
||||||
|
//
|
||||||
|
// This software is provided by the copyright holders and contributors "as is" and
|
||||||
|
// any express or implied warranties, including, but not limited to, the implied
|
||||||
|
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
||||||
|
// In no event shall the Intel Corporation or contributors be liable for any direct,
|
||||||
|
// indirect, incidental, special, exemplary, or consequential damages
|
||||||
|
// (including, but not limited to, procurement of substitute goods or services;
|
||||||
|
// loss of use, data, or profits; or business interruption) however caused
|
||||||
|
// and on any theory of liability, whether in contract, strict liability,
|
||||||
|
// or tort (including negligence or otherwise) arising in any way out of
|
||||||
|
// the use of this software, even if advised of the possibility of such damage.
|
||||||
|
//
|
||||||
|
//M*/
|
||||||
|
|
||||||
|
#include "internal_common.hpp"
|
||||||
|
#include "border_interpolate.hpp"
|
||||||
|
#include "opencv2/gpu/gpu.hpp"
|
||||||
|
|
||||||
|
|
||||||
|
bool cv::gpu::tryConvertToGpuBorderType(int cpuBorderType, int& gpuBorderType)
|
||||||
|
{
|
||||||
|
if (cpuBorderType == cv::BORDER_REFLECT101)
|
||||||
|
{
|
||||||
|
gpuBorderType = cv::gpu::BORDER_REFLECT101;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cpuBorderType == cv::BORDER_REPLICATE)
|
||||||
|
{
|
||||||
|
gpuBorderType = cv::gpu::BORDER_REPLICATE;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
56
modules/gpu/src/border_interpolate.hpp
Normal file
56
modules/gpu/src/border_interpolate.hpp
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
/*M///////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
||||||
|
//
|
||||||
|
// By downloading, copying, installing or using the software you agree to this license.
|
||||||
|
// If you do not agree to this license, do not download, install,
|
||||||
|
// copy or use the software.
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// License Agreement
|
||||||
|
// For Open Source Computer Vision Library
|
||||||
|
//
|
||||||
|
// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
|
||||||
|
// Copyright (C) 2009, Willow Garage Inc., all rights reserved.
|
||||||
|
// Third party copyrights are property of their respective owners.
|
||||||
|
//
|
||||||
|
// Redistribution and use in source and binary forms, with or without modification,
|
||||||
|
// are permitted provided that the following conditions are met:
|
||||||
|
//
|
||||||
|
// * Redistribution's of source code must retain the above copyright notice,
|
||||||
|
// this list of conditions and the following disclaimer.
|
||||||
|
//
|
||||||
|
// * Redistribution's in binary form must reproduce the above copyright notice,
|
||||||
|
// this list of conditions and the following disclaimer in the documentation
|
||||||
|
// and/or other materials provided with the distribution.
|
||||||
|
//
|
||||||
|
// * The name of the copyright holders may not be used to endorse or promote products
|
||||||
|
// derived from this software without specific prior written permission.
|
||||||
|
//
|
||||||
|
// This software is provided by the copyright holders and contributors "as is" and
|
||||||
|
// any express or implied warranties, including, but not limited to, the implied
|
||||||
|
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
||||||
|
// In no event shall the Intel Corporation or contributors be liable for any direct,
|
||||||
|
// indirect, incidental, special, exemplary, or consequential damages
|
||||||
|
// (including, but not limited to, procurement of substitute goods or services;
|
||||||
|
// loss of use, data, or profits; or business interruption) however caused
|
||||||
|
// and on any theory of liability, whether in contract, strict liability,
|
||||||
|
// or tort (including negligence or otherwise) arising in any way out of
|
||||||
|
// the use of this software, even if advised of the possibility of such damage.
|
||||||
|
//
|
||||||
|
//M*/
|
||||||
|
|
||||||
|
#ifndef __OPENCV_GPU_BORDER_INTERPOLATE_HPP__
|
||||||
|
#define __OPENCV_GPU_BORDER_INTERPOLATE_HPP__
|
||||||
|
|
||||||
|
#include "border_interpolate.hpp"
|
||||||
|
|
||||||
|
namespace cv { namespace gpu {
|
||||||
|
|
||||||
|
// Converts CPU border extrapolation mode into GPU internal analogue.
|
||||||
|
// Returns true if the GPU analogue exists, false otherwise.
|
||||||
|
bool tryConvertToGpuBorderType(int cpuBorderType, int& gpuBorderType);
|
||||||
|
|
||||||
|
}}
|
||||||
|
|
||||||
|
#endif
|
@@ -28,7 +28,7 @@
|
|||||||
// derived from this software without specific prior written permission.
|
// derived from this software without specific prior written permission.
|
||||||
//
|
//
|
||||||
// This software is provided by the copyright holders and contributors "as is" and
|
// This software is provided by the copyright holders and contributors "as is" and
|
||||||
// any express or bpied warranties, including, but not limited to, the bpied
|
// any express or implied warranties, including, but not limited to, the implied
|
||||||
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
||||||
// In no event shall the Intel Corporation or contributors be liable for any direct,
|
// In no event shall the Intel Corporation or contributors be liable for any direct,
|
||||||
// indirect, incidental, special, exemplary, or consequential damages
|
// indirect, incidental, special, exemplary, or consequential damages
|
||||||
@@ -40,6 +40,11 @@
|
|||||||
//
|
//
|
||||||
//M*/
|
//M*/
|
||||||
|
|
||||||
|
#ifndef __OPENCV_GPU_BORDER_INTERPOLATE_HPP__
|
||||||
|
#define __OPENCV_GPU_BORDER_INTERPOLATE_HPP__
|
||||||
|
|
||||||
|
#include "../internal_common.hpp"
|
||||||
|
|
||||||
namespace cv { namespace gpu {
|
namespace cv { namespace gpu {
|
||||||
|
|
||||||
struct BrdReflect101
|
struct BrdReflect101
|
||||||
@@ -170,3 +175,5 @@ namespace cv { namespace gpu {
|
|||||||
};
|
};
|
||||||
|
|
||||||
}}
|
}}
|
||||||
|
|
||||||
|
#endif
|
@@ -95,13 +95,6 @@ namespace cv
|
|||||||
cudaSafeCall( cudaUnbindTexture(tex) );
|
cudaSafeCall( cudaUnbindTexture(tex) );
|
||||||
}
|
}
|
||||||
|
|
||||||
// Available GPU border interpolation modes (named as CPU
|
|
||||||
// border interpolation modes)
|
|
||||||
enum
|
|
||||||
{
|
|
||||||
BORDER_REFLECT101 = 0,
|
|
||||||
BORDER_REPLICATE
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -42,7 +42,6 @@
|
|||||||
|
|
||||||
#include "cuda_shared.hpp"
|
#include "cuda_shared.hpp"
|
||||||
#include "border_interpolate.hpp"
|
#include "border_interpolate.hpp"
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
using namespace cv::gpu;
|
using namespace cv::gpu;
|
||||||
|
|
||||||
|
@@ -41,6 +41,7 @@
|
|||||||
//M*/
|
//M*/
|
||||||
|
|
||||||
#include "precomp.hpp"
|
#include "precomp.hpp"
|
||||||
|
#include "border_interpolate.hpp"
|
||||||
|
|
||||||
using namespace cv;
|
using namespace cv;
|
||||||
using namespace cv::gpu;
|
using namespace cv::gpu;
|
||||||
@@ -940,18 +941,11 @@ namespace
|
|||||||
|
|
||||||
void cv::gpu::cornerHarris(const GpuMat& src, GpuMat& dst, int blockSize, int ksize, double k, int borderType)
|
void cv::gpu::cornerHarris(const GpuMat& src, GpuMat& dst, int blockSize, int ksize, double k, int borderType)
|
||||||
{
|
{
|
||||||
|
CV_Assert(borderType == cv::BORDER_REFLECT101 ||
|
||||||
|
borderType == cv::BORDER_REPLICATE);
|
||||||
|
|
||||||
int gpuBorderType;
|
int gpuBorderType;
|
||||||
switch (borderType)
|
CV_Assert(tryConvertToGpuBorderType(borderType, gpuBorderType));
|
||||||
{
|
|
||||||
case cv::BORDER_REFLECT101:
|
|
||||||
gpuBorderType = cv::gpu::BORDER_REFLECT101;
|
|
||||||
break;
|
|
||||||
case cv::BORDER_REPLICATE:
|
|
||||||
gpuBorderType = cv::gpu::BORDER_REPLICATE;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
CV_Error(CV_StsBadArg, "cornerHarris: unsupported border extrapolation mode");
|
|
||||||
}
|
|
||||||
|
|
||||||
GpuMat Dx, Dy;
|
GpuMat Dx, Dy;
|
||||||
extractCovData(src, Dx, Dy, blockSize, ksize, gpuBorderType);
|
extractCovData(src, Dx, Dy, blockSize, ksize, gpuBorderType);
|
||||||
@@ -961,18 +955,11 @@ void cv::gpu::cornerHarris(const GpuMat& src, GpuMat& dst, int blockSize, int ks
|
|||||||
|
|
||||||
void cv::gpu::cornerMinEigenVal(const GpuMat& src, GpuMat& dst, int blockSize, int ksize, int borderType)
|
void cv::gpu::cornerMinEigenVal(const GpuMat& src, GpuMat& dst, int blockSize, int ksize, int borderType)
|
||||||
{
|
{
|
||||||
|
CV_Assert(borderType == cv::BORDER_REFLECT101 ||
|
||||||
|
borderType == cv::BORDER_REPLICATE);
|
||||||
|
|
||||||
int gpuBorderType;
|
int gpuBorderType;
|
||||||
switch (borderType)
|
CV_Assert(tryConvertToGpuBorderType(borderType, gpuBorderType));
|
||||||
{
|
|
||||||
case cv::BORDER_REFLECT101:
|
|
||||||
gpuBorderType = cv::gpu::BORDER_REFLECT101;
|
|
||||||
break;
|
|
||||||
case cv::BORDER_REPLICATE:
|
|
||||||
gpuBorderType = cv::gpu::BORDER_REPLICATE;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
CV_Error(CV_StsBadArg, "cornerMinEigenVal: unsupported border extrapolation mode");
|
|
||||||
}
|
|
||||||
|
|
||||||
GpuMat Dx, Dy;
|
GpuMat Dx, Dy;
|
||||||
extractCovData(src, Dx, Dy, blockSize, ksize, gpuBorderType);
|
extractCovData(src, Dx, Dy, blockSize, ksize, gpuBorderType);
|
||||||
|
57
modules/gpu/src/internal_common.hpp
Normal file
57
modules/gpu/src/internal_common.hpp
Normal file
@@ -0,0 +1,57 @@
|
|||||||
|
/*M///////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
||||||
|
//
|
||||||
|
// By downloading, copying, installing or using the software you agree to this license.
|
||||||
|
// If you do not agree to this license, do not download, install,
|
||||||
|
// copy or use the software.
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// License Agreement
|
||||||
|
// For Open Source Computer Vision Library
|
||||||
|
//
|
||||||
|
// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
|
||||||
|
// Copyright (C) 2009, Willow Garage Inc., all rights reserved.
|
||||||
|
// Third party copyrights are property of their respective owners.
|
||||||
|
//
|
||||||
|
// Redistribution and use in source and binary forms, with or without modification,
|
||||||
|
// are permitted provided that the following conditions are met:
|
||||||
|
//
|
||||||
|
// * Redistribution's of source code must retain the above copyright notice,
|
||||||
|
// this list of conditions and the following disclaimer.
|
||||||
|
//
|
||||||
|
// * Redistribution's in binary form must reproduce the above copyright notice,
|
||||||
|
// this list of conditions and the following disclaimer in the documentation
|
||||||
|
// and/or other materials provided with the distribution.
|
||||||
|
//
|
||||||
|
// * The name of the copyright holders may not be used to endorse or promote products
|
||||||
|
// derived from this software without specific prior written permission.
|
||||||
|
//
|
||||||
|
// This software is provided by the copyright holders and contributors "as is" and
|
||||||
|
// any express or implied warranties, including, but not limited to, the implied
|
||||||
|
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
||||||
|
// In no event shall the Intel Corporation or contributors be liable for any direct,
|
||||||
|
// indirect, incidental, special, exemplary, or consequential damages
|
||||||
|
// (including, but not limited to, procurement of substitute goods or services;
|
||||||
|
// loss of use, data, or profits; or business interruption) however caused
|
||||||
|
// and on any theory of liability, whether in contract, strict liability,
|
||||||
|
// or tort (including negligence or otherwise) arising in any way out of
|
||||||
|
// the use of this software, even if advised of the possibility of such damage.
|
||||||
|
//
|
||||||
|
//M*/
|
||||||
|
|
||||||
|
#ifndef __OPENCV_GPU_INTERNAL_COMMON_HPP__
|
||||||
|
#define __OPENCV_GPU_INTERNAL_COMMON_HPP__
|
||||||
|
|
||||||
|
namespace cv { namespace gpu {
|
||||||
|
|
||||||
|
// Internal GPU anlagues of CPU border extrapolation types
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
BORDER_REFLECT101 = 0,
|
||||||
|
BORDER_REPLICATE
|
||||||
|
};
|
||||||
|
|
||||||
|
}}
|
||||||
|
|
||||||
|
#endif
|
Reference in New Issue
Block a user