简体   繁体   English

结合多个特征向量,HOG和LBP

[英]Combining multiple features vector, HOG and LBP

I am working on people detection using two feature descriptor, HOG and LBP. 我正在使用两个特征描述符HOG和LBP进行人员检测。 So far, I combine both of the features using a simple concatenation. 到目前为止,我已经使用简单的串联结合了这两个功能。 But it shows me sometimes problem due to big vectors. 但是它告诉我有时由于向量大而引起的问题。 Here is my code. 这是我的代码。

%extract features from negative and positive images

[HOGpos,HOGneg] = features(pathPos, pathNeg);  


% loading and labeling each training example
HOG_featV = HOGfeature(fpos,fneg);   


% get label of training data from HOG
HOGlabel  = cell2mat(HOG_featV(2,:));

% get the feature vector value from HOG
HOGfeatureVector = HOG_featV(3,:)';

C = cell2mat(HOGfeatureVector); % each row of P correspond to a training example 




%extract features from LBP
[LBPpos,LBPneg] = LBPfeatures(pathPos, pathNeg);


% loading and labeling each training example
LBP_featV = loadingV(LBPpos, LBPneg); 


% get label of training data from LBP
LBPlabel = cell2mat(LBP_featV(2,:));

% get feature vector value from LBP
LBPfeatureVector = LBP_featV(3,:);
M = cell2mat(LBPtP)'; % each row of P correspond to a training example


%concatenate HOG and LBP feature
featureVector = [C M];

I want to know, is there any method to combine two feature vector which is more reliable and faster? 我想知道,是否有任何方法可以将两个特征向量结合起来,使其更可靠,更快? If yes, please give some suggestion or link that I can refer. 如果是,请提出一些建议或链接,我可以参考。 Thank you. 谢谢。

I understood from you comments the following: You are selecting 1845 key points in the image. 我从您的评论中了解到以下几点:您正在图像中选择1845个关键点。 For each point you calculate a feature vector of length 383 (LBP+HOG combined). 对于每个点,您将计算长度为383(LBP + HOG组合)的特征向量。 The total vector that represents the image is of length ~100,000. 表示图像的总向量长度约为100,000。

If in fact you have only 1845 images and each image is represented by only 383 features than you are doomed to fail and your SVM will have a very high error rate. 如果实际上您只有1845张图像,并且每个图像仅由383个特征表示,那么您注定要失败,并且SVM的错误率将非常高。 Mainly because (the features vector is too short and the amount of training images is too small). 主要是因为(特征向量太短并且训练图像的数量太小)。 So I assume that is not the case 所以我认为情况并非如此

