static Mat background, foregroundmask, colormask, mScissors, scissorsmask;
static double Z = 1;
+static bool recomputeScissors = true;
void mouseScissors(int evt, int x, int y, int flags, void* param){
if (evt==CV_EVENT_LBUTTONDOWN) {
Prefs.scissorpoints->push_back( Point(x, y) );
+ recomputeScissors = true;
}
else if (evt==CV_EVENT_RBUTTONDOWN) {
nearestid = ipoint;
}
}
- if ( nearestid != -1 )
+ if ( nearestid != -1 ) {
Prefs.scissorpoints->erase( Prefs.scissorpoints->begin() + nearestid );
+ recomputeScissors = true;
+ }
}
}
}
else
scissorsmask = Mat::ones(Props.height, Props.width, CV_8U);
-
- //if ( ! windowclosed_sissors )
- if ( ! isWindowClosed("stickletrack_masking_scissorsmask") )
- imshow("stickletrack_masking_scissorsmask", mScissors);
}
void masking_getCombinedMask(const Mat& origframe, Mat& combinedmask) {
computeColorMask(origframe, colormask);
-
computeScissors(origframe, mScissors);
- computeScissorsMask(scissorsmask);
+ if ( recomputeScissors ) {
+ computeScissorsMask(scissorsmask);
+ recomputeScissors = false;
+ }
+
+ if ( ! isWindowClosed("stickletrack_masking_scissorsmask") )
+ imshow("stickletrack_masking_scissorsmask", mScissors);
+
bitwise_and(foregroundmask, colormask, combinedmask);
bitwise_and(combinedmask, scissorsmask, combinedmask);
}