fixed big in gpu::HOGDescriptor, added property into CPU's HOGDescriptor
This commit is contained in:
parent
e954577304
commit
cc6a87fc9d
@ -446,7 +446,7 @@ __global__ void compute_gradients_8UC4_kernel(int height, int width, const PtrEl
|
|||||||
|
|
||||||
if (threadIdx.x == 0)
|
if (threadIdx.x == 0)
|
||||||
{
|
{
|
||||||
val = x > 0 ? row[x - 1] : row[x + 1];
|
val = x > 0 ? row[x - 1] : row[1];
|
||||||
sh_row[0] = val.x;
|
sh_row[0] = val.x;
|
||||||
sh_row[(nthreads + 2)] = val.y;
|
sh_row[(nthreads + 2)] = val.y;
|
||||||
sh_row[2 * (nthreads + 2)] = val.z;
|
sh_row[2 * (nthreads + 2)] = val.z;
|
||||||
@ -454,7 +454,7 @@ __global__ void compute_gradients_8UC4_kernel(int height, int width, const PtrEl
|
|||||||
|
|
||||||
if (threadIdx.x == blockDim.x - 1)
|
if (threadIdx.x == blockDim.x - 1)
|
||||||
{
|
{
|
||||||
val = (x < width - 1) ? row[x + 1] : row[x - 1];
|
val = (x < width - 1) ? row[x + 1] : row[width - 2];
|
||||||
sh_row[blockDim.x + 1] = val.x;
|
sh_row[blockDim.x + 1] = val.x;
|
||||||
sh_row[blockDim.x + 1 + (nthreads + 2)] = val.y;
|
sh_row[blockDim.x + 1 + (nthreads + 2)] = val.y;
|
||||||
sh_row[blockDim.x + 1 + 2 * (nthreads + 2)] = val.z;
|
sh_row[blockDim.x + 1 + 2 * (nthreads + 2)] = val.z;
|
||||||
@ -553,10 +553,10 @@ __global__ void compute_gradients_8UC1_kernel(int height, int width, const PtrEl
|
|||||||
sh_row[threadIdx.x + 1] = row[x - 2];
|
sh_row[threadIdx.x + 1] = row[x - 2];
|
||||||
|
|
||||||
if (threadIdx.x == 0)
|
if (threadIdx.x == 0)
|
||||||
sh_row[0] = x > 0 ? row[x - 1] : row[x + 1];
|
sh_row[0] = x > 0 ? row[x - 1] : row[1];
|
||||||
|
|
||||||
if (threadIdx.x == blockDim.x - 1)
|
if (threadIdx.x == blockDim.x - 1)
|
||||||
sh_row[blockDim.x + 1] = (x < width - 1) ? row[x + 1] : row[x - 1];
|
sh_row[blockDim.x + 1] = (x < width - 1) ? row[x + 1] : row[width - 2];
|
||||||
|
|
||||||
__syncthreads();
|
__syncthreads();
|
||||||
if (x < width)
|
if (x < width)
|
||||||
|
@ -360,20 +360,22 @@ struct CV_EXPORTS_W HOGDescriptor
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
enum { L2Hys=0 };
|
enum { L2Hys=0 };
|
||||||
|
enum { DEFAULT_NLEVELS=64 };
|
||||||
|
|
||||||
CV_WRAP HOGDescriptor() : winSize(64,128), blockSize(16,16), blockStride(8,8),
|
CV_WRAP HOGDescriptor() : winSize(64,128), blockSize(16,16), blockStride(8,8),
|
||||||
cellSize(8,8), nbins(9), derivAperture(1), winSigma(-1),
|
cellSize(8,8), nbins(9), derivAperture(1), winSigma(-1),
|
||||||
histogramNormType(HOGDescriptor::L2Hys), L2HysThreshold(0.2), gammaCorrection(true)
|
histogramNormType(HOGDescriptor::L2Hys), L2HysThreshold(0.2), gammaCorrection(true),
|
||||||
|
nlevels(DEFAULT_NLEVELS)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
CV_WRAP HOGDescriptor(Size _winSize, Size _blockSize, Size _blockStride,
|
CV_WRAP HOGDescriptor(Size _winSize, Size _blockSize, Size _blockStride,
|
||||||
Size _cellSize, int _nbins, int _derivAperture=1, double _winSigma=-1,
|
Size _cellSize, int _nbins, int _derivAperture=1, double _winSigma=-1,
|
||||||
int _histogramNormType=HOGDescriptor::L2Hys,
|
int _histogramNormType=HOGDescriptor::L2Hys,
|
||||||
double _L2HysThreshold=0.2, bool _gammaCorrection=false)
|
double _L2HysThreshold=0.2, bool _gammaCorrection=false, int _nlevels=DEFAULT_NLEVELS)
|
||||||
: winSize(_winSize), blockSize(_blockSize), blockStride(_blockStride), cellSize(_cellSize),
|
: winSize(_winSize), blockSize(_blockSize), blockStride(_blockStride), cellSize(_cellSize),
|
||||||
nbins(_nbins), derivAperture(_derivAperture), winSigma(_winSigma),
|
nbins(_nbins), derivAperture(_derivAperture), winSigma(_winSigma),
|
||||||
histogramNormType(_histogramNormType), L2HysThreshold(_L2HysThreshold),
|
histogramNormType(_histogramNormType), L2HysThreshold(_L2HysThreshold),
|
||||||
gammaCorrection(_gammaCorrection)
|
gammaCorrection(_gammaCorrection), nlevels(_nlevels)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
CV_WRAP HOGDescriptor(const String& filename)
|
CV_WRAP HOGDescriptor(const String& filename)
|
||||||
@ -429,6 +431,7 @@ public:
|
|||||||
CV_PROP double L2HysThreshold;
|
CV_PROP double L2HysThreshold;
|
||||||
CV_PROP bool gammaCorrection;
|
CV_PROP bool gammaCorrection;
|
||||||
CV_PROP vector<float> svmDetector;
|
CV_PROP vector<float> svmDetector;
|
||||||
|
CV_PROP int nlevels;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -872,11 +872,10 @@ void HOGDescriptor::detectMultiScale(
|
|||||||
double scale0, int groupThreshold) const
|
double scale0, int groupThreshold) const
|
||||||
{
|
{
|
||||||
double scale = 1.;
|
double scale = 1.;
|
||||||
const int maxLevels = 64;
|
|
||||||
int levels = 0;
|
int levels = 0;
|
||||||
|
|
||||||
vector<double> levelScale;
|
vector<double> levelScale;
|
||||||
for( levels = 0; levels < maxLevels; levels++ )
|
for( levels = 0; levels < nlevels; levels++ )
|
||||||
{
|
{
|
||||||
levelScale.push_back(scale);
|
levelScale.push_back(scale);
|
||||||
if( cvRound(img.cols/scale) < winSize.width ||
|
if( cvRound(img.cols/scale) < winSize.width ||
|
||||||
|
Loading…
x
Reference in New Issue
Block a user