2

Im trying out the codebook method, but don't really understand the point of int t in a code_book struct. Its the variable used to "Count every access", but this completely lost me. Count what access to what? By whom? Could someone please explain the purpose of the member variable to me? Please try to use non-technical terms

Secondly, in the ce struct, whats the point of the int t_last_update and int stale member data? t_last_update is supposed to kill stale entries, but whats a stale entry? What do you mean by "kill it"? And for int stale, its supposed to count the max negative run? Whats a negative run and whats its used for?

Thanks for your help

PS: just confirming what I need: explain what int t in a code_book struct does and what int t_last_update and int _stale do in a ce struct.

Jav_Rock
  • 22,059
  • 20
  • 123
  • 164
fdh
  • 5,256
  • 13
  • 58
  • 101

1 Answers1

3

I assume you are talking about this section of code from the OpenCV book:

typedef struct code_book {
  ...
  int t; // Count every access
} codeBook;

Basically, you can think of the t field as a tick count each time a new frame is added to the code book. It used to determine how long it has been from the start of the code book collection, or the last clear of stale pixels.

EDIT: You have two data structures being tracked. codeBook is like the parent of the codeBook_elements (i.e., the ce structure) stored within it. t is incremented every time the codeBook is updated. But, that update may not increment all codeBook_elements. So...

t_last_update is the last time a particular codeBook_element was accessed.

stale helps to track how "old" the code book entries are in the code book.

negRun stands for negative run-time. It keeps track of how long it has been since a code book entry has been accessed. If it's been too long, then it's considered stale and is removed to conserve memory.

There is an update of the code book method in the OpenCV samples. Take a look at the bgfg_codebook.cpp sample.

Hope that was helpful!

Daniel
  • 1,239
  • 1
  • 13
  • 24
mevatron
  • 13,911
  • 4
  • 55
  • 72
  • 1
    Thank You I understood it all perfectly :) Just one small thing- t_last_update and int t seem basically the same thing, so why have two different variables? Thanks Again – fdh Oct 14 '11 at 02:08
  • Sorry, about that I didn't make that quite clear :) I'll edit the answer to clear that up! – mevatron Oct 14 '11 at 02:14
  • Thank You that summed it up perfectly :) – fdh Oct 14 '11 at 02:18