Advertisement
Guest User

Untitled

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