OpenCV freeze ~1-2 sec. then continue...

Hi all,
I’m working on face recognition and blob tracking. Thanks to this forum, google and a couple of books I’ve manage to do exactly what I want. BUT, (because there’s always a ‘but’) my program freeze 1 to 2 sec. then continue as normal at relatively constant time. It’s not a nightmare but I really want to get rid of this kind of ‘lag’.
Then I’ve got two questions:

1- Is it something I should accept because it’s something often encounter with this library?

2- If the answer of my first question is ‘no’ then what can cause this little but annoying freeze?

3- Last question: can I resolve this issue and how?

Before posting my code I prefer to have your opinions on the first two question and make sure that you understand what’s my bug then I will show you my work.

note: I’m an artist that code stuff not a coder artist.

Big thanks in advance! Your help will be greatly appreciate!

that length of pause is not normal –

what is the condition in which the application freezes? for example, is it when there are alot of blobs?

steps I’d take to debug it:

a) first thing I’d check is for printing to the console, via printf or cout – this can be slow occur only at certain moments.

b) I’d comment out all of the draw() but leave in the update() to see, is it visual or based on things happening in update(). You can also comment out update() and leave in draw to check the reverse. If you comment out the draw, you’ll need to draw something animating just to be sure if it’s pausing or not.

c) once you’ve determined where the app is slowing, I’d start to comment out blocks of code, usually I work from the bottom of the function to the start, to see if I can see one line or one thing that is problematic.

things that are slow – allocating memory, reading from disk, printing to console, some algorithms, etc.

hope that helps

please feel free to post a simple-as-possible example that shows the problem (sometimes doing this can even help diagnose the problem)

take care,

also: you might have a memory leak. check the amount of memory your app is using (under OSX you use Activity Monitor, under windows use Task Manager). if it’s constantly increasing, then memory is leaking somewhere and that might be causing the pause.