OpenCV Q&A Forum - RSS feedhttp://answers.opencv.org/questions/OpenCV answersenCopyright <a href="http://www.opencv.org">OpenCV foundation</a>, 2012-2018.Fri, 11 Dec 2020 05:59:55 -0600Optimizations on opencv hog implementation(interp_weight, gaussian)http://answers.opencv.org/question/238824/optimizations-on-opencv-hog-implementationinterp_weight-gaussian/Hello,
I'm trying to implement hog descriptor algorithm on FPGA. I will use pure(without using any library) C++ code to synthesize design with Vivado HLS. So, i need to know what is the general formula which includes interp_weight, gaussian coefficients. The related opencl code is as follows;
int dist_center_y = dist_y - 4 * (1 - 2 * cell_y);
int idx = (dist_center_y + 8) * 16 + (dist_center_x + 8);
float gaussian = gauss_w_lut[idx];
idx = (dist_y + 8) * 16 + (dist_x + 8);
float interp_weight = gauss_w_lut[256+idx];
hist[bin.x * 48] += gaussian * interp_weight * vote.x;
hist[bin.y * 48] += gaussian * interp_weight * vote.y;
Its hard for me to read this opencl code, because i am unfamiliar to this language.
Is there any paper or guide which explaines steps of opencv hog implementation? I should create a C++ code which is fully compatible with opencv.
Necessary addition: I have already implemented my own hog algorithm by looking at explanatory links from
https://docs.opencv.org/master/d5/d33/structcv_1_1HOGDescriptor.html#details . But the output is not same as the opencv. I checked opencv source code and realized that only difference between my algorithm and opencv implementation is the code section i posted above. I'm getting best accuracy on svm with opencv hog, so i need fully same algorithm with opencv. I couldnt find any mathematical formula, i m not good at getting mathematical formula from verbal expression.Mon, 07 Dec 2020 07:00:10 -0600http://answers.opencv.org/question/238824/optimizations-on-opencv-hog-implementationinterp_weight-gaussian/Answer by sturkmen for <p>Hello,</p>
<p>I'm trying to implement hog descriptor algorithm on FPGA. I will use pure(without using any library) C++ code to synthesize design with Vivado HLS. So, i need to know what is the general formula which includes interp_weight, gaussian coefficients. The related opencl code is as follows;</p>
<pre><code>int dist_center_y = dist_y - 4 * (1 - 2 * cell_y);
int idx = (dist_center_y + 8) * 16 + (dist_center_x + 8);
float gaussian = gauss_w_lut[idx];
idx = (dist_y + 8) * 16 + (dist_x + 8);
float interp_weight = gauss_w_lut[256+idx];
hist[bin.x * 48] += gaussian * interp_weight * vote.x;
hist[bin.y * 48] += gaussian * interp_weight * vote.y;
</code></pre>
<p>Its hard for me to read this opencl code, because i am unfamiliar to this language.</p>
<p>Is there any paper or guide which explaines steps of opencv hog implementation? I should create a C++ code which is fully compatible with opencv.</p>
<p>Necessary addition: I have already implemented my own hog algorithm by looking at explanatory links from
<a href="https://docs.opencv.org/master/d5/d33/structcv_1_1HOGDescriptor.html#details">https://docs.opencv.org/master/d5/d33...</a> . But the output is not same as the opencv. I checked opencv source code and realized that only difference between my algorithm and opencv implementation is the code section i posted above. I'm getting best accuracy on svm with opencv hog, so i need fully same algorithm with opencv. I couldnt find any mathematical formula, i m not good at getting mathematical formula from verbal expression.</p>
http://answers.opencv.org/question/238824/optimizations-on-opencv-hog-implementationinterp_weight-gaussian/?answer=239073#post-id-239073you can also take a look at http://blog.dlib.net/2014/02/dlib-186-released-make-your-own-object.html
do you have a dataset you already trained a detector?
you can train with both OpenCV and Dlib and compare resultsFri, 11 Dec 2020 05:59:55 -0600http://answers.opencv.org/question/238824/optimizations-on-opencv-hog-implementationinterp_weight-gaussian/?answer=239073#post-id-239073Answer by crackwitz for <p>Hello,</p>
<p>I'm trying to implement hog descriptor algorithm on FPGA. I will use pure(without using any library) C++ code to synthesize design with Vivado HLS. So, i need to know what is the general formula which includes interp_weight, gaussian coefficients. The related opencl code is as follows;</p>
<pre><code>int dist_center_y = dist_y - 4 * (1 - 2 * cell_y);
int idx = (dist_center_y + 8) * 16 + (dist_center_x + 8);
float gaussian = gauss_w_lut[idx];
idx = (dist_y + 8) * 16 + (dist_x + 8);
float interp_weight = gauss_w_lut[256+idx];
hist[bin.x * 48] += gaussian * interp_weight * vote.x;
hist[bin.y * 48] += gaussian * interp_weight * vote.y;
</code></pre>
<p>Its hard for me to read this opencl code, because i am unfamiliar to this language.</p>
<p>Is there any paper or guide which explaines steps of opencv hog implementation? I should create a C++ code which is fully compatible with opencv.</p>
<p>Necessary addition: I have already implemented my own hog algorithm by looking at explanatory links from
<a href="https://docs.opencv.org/master/d5/d33/structcv_1_1HOGDescriptor.html#details">https://docs.opencv.org/master/d5/d33...</a> . But the output is not same as the opencv. I checked opencv source code and realized that only difference between my algorithm and opencv implementation is the code section i posted above. I'm getting best accuracy on svm with opencv hog, so i need fully same algorithm with opencv. I couldnt find any mathematical formula, i m not good at getting mathematical formula from verbal expression.</p>
http://answers.opencv.org/question/238824/optimizations-on-opencv-hog-implementationinterp_weight-gaussian/?answer=238840#post-id-238840I would suggest that you find the original scientific paper that describes the Histogram of Oriented Gradients
the wikipedia article is a bearable starting point https://en.wikipedia.org/wiki/Histogram_of_oriented_gradientsMon, 07 Dec 2020 12:59:15 -0600http://answers.opencv.org/question/238824/optimizations-on-opencv-hog-implementationinterp_weight-gaussian/?answer=238840#post-id-238840Comment by Alican Özeloğlu for <p>I would suggest that you find the original scientific paper that describes the Histogram of Oriented Gradients</p>
<p>the wikipedia article is a bearable starting point <a href="https://en.wikipedia.org/wiki/Histogram_of_oriented_gradients">https://en.wikipedia.org/wiki/Histogr...</a></p>
http://answers.opencv.org/question/238824/optimizations-on-opencv-hog-implementationinterp_weight-gaussian/?comment=238878#post-id-238878Thank you for your suggestion.Tue, 08 Dec 2020 00:31:40 -0600http://answers.opencv.org/question/238824/optimizations-on-opencv-hog-implementationinterp_weight-gaussian/?comment=238878#post-id-238878Answer by berak for <p>Hello,</p>
<p>I'm trying to implement hog descriptor algorithm on FPGA. I will use pure(without using any library) C++ code to synthesize design with Vivado HLS. So, i need to know what is the general formula which includes interp_weight, gaussian coefficients. The related opencl code is as follows;</p>
<pre><code>int dist_center_y = dist_y - 4 * (1 - 2 * cell_y);
int idx = (dist_center_y + 8) * 16 + (dist_center_x + 8);
float gaussian = gauss_w_lut[idx];
idx = (dist_y + 8) * 16 + (dist_x + 8);
float interp_weight = gauss_w_lut[256+idx];
hist[bin.x * 48] += gaussian * interp_weight * vote.x;
hist[bin.y * 48] += gaussian * interp_weight * vote.y;
</code></pre>
<p>Its hard for me to read this opencl code, because i am unfamiliar to this language.</p>
<p>Is there any paper or guide which explaines steps of opencv hog implementation? I should create a C++ code which is fully compatible with opencv.</p>
<p>Necessary addition: I have already implemented my own hog algorithm by looking at explanatory links from
<a href="https://docs.opencv.org/master/d5/d33/structcv_1_1HOGDescriptor.html#details">https://docs.opencv.org/master/d5/d33...</a> . But the output is not same as the opencv. I checked opencv source code and realized that only difference between my algorithm and opencv implementation is the code section i posted above. I'm getting best accuracy on svm with opencv hog, so i need fully same algorithm with opencv. I couldnt find any mathematical formula, i m not good at getting mathematical formula from verbal expression.</p>
http://answers.opencv.org/question/238824/optimizations-on-opencv-hog-implementationinterp_weight-gaussian/?answer=238829#post-id-238829looking at optimized opencl code, when trying to understand an algorithm is always a bad idea ...
rather [read the official docs](https://docs.opencv.org/master/d5/d33/structcv_1_1HOGDescriptor.html#details), there are a lot of explanatory links !Mon, 07 Dec 2020 08:12:06 -0600http://answers.opencv.org/question/238824/optimizations-on-opencv-hog-implementationinterp_weight-gaussian/?answer=238829#post-id-238829Comment by Alican Özeloğlu for <p>looking at optimized opencl code, when trying to understand an algorithm is always a bad idea ...</p>
<p>rather <a href="https://docs.opencv.org/master/d5/d33/structcv_1_1HOGDescriptor.html#details">read the official docs</a>, there are a lot of explanatory links !</p>
http://answers.opencv.org/question/238824/optimizations-on-opencv-hog-implementationinterp_weight-gaussian/?comment=238880#post-id-238880Thank you for your answer. I have already read this articles but couldnt build an algorithm which produces output exact same with opencv.Tue, 08 Dec 2020 00:35:41 -0600http://answers.opencv.org/question/238824/optimizations-on-opencv-hog-implementationinterp_weight-gaussian/?comment=238880#post-id-238880