mirror of
https://github.com/opencv/opencv.git
synced 2026-07-29 23:33:05 +04:00
added getDescriptors support into gpu HOG, also added commented test for this feature
This commit is contained in:
+23
-33
@@ -51,8 +51,10 @@ double cv::gpu::HOGDescriptor::getWinSigma() const { throw_nogpu(); return 0; }
|
||||
bool cv::gpu::HOGDescriptor::checkDetectorSize() const { throw_nogpu(); return false; }
|
||||
void cv::gpu::HOGDescriptor::setSVMDetector(const vector<float>&) { throw_nogpu(); }
|
||||
void cv::gpu::HOGDescriptor::computeGradient(const GpuMat&, GpuMat&, GpuMat&) { throw_nogpu(); }
|
||||
void cv::gpu::HOGDescriptor::computeBlockHistograms(const GpuMat&) { throw_nogpu(); }
|
||||
void cv::gpu::HOGDescriptor::detect(const GpuMat&, vector<Point>&, double, Size, Size) { throw_nogpu(); }
|
||||
void cv::gpu::HOGDescriptor::detectMultiScale(const GpuMat&, vector<Rect>&, double, Size, Size, double, int) { throw_nogpu(); }
|
||||
void cv::gpu::HOGDescriptor::getDescriptors(const GpuMat&, Size, GpuMat&) { throw_nogpu(); }
|
||||
std::vector<float> cv::gpu::HOGDescriptor::getDefaultPeopleDetector() { throw_nogpu(); return std::vector<float>(); }
|
||||
std::vector<float> cv::gpu::HOGDescriptor::getPeopleDetector_48x96() { throw_nogpu(); return std::vector<float>(); }
|
||||
std::vector<float> cv::gpu::HOGDescriptor::getPeopleDetector_64x128() { throw_nogpu(); return std::vector<float>(); }
|
||||
@@ -76,6 +78,10 @@ void classify_hists(int win_height, int win_width, int block_stride_y,
|
||||
int width, float* block_hists, float* coefs, float free_coef,
|
||||
float threshold, unsigned char* labels);
|
||||
|
||||
void extract_descriptors(int win_height, int win_width, int block_stride_y, int block_stride_x,
|
||||
int win_stride_y, int win_stride_x, int height, int width, float* block_hists,
|
||||
cv::gpu::DevMem2Df descriptors);
|
||||
|
||||
void compute_gradients_8UC1(int nbins, int height, int width, const cv::gpu::DevMem2D& img,
|
||||
float angle_scale, cv::gpu::DevMem2Df grad, cv::gpu::DevMem2D qangle);
|
||||
void compute_gradients_8UC4(int nbins, int height, int width, const cv::gpu::DevMem2D& img,
|
||||
@@ -212,39 +218,23 @@ void cv::gpu::HOGDescriptor::computeBlockHistograms(const GpuMat& img)
|
||||
}
|
||||
|
||||
|
||||
////TODO: test it
|
||||
//void cv::gpu::HOGDescriptor::getDescriptors(const GpuMat& img, Size win_stride,
|
||||
// vector<GpuMat>& descriptors)
|
||||
//{
|
||||
// CV_Assert(win_stride.width % block_stride.width == 0 &&
|
||||
// win_stride.height % block_stride.height == 0);
|
||||
//
|
||||
// computeBlockHistograms(img);
|
||||
//
|
||||
// Size blocks_per_img = numPartsWithin(img.size(), block_size, block_stride);
|
||||
// GpuMat hists_reshaped = block_hists.reshape(0, blocks_per_img.height);
|
||||
//
|
||||
// const int block_hist_size = getBlockHistogramSize();
|
||||
// Size blocks_per_win = numPartsWithin(win_size, block_size, block_stride);
|
||||
// Size wins_per_img = numPartsWithin(img.size(), win_size, win_stride);
|
||||
//
|
||||
// descriptors.resize(wins_per_img.area());
|
||||
// for (int i = 0; i < wins_per_img.height; ++i)
|
||||
// {
|
||||
// for (int j = 0; j < wins_per_img.width; ++j)
|
||||
// {
|
||||
// Range rows;
|
||||
// rows.start = i * (blocks_per_win.height + 1);
|
||||
// rows.end = rows.start + blocks_per_win.height;
|
||||
//
|
||||
// Range cols;
|
||||
// cols.start = j * (blocks_per_win.width + 1) * block_hist_size;
|
||||
// cols.end = cols.start + blocks_per_win.width * block_hist_size;
|
||||
//
|
||||
// descriptors[i * wins_per_img.width + j] = hists_reshaped(rows, cols);
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
void cv::gpu::HOGDescriptor::getDescriptors(const GpuMat& img, Size win_stride, GpuMat& descriptors)
|
||||
{
|
||||
CV_Assert(win_stride.width % block_stride.width == 0 &&
|
||||
win_stride.height % block_stride.height == 0);
|
||||
|
||||
computeBlockHistograms(img);
|
||||
|
||||
const int block_hist_size = getBlockHistogramSize();
|
||||
Size blocks_per_win = numPartsWithin(win_size, block_size, block_stride);
|
||||
Size wins_per_img = numPartsWithin(img.size(), win_size, win_stride);
|
||||
|
||||
descriptors.create(wins_per_img.area(), blocks_per_win.area() * block_hist_size, CV_32F);
|
||||
|
||||
hog::extract_descriptors(win_size.height, win_size.width, block_stride.height, block_stride.width,
|
||||
win_stride.height, win_stride.width, img.rows, img.cols, block_hists.ptr<float>(),
|
||||
descriptors);
|
||||
}
|
||||
|
||||
|
||||
void cv::gpu::HOGDescriptor::detect(const GpuMat& img, vector<Point>& hits, double hit_threshold,
|
||||
|
||||
Reference in New Issue
Block a user