1

I'm working on a high resolution data set for extracting desired image objects. To do this, I have applied HOG + SVM. Although the results I get are very promising and operationally accepted, the speed of this task is annoying! For each image, which is of size 2800 * 1400, the algorithm takes 4 minutes to be done, which is far from the time I need. Most of this time is taken for performing sliding window. I need this recognition procedure to be done within only 10 seconds. Since I make the use of Matlab, it seems that reaching 10 seconds is impossible and I have to think of C++. However, I've never worked with C++ and haven't enough time to learn it for this task.

I would be grateful to know that is there any ways to speed up the sliding window in Matlab or Python to perform the recognition in under 1 minute?

Federico
  • 266
  • 1
  • 2
  • 13
  • 1
    It may be worth posting the code that you have on the [Code Review](http://codereview.stackexchange.com/) site for suggestions on optimization. – Suever Mar 08 '16 at 14:30
  • 1
    Not only will you need to use a language like C++ to improve efficiency, but you'll probably need to use CUDA to offload a majority of the computational overhead onto GPUs. I believe there are CUDA extensions/libraries for Python as well. Doing it in Matlab with only the use of a CPU will not get you even close to under a minute, let alone under 10 seconds. – Scott Mudge Mar 08 '16 at 14:30
  • Many thanks to both of you for your helpful comments. @Scott, if there exists CUDA modules for Python, is it possible to get the goal without employing C++? – Federico Mar 08 '16 at 15:16
  • 1
    Depending on the performance of the GPUs available to CUDA and the efficiency of your algorithms, certainly. – Scott Mudge Mar 08 '16 at 15:50
  • If you have the parallel computing toolbox, you also have CUDA support in Matlab. – Jonas Mar 08 '16 at 15:55
  • @Jonas, thank you. Yes, I have used parallel computing toolbox and also I have vectorized the scripts as much as possible; however, I'm not seeing any significant improvement in the speed. – Federico Mar 08 '16 at 17:22
  • @Federico - the time spent in the body of the loop has to be sufficiently large for you to be able to see speed improvements when you replace `for` with `parfor`. Also, I assume you did try CUDA, then? – Jonas Mar 08 '16 at 20:48
  • @Jonas, thank you for the reply. Yes, I use `parfor`, but it is also not an effective helper for my case. – Federico Mar 09 '16 at 10:53
  • @Federico: you may want to look into modifying your code, then. If you don't need to process individual frames sequentially, you can e.g. run `parfor iFrame=1:nFrames, %spend 4 minutes on a frame;end`, which brings processing to under 10s/frame if you run on 25 nodes. – Jonas Mar 09 '16 at 12:04
  • @Jonas, thank you for your great suggestion. I'll try it and report the results. – Federico Mar 09 '16 at 12:19

1 Answers1

2

Does it have to be HOG-SVM?

If not, then you can use the trainCascadeObjectDetector function in the Computer Vision System Toolbox. It trains a boosted cascade classifier, and it gives you a choice of HOG, LBP, and Haar features. Then you can use vision.CascadeObjectDetector, which implements the sliding windows internally using native code, making it much faster.

See matlab documentation on training a cascade object detector.

Dima
  • 38,860
  • 14
  • 75
  • 115
  • Thank you so much for your comment. I have already tested that function, but I got poor accuracy. On the other hand, when I apply SVM and HOG together, the result is the one I need and very accurate. I barely see false-classified objects when using this combination. – Federico Mar 09 '16 at 10:48
  • 1
    Interesting... What kind of objects are you trying to detect? – Dima Mar 09 '16 at 15:58
  • Thank you for the response. My objects are traffic signs. – Federico Mar 09 '16 at 16:11