In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-03 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
What is the feature extraction method of opencv3 and C++HOG? in view of this problem, this article introduces the corresponding analysis and solution in detail, hoping to help more partners who want to solve this problem to find a more simple and feasible method.
HOG feature
HOG (Histograms of Oriented Gradients) gradient direction histogram
By using the gradient information to reflect the edge information of the image object and characterize the local appearance and shape of the image through the size of the local gradient, it is proposed in the paper Histograms of Oriented Gradients for Human Detection.
The process of HOG feature extraction is as follows:
Gamma normalization
Calculate the gradient
Partition cell
Combined into block, statistical block histogram
Gradient histogram normalization
Collect HOG features.
Gamma normalization:
The image color is normalized by Gamma to reduce the influence of local shadow and background factors.
Calculate the gradient:
The horizontal and vertical gradients of the image are calculated by difference.
Then the amplitude and direction of the gradient of each pixel are obtained.
Partition cell
The whole window is divided into same size and non-overlapping cell cell (such as 8 × 8 pixels), and the gradient size and direction of each cell are calculated. Then the gradient direction of each pixel is divided into 9 bins in the interval of 0 − 180o0 − 180o (undirected: 0-180o, directed: 0-360o). The pixel in each cell is weighted by amplitude, and the gradient histogram is weighted.
9bins:
As shown in the figure, the error rate under different numbers of bins:
Combined into block, statistical block histogram
2 × 2 adjacent cell are composed of 16 × 16 pixel blocks, namely block. The sliding window of block size is slid from left to right from top to bottom, and the gradient direction histogram vector is obtained.
As shown in the figure, the effect of different sizes of cell is compared with that of different sizes of block:
Gradient histogram normalization
The author compares L2-norm, L1-norm, L1-sqrt and other normalization methods, and finds that they are significantly better than non-standard data. Among them, L2-norm and L1-sqrt are the best, while L1-norm is 5% lower than L2-norm and L1-sqrt.
As shown in the figure, the effects of different normalization methods are compared:
In this way, lighting, shadows and edges can be further compressed by normalization.
Collect HOG characteristics
Since the gradient direction in each cell is divided into 9 bins, the length of the HOG eigenvector of each cell is 9. 5%.
In this way, for an image with a size of 128x64, a 16 × 16 pixel block composed of 8x8 pixel sell,2 × 2 cell and an 8 pixel block moving step are used, so that the number of detection window block is 15 × 7. The dimension of the HOG feature descriptor is 15 × 7 × 4 × 9.
Disadvantages of HOG:
Slow speed and poor real-time performance; it is difficult to deal with occlusion.
OpenCV application
There are two uses for pedestrian detection using HOG:
1. Pedestrian detection using HOG feature + SVM classifier
2. Use HOG+SVM to train your own XML files.
Using the first method, using HOG features combined with SVM classifier for pedestrian detection, a simple example:
# include # include using namespace std;using namespace cv;int main () {Mat src, dst; src = imread ("E:/image/image/passerby.jpg", 1); if (src.empty ()) {printf ("can not load the image...\ n"); return-1;} dst = src.clone (); vector findrects, findrect; HOGDescriptor HOG; / / SVM classifier HOG.setSVMDetector (HOGDescriptor::getDefaultPeopleDetector ()) / / Multi-scale detection HOG.detectMultiScale (src, findrects, 0, Size (4Power4), Size (0Let0), 1.05,2); / / if rects is nested, take the outermost rectangle and store it in rect for (int item0; I < findrects.size (); iSum +) {Rect rect = findrects [I]; int jung0; for (; j < findrects.size (); jagger +) if (j! = I & (rect & findrects [j]) = rect) break If (j = = findrects.size ()) findrect.push_back (rect);} / / frame select the test result for (int item0; I)
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.