Advertisement
Guest User

Untitled

a guest
Jun 28th, 2017
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.69 KB | None | 0 0
  1. cv::Mat calculatedBackground;
  2. cv::Mat getForegroundMask( cv::Mat sourceImage8 )
  3. {
  4.     // Remove NODEPTH because it is at maximum distance
  5.     cv::Mat foregroundMask;
  6.     cv::Mat frame8withoutNODEPTH;
  7.     cv::threshold( sourceImage8, frame8withoutNODEPTH, 250,250, cv::THRESH_TOZERO_INV );
  8.     // Compare for new maximum distances
  9.     cv::max( calculatedBackground, frame8withoutNODEPTH, calculatedBackground );
  10.     // Add small Tolerance
  11.     cv::Mat backgroundWithTolerance;
  12.     cv::add( calculatedBackground, cvScalarAll(-1), backgroundWithTolerance );
  13.     // Find foreground:
  14.     cv::compare( sourceImage8, backgroundWithTolerance, foregroundMask, cv::CMP_LT );
  15.     return foregroundMask;
  16. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement