I am trying to combine LBP-HOG for object detection. This is actually a part of model free object tracker. I have extracted both features and fed them in to a Linear SVM. here is the code.
svm = trainSVM( pos{j},neg{j} ); // for LBP features where pos{j} and neg{j} are mxn matrix.
svmHog=trainSVM( posHog{j},negHog{j} ); // for HOG features. i used VLFEAT for both LBP and HOG
The SVM light library was used for the purpose of training.
I have used firstly the LBP feature for classification of window using Sliding window approach with the stride of 4.
The top 100 predicted labels were then fed into HOG classifier. but the result i obtained stayed on top always like 44x1, 87x1, 202x1. Am i missin something? My code for detection follows:
function detect(im,model,modelHog,wSize)
%{
this function will take three parameters
1. im --> Test Image
2. model --> trained model
3. wStize --> Size of the window, i.e. [24,32]
and draw rectangle on best estimated window
%}
topLeftRow = 1;
topLeftCol = 1;
[bottomRightCol bottomRightRow d] = size(im);
fcount = 1;
% this for loop scan the entire image and extract features for each sliding window
for y = topLeftCol:3:bottomRightCol-wSize(2)
for x = topLeftRow:3:bottomRightRow-wSize(1)
p1 = [x,y];
p2 = [x+(wSize(1)-1), y+(wSize(2)-1)];
po = [p1; p2];
img = imcut(po,im);
hog= vl_hog(single(img),8);
hog = hog(:,:,1:9) ; % + hog(:,:,10:18);
lbp= vl_lbp(single(img),16);
%lbp = lbp(:,:,1:9)+ lbp(:,:,10:18);
featureVector{fcount} = lbp; %cat(3,lbp,hog); %HOG(double(img));
featureVector{fcount}=featureVector{fcount}(:)';
featureVector{fcount}=transpose(featureVector{fcount});
featureVectorHOG{fcount} = hog; %cat(3,lbp,hog); %HOG(double(img));
featureVectorHOG{fcount}=featureVectorHOG{fcount}(:)';
featureVectorHOG{fcount}=transpose(featureVectorHOG{fcount});
boxPoint{fcount} = [x,y];
fcount = fcount+1;
x = x+1;
end
end
lebel = ones(length(featureVector),1);
P = double(cell2mat(featureVector));
% each row of P' correspond to a window
[~, predictions] = svmclassify(P',lebel,model); % classifying each window
[sortedValues,sortIndex] = sort(predictions(:),'descend');
for j=1:100%length(sortedValues)
bBox{j} = cell2mat(boxPoint(sortIndex(j)));
fVectorHOG{j}=featureVectorHOG{sortIndex(j)};
end
lebel = ones(length(fVectorHOG),1);
P = double(cell2mat(fVectorHOG));
[~, predictions] = svmclassify(P',lebel,modelHog); % classifying each window
[a, indx]= max(predictions);
bBox = cell2mat(boxPoint(indx));
rectangle('Position',[bBox(1),bBox(2),24,32],'LineWidth',1, 'EdgeColor','r');
end