|
|
@ -183,13 +183,47 @@ struct cv::gpu::SoftCascade::Filds |
|
|
|
{ |
|
|
|
{ |
|
|
|
cudaMemset(plane.data, 0, plane.step * plane.rows); |
|
|
|
cudaMemset(plane.data, 0, plane.step * plane.rows); |
|
|
|
|
|
|
|
|
|
|
|
int fw = Filds::FRAME_WIDTH; |
|
|
|
static const int fw = Filds::FRAME_WIDTH; |
|
|
|
int fh = Filds::FRAME_HEIGHT; |
|
|
|
static const int fh = Filds::FRAME_HEIGHT; |
|
|
|
|
|
|
|
|
|
|
|
GpuMat gray(plane, cv::Rect(0, fh * Filds::HOG_LUV_BINS, fw, fh)); |
|
|
|
GpuMat gray(plane, cv::Rect(0, fh * Filds::HOG_LUV_BINS, fw, fh)); |
|
|
|
cv::gpu::cvtColor(colored, gray, CV_BGR2GRAY); |
|
|
|
cv::gpu::cvtColor(colored, gray, CV_BGR2GRAY); |
|
|
|
|
|
|
|
createHogBins(gray); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
createLuvBins(colored); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
integrate(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private: |
|
|
|
|
|
|
|
void calcLevels(const std::vector<device::icf::Octave>& octs, |
|
|
|
|
|
|
|
int frameW, int frameH, int nscales); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
typedef std::vector<device::icf::Octave>::const_iterator octIt_t; |
|
|
|
|
|
|
|
int fitOctave(const std::vector<device::icf::Octave>& octs, const float& logFactor) const |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
float minAbsLog = FLT_MAX; |
|
|
|
|
|
|
|
int res = 0; |
|
|
|
|
|
|
|
for (int oct = 0; oct < (int)octs.size(); ++oct) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
const device::icf::Octave& octave =octs[oct]; |
|
|
|
|
|
|
|
float logOctave = ::log(octave.scale); |
|
|
|
|
|
|
|
float logAbsScale = ::fabs(logFactor - logOctave); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(logAbsScale < minAbsLog) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
res = oct; |
|
|
|
|
|
|
|
minAbsLog = logAbsScale; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return res; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void createHogBins(const cv::gpu::GpuMat& gray) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
static const int fw = Filds::FRAME_WIDTH; |
|
|
|
|
|
|
|
static const int fh = Filds::FRAME_HEIGHT; |
|
|
|
|
|
|
|
|
|
|
|
//create hog
|
|
|
|
|
|
|
|
GpuMat dfdx(fplane, cv::Rect(0, 0, fw, fh)); |
|
|
|
GpuMat dfdx(fplane, cv::Rect(0, 0, fw, fh)); |
|
|
|
GpuMat dfdy(fplane, cv::Rect(0, fh, fw, fh)); |
|
|
|
GpuMat dfdy(fplane, cv::Rect(0, fh, fw, fh)); |
|
|
|
|
|
|
|
|
|
|
@ -213,7 +247,14 @@ struct cv::gpu::SoftCascade::Filds |
|
|
|
GpuMat cmag(plane, cv::Rect(0, fh * Filds::HOG_BINS, fw, fh)); |
|
|
|
GpuMat cmag(plane, cv::Rect(0, fh * Filds::HOG_BINS, fw, fh)); |
|
|
|
nmag.convertTo(cmag, CV_8UC1); |
|
|
|
nmag.convertTo(cmag, CV_8UC1); |
|
|
|
|
|
|
|
|
|
|
|
// create luv
|
|
|
|
device::icf::fillBins(plane, nang, fw, fh, Filds::HOG_BINS); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void createLuvBins(const cv::gpu::GpuMat& colored) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
static const int fw = Filds::FRAME_WIDTH; |
|
|
|
|
|
|
|
static const int fh = Filds::FRAME_HEIGHT; |
|
|
|
|
|
|
|
|
|
|
|
cv::gpu::cvtColor(colored, luv, CV_BGR2Luv); |
|
|
|
cv::gpu::cvtColor(colored, luv, CV_BGR2Luv); |
|
|
|
|
|
|
|
|
|
|
|
std::vector<GpuMat> splited; |
|
|
|
std::vector<GpuMat> splited; |
|
|
@ -223,8 +264,12 @@ struct cv::gpu::SoftCascade::Filds |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
cv::gpu::split(luv, splited); |
|
|
|
cv::gpu::split(luv, splited); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
device::icf::fillBins(plane, nang, fw, fh, Filds::HOG_BINS); |
|
|
|
void integrate() |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
int fw = Filds::FRAME_WIDTH; |
|
|
|
|
|
|
|
int fh = Filds::FRAME_HEIGHT; |
|
|
|
|
|
|
|
|
|
|
|
GpuMat channels(plane, cv::Rect(0, 0, fw, fh * Filds::HOG_LUV_BINS)); |
|
|
|
GpuMat channels(plane, cv::Rect(0, 0, fw, fh * Filds::HOG_LUV_BINS)); |
|
|
|
cv::gpu::resize(channels, shrunk, cv::Size(), 0.25, 0.25, CV_INTER_AREA); |
|
|
|
cv::gpu::resize(channels, shrunk, cv::Size(), 0.25, 0.25, CV_INTER_AREA); |
|
|
@ -239,30 +284,6 @@ struct cv::gpu::SoftCascade::Filds |
|
|
|
cv::gpu::integralBuffered(channel, sum, integralBuffer); |
|
|
|
cv::gpu::integralBuffered(channel, sum, integralBuffer); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private: |
|
|
|
|
|
|
|
void calcLevels(const std::vector<device::icf::Octave>& octs, |
|
|
|
|
|
|
|
int frameW, int frameH, int nscales); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
typedef std::vector<device::icf::Octave>::const_iterator octIt_t; |
|
|
|
|
|
|
|
int fitOctave(const std::vector<device::icf::Octave>& octs, const float& logFactor) const |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
float minAbsLog = FLT_MAX; |
|
|
|
|
|
|
|
int res = 0; |
|
|
|
|
|
|
|
for (int oct = 0; oct < (int)octs.size(); ++oct) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
const device::icf::Octave& octave =octs[oct]; |
|
|
|
|
|
|
|
float logOctave = ::log(octave.scale); |
|
|
|
|
|
|
|
float logAbsScale = ::fabs(logFactor - logOctave); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(logAbsScale < minAbsLog) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
res = oct; |
|
|
|
|
|
|
|
minAbsLog = logAbsScale; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return res; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
bool cv::gpu::SoftCascade::Filds::fill(const FileNode &root, const float mins, const float maxs) |
|
|
|
bool cv::gpu::SoftCascade::Filds::fill(const FileNode &root, const float mins, const float maxs) |
|
|
@ -572,5 +593,4 @@ cv::Size cv::gpu::SoftCascade::getRoiSize() const |
|
|
|
return cv::Size(Filds::FRAME_WIDTH / 4, Filds::FRAME_HEIGHT / 4); |
|
|
|
return cv::Size(Filds::FRAME_WIDTH / 4, Filds::FRAME_HEIGHT / 4); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endif |
|
|
|
#endif |