Ask Your Question
0

How to speed up multiple object detection and tracking?

asked 2013-05-13 22:08:03 -0600

LeonLaw gravatar image

updated 2013-05-13 22:09:07 -0600

Hi everyone. I have been working an moving object dection and tracking project. There're some questions that block me recently. Here are the opencv processing procedures: 0.Binary process 1. cvDilate 2. cvErode 3. cvCvtColor // CV_BGR2GRAY 4. cvSmooth 5. cvFindContours

For an image with 360x60 pixels, it takes about 5ms to handle the above procedures, but it takes nearly 20 ms to process a picture with 1280x800 pixels. Since this is an real time project, 20 ms is unacceptable. I wonder if there's any improvement methods for it. The platform is VS2010+opencv 2.4.4+C language. I intended to adopt parallel processing like TBB or openMP, but don't know how.

Besides, for multiple moving object detection and tracking, what is the best method? cvFindContours cant't find all the targets.

Your suggestions are really appreciated. Thanks for the help in advance.

Regards, Leon

edit retag flag offensive close merge delete

Comments

1
sammy gravatar imagesammy ( 2013-05-14 00:10:00 -0600 )edit

It only told me the general rule for optimization. Any example code?

LeonLaw gravatar imageLeonLaw ( 2013-05-14 01:58:40 -0600 )edit
  • How is 20ms unacceptable? Assuming your input comes from a regular video camera, you'd probably getting around 30fps, giving you 10ms to spare...
Rafael Sierra gravatar imageRafael Sierra ( 2013-05-15 02:02:40 -0600 )edit

Well, the requirement is 40 fps or more. The above steps would take more than 20ms...

LeonLaw gravatar imageLeonLaw ( 2013-05-15 04:33:10 -0600 )edit

2 answers

Sort by ยป oldest newest most voted
0

answered 2013-05-15 02:32:47 -0600

Rafael Sierra gravatar image

If you can process a 360x60 image in 5ms, a 1280x800 should take 47 times that: about 230ms. I guess you had a typo and you meant around 200ms, as there might be other factors (like jpeg decompression) that affect the runtime.

You outline 5 steps and I see that there is a problem with the order of the operations: (I'm assuming you use color images as input as your are converting with CV_BGR2GRAY ).

Step number 3, cvCvtColor(), should be your first step, as steps 1 & 2 dilate/erode usually don't make much sense on non-binary images: Working on 1-channel images is way faster than working on 3-channel images.

Step 4 uses cvSmooth() and depending on the method (CV_MEDIAN for instance) this usually taxes your system: avoid it if you can.

Now, regarding optimization, a 1280x800 image takes more that 3MB to hold in memory, and whatever you do will be constrained by the memory access speed of your system. Operations are faster if all the data involved is held on the CPU cache. It would be better if you design your algorithms so you can divide your image in several horizontal strips so each strip data (aggregating the input and all intermediate images) fits on the cache, and apply all of your processing steps to each strip separately.

Also you could use a few threads to process your image in parallel. Keep in mind that you want to keep most data in the CPU cache, so you might need to increase the number of strips, so most data is kept in the cache.

Cheers.

edit flag offensive delete link more

Comments

Thanks for the detailed suggestions. The performance should be improved as per the above analysis. Yeah, the input are 3-channel RGB images. I'll update the sequences of these opencv steps.

LeonLaw gravatar imageLeonLaw ( 2013-05-15 04:29:51 -0600 )edit
0

answered 2013-05-14 00:00:17 -0600

NightLife gravatar image

updated 2013-05-14 00:01:17 -0600

Image Pyramid method can help you to manage this problem. This Link is about the fast template matching by means of Image Pyramid.

Hope the idea be usefull.

edit flag offensive delete link more

Comments

Thanks a lot for quick response. It looks like the answer what I'm looking for. Let me verify the method. Any suggestions for C language concurrency computing?

LeonLaw gravatar imageLeonLaw ( 2013-05-14 00:43:15 -0600 )edit

Your welcome Man ..For the concurrency I do not have idea now. If the answer is useful, just mark it as a correct answer for the others :)

NightLife gravatar imageNightLife ( 2013-05-14 01:01:35 -0600 )edit

The object is unregular finger points, I'm not sure whether the method works. Thanks a lot.

LeonLaw gravatar imageLeonLaw ( 2013-05-14 02:00:57 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2013-05-13 22:08:03 -0600

Seen: 4,496 times

Last updated: May 15 '13