Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class ForgroundDetector {
- public:
- cv::Mat& getForegroundMask(cv::Mat const& sourceImage8 ) {
- // Remove NODEPTH because it is at maximum distance
- cv::Mat frame8withoutNODEPTH;
- cv::threshold(sourceImage8, frame8withoutNODEPTH, 250,250, cv::THRESH_TOZERO_INV);
- // Compare for new maximum distances
- cv::max(m_calculatedBackground, frame8withoutNODEPTH, m_calculatedBackground);
- // Add small Tolerance
- cv::Mat backgroundWithTolerance;
- cv::add(m_calculatedBackground, cvScalarAll(-1), backgroundWithTolerance);
- // Find foreground:
- cv::compare(sourceImage8, backgroundWithTolerance, m_foregroundMask, cv::CMP_LT);
- return m_foregroundMask;
- }
- private:
- cv::Mat m_calculatedBackground;
- cv::Mat m_foregroundMask;
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement