remove generic version of GPU channel computer.
This commit is contained in:
parent
3c8e66d580
commit
83e7d3dd67
@ -1,52 +1,3 @@
|
||||
macro(ocv_glob_cuda_powered_module_sources)
|
||||
file(GLOB_RECURSE lib_srcs "src/*.cpp")
|
||||
file(GLOB_RECURSE lib_int_hdrs "src/*.hpp" "src/*.h")
|
||||
file(GLOB lib_hdrs "include/opencv2/${name}/*.hpp" "include/opencv2/${name}/*.h")
|
||||
file(GLOB lib_hdrs_detail "include/opencv2/${name}/detail/*.hpp" "include/opencv2/${name}/detail/*.h")
|
||||
|
||||
file(GLOB_RECURSE lib_device_srcs "src/*.cu")
|
||||
set(device_objs "")
|
||||
set(lib_device_hdrs "")
|
||||
|
||||
if (HAVE_CUDA AND lib_device_srcs)
|
||||
ocv_include_directories(${CUDA_INCLUDE_DIRS})
|
||||
file(GLOB_RECURSE lib_device_hdrs "src/cuda/*.hpp")
|
||||
|
||||
ocv_cuda_compile(device_objs ${lib_device_srcs})
|
||||
source_group("Src\\Cuda" FILES ${lib_device_srcs} ${lib_device_hdrs})
|
||||
if (lib_device_hdrs)
|
||||
list(REMOVE_ITEM lib_int_hdrs ${lib_device_hdrs})
|
||||
endif()
|
||||
endif()
|
||||
|
||||
ocv_set_module_sources(${ARGN} HEADERS ${lib_hdrs} ${lib_hdrs_detail}
|
||||
SOURCES ${lib_srcs} ${lib_int_hdrs} ${device_objs} ${lib_device_srcs} ${lib_device_hdrs})
|
||||
|
||||
source_group("Src" FILES ${lib_srcs} ${lib_int_hdrs})
|
||||
source_group("Include" FILES ${lib_hdrs})
|
||||
source_group("Include\\detail" FILES ${lib_hdrs_detail})
|
||||
endmacro()
|
||||
|
||||
set(the_description "Soft Cascade detection and training")
|
||||
ocv_warnings_disable(CMAKE_CXX_FLAGS /wd4310 -Wundef -Wmissing-declarations)
|
||||
set(cuda_deps "")
|
||||
set(cuda_include "")
|
||||
|
||||
if (NAVE_CUDA)
|
||||
set(cuda_deps ${CUDA_LIBRARIES} ${CUDA_npp_LIBRARY})
|
||||
endif()
|
||||
ocv_add_module(softcascade opencv_core opencv_imgproc opencv_ml OPTIONAL ${cuda_deps})
|
||||
|
||||
if(HAVE_CUDA)
|
||||
ocv_module_include_directories(${CUDA_INCLUDE_DIRS})
|
||||
ocv_warnings_disable(CMAKE_CXX_FLAGS -Wundef)
|
||||
else()
|
||||
ocv_module_include_directories()
|
||||
endif()
|
||||
|
||||
ocv_glob_cuda_powered_module_sources()
|
||||
ocv_create_module()
|
||||
ocv_add_precompiled_headers(${the_module})
|
||||
|
||||
ocv_add_accuracy_tests()
|
||||
ocv_add_perf_tests()
|
||||
ocv_define_module(softcascade opencv_core opencv_imgproc opencv_ml)
|
||||
ocv_warnings_disable(CMAKE_CXX_FLAGS /wd4310 -Wundef)
|
||||
|
@ -219,7 +219,7 @@ class CV_EXPORTS ChannelsProcessor
|
||||
public:
|
||||
enum
|
||||
{
|
||||
GENERIC = 1 << 4,
|
||||
// GENERIC = 1 << 4, does not supported
|
||||
SEPARABLE = 2 << 4
|
||||
};
|
||||
|
||||
@ -233,7 +233,7 @@ public:
|
||||
// Param shrinkage is a resizing factor. Resize is applied before the computing integral sum
|
||||
// Param bins is a number of HOG-like channels.
|
||||
// Param flags is a channel computing extra flags.
|
||||
static cv::Ptr<ChannelsProcessor> create(const int shrinkage, const int bins, const int flags = GENERIC);
|
||||
static cv::Ptr<ChannelsProcessor> create(const int shrinkage, const int bins, const int flags = SEPARABLE);
|
||||
|
||||
virtual ~ChannelsProcessor();
|
||||
|
||||
@ -267,7 +267,7 @@ public:
|
||||
// Param scales is a number of scales from minScale to maxScale.
|
||||
// Param flags is an extra tuning flags.
|
||||
SCascade(const double minScale = 0.4, const double maxScale = 5., const int scales = 55,
|
||||
const int flags = NO_REJECT || ChannelsProcessor::GENERIC);
|
||||
const int flags = NO_REJECT | ChannelsProcessor::SEPARABLE);
|
||||
|
||||
virtual ~SCascade();
|
||||
|
||||
|
@ -73,7 +73,7 @@ namespace
|
||||
|
||||
inline void ___cudaSafeCall(cudaError_t err, const char *file, const int line, const char *func = "")
|
||||
{
|
||||
//if (cudaSuccess != err) cv::gpu::error(cudaGetErrorString(err), file, line, func);
|
||||
if (cudaSuccess != err) cv::gpu::error(cudaGetErrorString(err), file, line, func);
|
||||
}
|
||||
}
|
||||
|
||||
@ -545,98 +545,6 @@ inline void setZero(cv::gpu::GpuMat& m, cv::gpu::Stream& s)
|
||||
m.setTo(0);
|
||||
}
|
||||
|
||||
struct GenricPreprocessor : public cv::softcascade::ChannelsProcessor
|
||||
{
|
||||
GenricPreprocessor(const int s, const int b) : cv::softcascade::ChannelsProcessor(), shrinkage(s), bins(b) {}
|
||||
virtual ~GenricPreprocessor() {}
|
||||
|
||||
virtual void apply(InputArray _frame, OutputArray _shrunk, cv::gpu::Stream& s = cv::gpu::Stream::Null())
|
||||
{
|
||||
const cv::gpu::GpuMat frame = _frame.getGpuMat();
|
||||
|
||||
_shrunk.create(frame.rows * (4 + bins) / shrinkage, frame.cols / shrinkage, CV_8UC1);
|
||||
cv::gpu::GpuMat shrunk = _shrunk.getGpuMat();
|
||||
|
||||
channels.create(frame.rows * (4 + bins), frame.cols, CV_8UC1);
|
||||
setZero(channels, s);
|
||||
|
||||
//cv::gpu::cvtColor(frame, gray, CV_BGR2GRAY, s);
|
||||
createHogBins(s);
|
||||
|
||||
createLuvBins(frame, s);
|
||||
|
||||
//cv::gpu::resize(channels, shrunk, cv::Size(), 1.f / shrinkage, 1.f / shrinkage, CV_INTER_AREA, s);
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
void createHogBins(cv::gpu::Stream& s)
|
||||
{
|
||||
static const int fw = gray.cols;
|
||||
static const int fh = gray.rows;
|
||||
|
||||
fplane.create(fh * HOG_BINS, fw, CV_32FC1);
|
||||
|
||||
cv::gpu::GpuMat dfdx(fplane, cv::Rect(0, 0, fw, fh));
|
||||
cv::gpu::GpuMat dfdy(fplane, cv::Rect(0, fh, fw, fh));
|
||||
|
||||
//cv::gpu::Sobel(gray, dfdx, CV_32F, 1, 0, sobelBuf, 3, 1, cv::BORDER_DEFAULT, -1, s);
|
||||
//cv::gpu::Sobel(gray, dfdy, CV_32F, 0, 1, sobelBuf, 3, 1, cv::BORDER_DEFAULT, -1, s);
|
||||
|
||||
cv::gpu::GpuMat mag(fplane, cv::Rect(0, 2 * fh, fw, fh));
|
||||
cv::gpu::GpuMat ang(fplane, cv::Rect(0, 3 * fh, fw, fh));
|
||||
|
||||
//cv::gpu::cartToPolar(dfdx, dfdy, mag, ang, true, s);
|
||||
|
||||
// normalize magnitude to uchar interval and angles to 6 bins
|
||||
cv::gpu::GpuMat nmag(fplane, cv::Rect(0, 4 * fh, fw, fh));
|
||||
cv::gpu::GpuMat nang(fplane, cv::Rect(0, 5 * fh, fw, fh));
|
||||
|
||||
//cv::gpu::multiply(mag, cv::Scalar::all(1.f / (8 *::log(2.0f))), nmag, 1, -1, s);
|
||||
//cv::gpu::multiply(ang, cv::Scalar::all(1.f / 60.f), nang, 1, -1, s);
|
||||
|
||||
//create uchar magnitude
|
||||
cv::gpu::GpuMat cmag(channels, cv::Rect(0, fh * HOG_BINS, fw, fh));
|
||||
if (s)
|
||||
s.enqueueConvert(nmag, cmag, CV_8UC1);
|
||||
else
|
||||
nmag.convertTo(cmag, CV_8UC1);
|
||||
|
||||
cudaStream_t stream = cv::gpu::StreamAccessor::getStream(s);
|
||||
cv::softcascade::device::fillBins(channels, nang, fw, fh, HOG_BINS, stream);
|
||||
}
|
||||
|
||||
void createLuvBins(const cv::gpu::GpuMat& colored, cv::gpu::Stream& s)
|
||||
{
|
||||
static const int fw = colored.cols;
|
||||
static const int fh = colored.rows;
|
||||
|
||||
//cv::gpu::cvtColor(colored, luv, CV_BGR2Luv, s);
|
||||
|
||||
std::vector<cv::gpu::GpuMat> splited;
|
||||
for(int i = 0; i < LUV_BINS; ++i)
|
||||
{
|
||||
splited.push_back(cv::gpu::GpuMat(channels, cv::Rect(0, fh * (7 + i), fw, fh)));
|
||||
}
|
||||
|
||||
//cv::gpu::split(luv, splited, s);
|
||||
}
|
||||
|
||||
enum {HOG_BINS = 6, LUV_BINS = 3};
|
||||
|
||||
const int shrinkage;
|
||||
const int bins;
|
||||
|
||||
cv::gpu::GpuMat gray;
|
||||
cv::gpu::GpuMat luv;
|
||||
cv::gpu::GpuMat channels;
|
||||
|
||||
// preallocated buffer for floating point operations
|
||||
cv::gpu::GpuMat fplane;
|
||||
cv::gpu::GpuMat sobelBuf;
|
||||
};
|
||||
|
||||
|
||||
struct SeparablePreprocessor : public cv::softcascade::ChannelsProcessor
|
||||
{
|
||||
SeparablePreprocessor(const int s, const int b) : cv::softcascade::ChannelsProcessor(), shrinkage(s), bins(b) {}
|
||||
@ -674,11 +582,7 @@ private:
|
||||
|
||||
cv::Ptr<cv::softcascade::ChannelsProcessor> cv::softcascade::ChannelsProcessor::create(const int s, const int b, const int m)
|
||||
{
|
||||
CV_Assert((m && SEPARABLE) || (m && GENERIC));
|
||||
|
||||
if (m && GENERIC)
|
||||
return cv::Ptr<cv::softcascade::ChannelsProcessor>(new GenricPreprocessor(s, b));
|
||||
|
||||
CV_Assert((m && SEPARABLE));
|
||||
return cv::Ptr<cv::softcascade::ChannelsProcessor>(new SeparablePreprocessor(s, b));
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user