Ask Your Question
2

LatentSVM detector

asked 2013-04-22 11:21:55 -0500

Mowgly gravatar image

Hi everybody,

I am using LatentSVM detector with the code available in samples/cpp/latentsvm_multidetect.cpp. The problem is that it works a bit slow for what I want. My question is if there is any way to change some parameters that could make this code to work faster?

Thank you in advance,

Xavi

edit retag flag offensive close merge delete

2 answers

Sort by ยป oldest newest most voted
2

answered 2013-04-22 14:00:36 -0500

Basically the latentSVM algorithm is an implementation of the latentSVM algorithm of Pedro Felzenswalb. It is one of the more earlier implementations, leading indeed to an operating speed of like 5-10 seconds per image for processing.

You could try to reduce the size of the image and apply a mask that defines regions where people can actually occur (cut out air and buildings for example). You could even use background subtraction to first define moving regions in subsequent images.

However, if you want a faster implementation of this algorithm, go to his website and get the release 5, which uses grammar models and which is way faster in processing.

http://people.cs.uchicago.edu/~rbg/latent/

If you want to go for realtime processing, you will need to implement the algorithm on GPU, or trying to convert it to multicore usage. Also trying other techniques which are faster, like random forests, could be a way to go.

edit flag offensive delete link more
0

answered 2013-05-08 08:44:15 -0500

vinayverma gravatar image

I have recently faced the same issue. For an application I used Latent SVM xmls which are already provided with OpenCV installation. It seems like there is an argument in the detect() method where we can specify the number of parallel threads for detection. However the detection time doesn't vary with number of threads. If a single model is loaded, the detection time varies from 10-20 sec per frame and things become worse if you load multiple models.

To make it faster, you can aid it with motion detection if your object is not stationary and moves a bit in the video. Once it is aided with motion detection, as per the maximum speed of your object, you can reject false detections using the distance between current and last detection. You can also skip frames in which the motion rectangle is less than the size of your object (this helps a lot).

If there is a region in the frame where your object is expected to be present, you can apply detection only to that region (again would take lesser time).

However, ANYTHING YOU DO, LatentSVM detection samples in OpenCV CANNOT DETECT IN REAL TIME.

Because of this, I am now using HaarTraining to build new models for my objects. And the results are very promising even at stage 8 of training. It is hardly consuming 20-40 ms and giving real time performance. I would suggest if you need real time processing, better switch to HaarTraining.

edit flag offensive delete link more

Comments

Hi Vinay, did you use opencv_haartraining (obsolete version) or opencv_traincascade?

sy456 gravatar imagesy456 ( 2014-03-12 07:41:41 -0500 )edit
Login/Signup to Answer

Question Tools

Stats

Asked: 2013-04-22 11:21:55 -0500

Seen: 1,539 times

Last updated: May 08 '13