You have a few problems in your approach. 您的方法存在一些问题。

  1. It seems you don't understand the difference between detector and classifier, and you are trying to apply classifier to solve detection problem. 似乎您不了解检测器和分类器之间的区别,并且您正在尝试应用分类器来解决检测问题。 There is a core difference. 有一个核心区别。 Classifier is designed to distinguish between 2 (or more) classes. 分类器旨在区分2个(或更多)类。 For example is this fruit and 'apple' or an 'orange'. 例如,这种水果和“苹果”或“橙色”。 You train it by giving a lot of examples of both classes. 您将通过给出两个类的大量示例来进行培训。 But if you give a Banana to the the classifier it will will return a random! 但是,如果将香蕉提供给分类器,它将返回一个随机值! result. 结果。 It might say 'apple' with 100% confidence or an orange with 100% confidence. 它可能会说100%置信度的“苹果”或100%置信度的橙子。 Classifier cannot deal with examples (like banana) that are not within the training classes (apple, orange). 分类器无法处理不在培训课程(苹果,橙子)中的示例(例如香蕉)。 On the other hand detector doesn't have 2 classes. 另一方面,探测器没有2个类别。 It has an 'apple' and 'everything else'. 它有一个“苹果”和“其他所有东西”。 There are no examples outside of the training classes because 'apples' and 'everything else' cover the entire world. 培训课程之外没有其他示例,因为“苹果”和“其他所有东西”覆盖了整个世界。 You can not train a classifier to recognize 'everything else' because there is an infinite variety of objects that are not 'apple'. 您无法训练分类器识别“其他所有东西”,因为有无数种不是“苹果”的对象。 'Everything else' is not a class that can be trained to recognize by classifier. “其他所有东西”不是可以被分类器训练为识别的课程。 For that you need a detector. 为此,您需要一个检测器。 The training process of the detector is a bit different and the types of examples you supply are different. 检测器的训练过程有所不同,并且您提供的示例类型也有所不同。 To train a detector you have to supply a huge amount of 'non apples. 要训​​练探测器,您必须提供大量的“非苹果”。 Images of cars, human beings, chairs, airplains. 汽车,人类,椅子,飞机的图像。 Typically you need many millions of different examples of 'non apples' and only a few examples of apples (say few thousands). 通常,您需要数百万个“非苹果”的不同示例,而仅需要几个苹果示例(例如数千个)。
  2. SVM is not a good solution for detection problem. SVM不是解决检测问题的好方法。 the core idea of the SVM is that you can select few representative examples (support vector) and describe the separation between 2 classes using those representatives. SVM的核心思想是您可以选择几个代表性示例(支持向量),并使用这些代表性描述两个类之间的分离。 But let me ask you - what are the representative images of everything that is 'not an apple'? 但是,我问你-“不是苹果”的一切代表图像是什么? It is impossible to answer that question. 不可能回答这个问题。 The amount of objects that are not 'apples' is infinite so you cannot select good support vectors for them. 不是“苹果”的对象数量是无限的,因此您无法为其选择良好的支持向量。 It is easy to select representative to 'apple' (image of red apple, green apple, rotten apple, etc) but not to the 'everything else' class. 选择代表“苹果”(红色苹果,青苹果,烂苹果等)的代表很容易,但是对于“其他所有事物”类别则没有选择。 Don't get me wrong - People use SVM for detection of easy objects (like corporate logos) but when your task is difficult like people detection (you have a huge intra-class variation) - SVM is inferior. 不要误会我的意思-人们使用SVM来检测容易的对象(例如公司徽标),但是当您的任务像人们检测一样困难时(您的内部差异很大)-SVM较差。 Even if you manage to train an SVM for detection you will have 2 problems: Slow run time, high error rate on new examples (due to intra-class variation). 即使您设法训练SVM进行检测,您也会遇到两个问题:运行时间慢,新示例的错误率高(由于类内差异)。 I would suggest to use boosting methods to train a detector. 我建议使用增强方法来训练探测器。
  3. I assume you get a high error rate because the amount of images you use for training is very low. 我认为您得到的错误率很高,因为用于训练的图像数量非常少。 Your feature vector is of length ~100,000 so if you use few millions of images for training - it will take few days for the SVM to get trained. 您的特征向量的长度约为100,000,因此,如果您使用数百万个图像进行训练-支持向量机将需要几天的时间进行训练。 Remember: for 2 class - classification problems few thousands of images might be enough. 请记住:对于2类-分类问题,几千张图像可能就足够了。 But, for detection problems you need millions of images. 但是,对于检测问题,您需要数百万张图像。
  4. Your amount of features is too high (assuming it is 100,000). 您的功能数量太高(假设为100,000)。 I am betting that you have less image samples than ~100,000 length of your features vector. 我敢打赌,您的图像样本少于特征向量的〜100,000长度。 For detection problems the amount of features should be relatively low (300-3000) but each feature must be good! 对于检测问题,功能数量应该相对较低(300-3000),但是每个功能都必须好! For example you start with a list of 60,000 different features and during training process reduce the number to say 1,500 good feature and use only them for detection. 例如,您先列出了60,000种不同的功能,然后在培训过程中将数量减少为1,500种好功能,仅将其用于检测。 If you start with lower amount of features (like 383 = LBP histogram + HOG histogram) than most of the features are useless and if you do PCA you might be surprised that effectively you have only ~40 features that help the detection and the rest are useless. 如果您开始时使用的特征量较少(例如383 = LBP直方图+ HOG直方图),而大多数特征则无用,并且如果您使用PCA,您可能会惊讶地发现,只有40个有效特征可以帮助检测,其余特征无用。 On the contrary if you finish you training still requiring 100,000 features you will get crazy over-fitting wich will cause a high error rate of the SVM. 相反,如果您完成培训后仍然需要100,000个功能,那么您会发疯,过度拟合将导致SVM的错误率很高。

Practical advise: 实用建议:

  1. You can keep working with LBP/HOG features but first make sure you have a huge amount of 'non people' examples (1-10 millions) Otherwise you will have a high error rate. 您可以继续使用LBP / HOG功能,但是首先请确保您有大量的“非人”示例(1-10百万),否则您的错误率就会很高。 Try to get also few thousands images of people 尝试获取数千人的图像

  2. Train a single cascade detector. 训练单个级联检测器。 It is easier to understand, much faster and is more accurate than SVM. 与SVM相比,它更易于理解,更快,更准确。 Give the training process all possible HOG, LBP features (without histograms) and let it select the good features. 为训练过程提供所有可能的HOG,LBP特征(无直方图),并让其选择良好的特征。 There are free implementations of cascade detector training inside openCV which you can use. 您可以使用openCV中的级联检测器培训的免费实现。 My personal advise: do not use SVM for detection. 我的个人建议:请勿使用SVM进行检测。 It is a wrong tool. 这是一个错误的工具。 Once you detected a person in the image you can use SVM to classify if it is an adult or a kid but do not use SVM for detection. 一旦在图像中检测到人,就可以使用SVM对其进行分类,是成人还是孩子,但不要使用SVM进行检测。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM