# How to use Edge Orientation histogram for object detection?

I am working on an object detection code and I chose the edge orientation histogram as a descriptor for the matching.

I am facing a problem in the back projected histogram as i don't seem to have a good matching , the back projected image is mostly white, which means that i cannot use meanshift or so for detection of the object.

here is what i've done so far:

1. Take an initial ROI (the target needed to be detected in the video stream).
2. convert ROI to grayscale
3. apply sobel operator for both x, y derivatives.
4. calculate orientation using opencv phase function (from derivative x and derivative y)
5. make a histogram of the generated orientation. with the following specs: (range : 0 to 2 PI) , (single channel) , (256 bins)
6. normalize the histogram

the code for doing these steps is the following:

Mat ROI_grad_x, ROI_grad_y , ROI_grad , ROI_gray;

cvtColor(ROI, ROI_gray, CV_BGR2GRAY);

Sobel( ROI_gray, ROI_grad_x, CV_16S, 1, 0, 3 );
Sobel( ROI_gray, ROI_grad_y, CV_16S, 0, 1, 3 );

Mat ROI_orientation_norm ;

Mat ROI_orientation_hist ;
float ROI_orientation_range[] = {0 , CV_PI};
const float *ROI_orientation_histRange[] = {ROI_orientation_range};
int ROI_orientation_histSize =256;
//calcHist( &ROI_orientation, 1, 0, Mat(), ROI_orientation_hist, 1, &ROI_orientation_histSize, &ROI_orientation_histRange , true, false);
calcHist( &ROI_orientation, 1, 0, Mat(), ROI_orientation_hist, 1, &ROI_orientation_histSize, ROI_orientation_histRange , true, false);

normalize( ROI_orientation_hist, ROI_orientation_hist, 0, 255, NORM_MINMAX, -1, Mat() );


then , and for each camera frame captured , I do the following steps:

1. convert to grayscale

2. apply sobel operator for both x derivative and y derivative.

3. compute orientation using phase opencv function (using the 2 derivatives mentioned above)

4. back project the histogram onto the orientation frame matrix to get the matches.

the code used for this part is the following :

 Mat grad_x, grad_y , grad;

Sobel( frame_gray, grad_x, CV_16S, 1, 0, 3 );
Sobel( frame_gray, grad_y, CV_16S, 0, 1, 3 );

///======================
Mat orientation_norm ;