Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8322073
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T23:15:09+00:00 2026-06-08T23:15:09+00:00

I am trying to extract features using OpenCV’s HoG API, however I can’t seem

  • 0

I am trying to extract features using OpenCV’s HoG API, however I can’t seem to find the API that allow me to do that.

What I am trying to do is to extract features using HoG from all my dataset (a set number of positive and negative images), then train my own SVM.

I peeked into HoG.cpp under OpenCV, and it didn’t help. All the codes are buried within complexities and the need to cater for different hardwares (e.g. Intel’s IPP)

My question is:

  1. Is there any API from OpenCV that I can use to extract all those features / descriptors to be fed into a SVM ? If there’s how can I use it to train my own SVM ?
  2. If there isn’t, are there any existing libraries out there, which could accomplish the same thing ?

So far, I am actually porting an existing library (http://hogprocessing.altervista.org/) from Processing (Java) to C++, but it’s still very slow, with detection taking around at least 16 seconds

Has anyone else successfully to extract HoG features, how did you go around it ? And do you have any open source codes which I could use ?

Thanks in advance

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T23:15:11+00:00Added an answer on June 8, 2026 at 11:15 pm

    You can use hog class in opencv as follows

    HOGDescriptor hog;
    vector<float> ders;
    vector<Point> locs;
    

    This function computes the hog features for you

    hog.compute(grayImg, ders, Size(32, 32), Size(0, 0), locs);
    

    The HOG features computed for grayImg are stored in ders vector to make it into a matrix, which can be used later for training.

    Mat Hogfeat(ders.size(), 1, CV_32FC1);
    
    for(int i=0;i<ders.size();i++)
        Hogfeat.at<float>(i,0)=ders.at(i);
    

    Now your HOG features are stored in Hogfeat matrix.

    You can also set the window size, cell size and block size by using object hog as follows:

    hog.blockSize = 16;
    hog.cellSize = 4;
    hog.blockStride = 8;
    
    // This is for comparing the HOG features of two images without using any SVM 
    // (It is not an efficient way but useful when you want to compare only few or two images)
    // Simple distance
    // Consider you have two HOG feature vectors for two images Hogfeat1 and Hogfeat2 and those are same size.
    
    double distance = 0;
    for(int i = 0; i < Hogfeat.rows; i++)
        distance += abs(Hogfeat.at<float>(i, 0) - Hogfeat.at<float>(i, 0));
    
    if (distance < Threshold)
        cout<<"Two images are of same class"<<endl;
    else
        cout<<"Two images are of different class"<<endl;
    

    Hope it is useful 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to extract strings from a text that features two different types of
I'm trying to extract some extra information from a location using google map api.
I'm trying to use OpenCV to extract SURF descriptors from an image. I'm using
I am trying to extract features using GLCM (gray-level co-occurrence matrix (GLCM) from image)
im trying to extract some files from a jar-file downloaded using java-webstart. below code
I am trying to extract the video id from a youtube url using the
I'm trying to write an .m file to extract energy features from an audio
im trying to extract an info hash from a torrent magnet link using perls
i am trying to extract the text abcdef from the following html using regex:
I'm trying to extract the overall comments number from a web page using Jsoup.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.