Opencv:通过FAST关键点和简要功能训练SVM [英] Opencv: Train SVM with FAST keypoints and BRIEF features

查看:125
本文介绍了Opencv:通过FAST关键点和简要功能训练SVM的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想训练一个SVM进行对象检测.至此,我有了一个python脚本,该脚本可检测FAST关键点并提取该位置的Brief功能.

I want to train a SVM for object detection. At this point I have a python script which detects FAST keypoints and extracts BRIEF features at that location.

现在,我不知道如何使用这些描述符来训练SVM.

Now I don't know how to use these descriptors to train a SVM.

你能告诉我吗?

  1. 如何使用描述符来训练SVM(据我所知,这些描述符应该是我的训练数据)?

  1. How to use the descriptors to train the SVM (As far as I know these descriptors should be my train data)?

标签的用途是什么?如何获得标签?

What are labels used for and how I can get them?

推荐答案

要训练SVM,您需要具有特征的矩阵X和具有标签的向量y.对于3张图片和两个功能,它看起来应该像这样:

To train a SVM you would need a matrix X with your features and a vector y with your labels. It should look like this for 3 images and two features:

>>> from sklearn import svm
>>> X = [[0, 0],   <- negative 0
         [1, 3],   <- positive 1
          2, 5]]   <- negative 0
>>> y = [0,   
         1,
         0]
>>> model = svm.SVC()
>>> model.fit(X, y) 

训练集将由几张图像组成,每个图像将是一行Xy.

The training set would consist of several images, each image would be a row of X and y.

对于标签y,您需要正例和负例(0或1):

For the labels y you need positive and negative examples (0 or 1):

正样本

您可以通过两种方式指定阳性样本.一种方法是指定 较大图像中的矩形区域.区域包含对象 出于兴趣.另一种方法是裁剪感兴趣的对象 从图像中保存,并将其另存为单独的图像.然后,您可以指定 该区域是整个图像.您还可以产生更多积极的影响 通过增加旋转或噪声或通过改变来从现有样本中采样 亮度或对比度.

You can specify positive samples in two ways. One way is to specify rectangular regions in a larger image. The regions contain the objects of interest. The other approach is to crop out the object of interest from the image and save it as a separate image. Then, you can specify the region to be the entire image. You can also generate more positive samples from existing ones by adding rotation or noise, or by varying brightness or contrast.

阴性样品

不包含感兴趣对象的图像.

Images that do not contain objects of interest.

["从此处略作编辑]

特征矩阵X:

在这里您可以发挥创造力,但我会提到一个简单的想法.设置height * width功能,每个图像的每个像素一个,但是除了在FAST关键点附近的一小部分之外,将它们全部设置为0.最后,您的X矩阵将具有维度(n_imagesheight*width).

Feature matrix X:

Here you can get creative but I will mention a simple idea. Make height * width features, one for each pixel of each image, but make them all 0 except in a small region around the FAST keypoints. In the end your X matrix will have dimension (n_images, height*width).

另一个常用的想法是言语之袋". X矩阵必须具有固定数量的要素/列,并且关键点的数量是可变的.这是一个表示问题,但是可以解决,将它们合并到具有固定数量的bin的直方图中.有关详细信息,请参见例如本文.

Another commonly used idea is Bag of Words. The X matrix must have a fixed number of features/columns and the number of keypoints is variable. This is a representation problem but it can be solved binning them in a histogram with a fixed number of bins. For details see for example this paper.

您将不得不咨询专业文献,以提出更多的方法来结合摘要"功能,但是我希望这会给您一个入门的思路.

You will have to consult the specialized literature to come up with more ways to incorporate the BRIEF features but I hope this will give you an idea on how to get started.

这篇关于Opencv:通过FAST关键点和简要功能训练SVM的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