开发者

OpenCV background subtraction/codebook?

开发者 https://www.devze.com 2023-04-13 01:40 出处:网络
Im trying out the c开发者_开发百科odebook 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. C

Im trying out the c开发者_开发百科odebook 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.


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!

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号