vector<float> HOGDetectorGPU::getHOGdescriptors(cv::HOGDescriptor& hog, Mat& image){
    resize(image, image, Size(WIN_X,WIN_Y) );
    Mat img;
    cvtColor(image, img, CV_RGB2GRAY);
    hog.winSize.height = WIN_X;
    hog.winSize.width = WIN_Y;
    // Size(128,64), //winSize
    // Size(16,16), //blocksize
    // Size(8,8), //blockStride,
    // Size(8,8), //cellSize,
    // 9, //nbins,
    // 0, //derivAper,
    // -1, //winSigma,
    // 0, //histogramNormType,
    // 0.2, //L2HysThresh,
    // 0 //gammal correction,
    // //nlevels=64
    //);
    vector<float> descriptorsValues;
    vector<Point> locations;
    hog.compute( img, descriptorsValues, Size(0,0), Size(0,0), locations);
    cout << "HOG descriptor size is " << hog.getDescriptorSize() << endl;
    cout << "img dimensions: " << img.cols << " width x " << img.rows << "height" << endl;
    cout << "Found " << descriptorsValues.size() << " descriptor values" << endl;
    cout << "Nr of locations specified : " << locations.size() << endl;
    return descriptorsValues;

}
Exemplo n.º 2
0
static void calculateFeaturesFromInput( cv::Mat imageData, std::vector< float >& featureVector, cv::HOGDescriptor& hog )
{
	std::vector< cv::Point > locations;
	hog.compute( imageData, featureVector, winStride, trainingPadding, locations );

	imageData.release();
}
Exemplo n.º 3
0
cv::Mat computeHOG(const cv::Mat &img_gray, cv::HOGDescriptor &d) {
  int correct_width = img_gray.cols - (img_gray.cols - d.blockSize.width) % d.blockStride.width;
  int correct_height = img_gray.rows - (img_gray.rows - d.blockSize.height) % d.blockStride.height;
  d.winSize = cv::Size(correct_width, correct_height);

  //Scale input image to the correct size
  cv::Mat resize_img;
  cv::resize(img_gray, resize_img, d.winSize);

  std::vector<float> descriptorsValues;
  std::vector<cv::Point> locations;
  d.compute(resize_img, descriptorsValues, cv::Size(0,0), cv::Size(0,0), locations);

  cv::Mat matDescriptorsValues(descriptorsValues, true);
  return matDescriptorsValues;
}