Skip to content

Instantly share code, notes, and snippets.

@squm
Created September 4, 2019 05:51
Show Gist options
  • Save squm/9d0e9a4898ca2d9400b2595e7a97d337 to your computer and use it in GitHub Desktop.
Save squm/9d0e9a4898ca2d9400b2595e7a97d337 to your computer and use it in GitHub Desktop.
int
motion_count(Mat I) {
const int size = motion_mask_size;
resize(I, I, Size(size, size), 0, 0, INTER_NEAREST);
int i = 0;
int count = 0;
for (
MatConstIterator_<uchar>
it = I.begin<uchar>(),
end = I.end<uchar>();
it != end;
it++
) {
const bool b = *it == 0 ? false : true;
if (b) {
count++;
}
}
return count;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment