How to train OpenCV SVM with BoW Properly

后端 未结 1 1298
抹茶落季
抹茶落季 2021-02-10 19:16

I can\'t train the SVM to recognize my object. I\'m trying to do this using SURF + Bag Of Words + SVM. My problem is that the classifier does not detect anything. All the result

1条回答
  •  长情又很酷
    2021-02-10 19:20

    First of all, using same parameters from an existing project doesn't prove that you are using correct parameters. In fact, in my opinion it is a completely nonsense approach (no offense). It is because, SVM parameters are affected from dataset and decriptor extraction method directly. In order to get correct parameters you have to do cross-validation. So if those parameters are obtained from a different recognition task it won't make any sense. For example in my face verification project optimal parameters were 0.0625 and 10 for gamma and C respectively.

    Other important issue with your approach is test images. As far as I see from your code, you are not using images from disk to test your classifier, so from rest of here I'll do some assumptions. If your test images, that you are acquired from camera are different from your positive images, it will fail. By different I mean this; you have to be sure that your test images are composed only of steering wheels, because your training images contain only steering wheels. If your test image contains, for instance car seat with it, your BoW descriptor for test image will be completely different from your train images BoW descriptor. So, simply, your test images shouldn't contain steering wheels with some other objects, they should only contain steering wheels.

    If you satisfy these, using training images for testing your system is the most basic approach. Even in that scenario you are failing you probably have some implenetation issues. Other approach can be this; split your training data into two, such that you have four partitions:

    • Positive train images
    • Negative train images
    • Positive test images
    • Negative test images

    Use only train images for training the system and test it with the test images. And again, you have to specify parameters via cross-validation.

    Other than these, you might want to check some specific steps in order to localize the problem, before doing the previous things that I wrote:

    1. How many keypoints are detected for each image? Similar images should result in similar number of keypoints.
    2. You know that BoW descriptor is a histogram of the SURF descriptors of an image. Be sure that similar images result in similar histograms (BoW descriptors). It is better for you to check this by visualizing the histograms.
    3. If the previous step is satisfied, the problem is most probably with the SVM training step, which is a very important step (maybe the most important one).

    I hope I was able to emphasize the importance of the cross-validation. Do the cross-validation!

    Good luck!

    0 讨论(0)
提交回复
热议问题