OpenCV  3.4.4
Open Source Computer Vision
samples/cpp/create_mask.cpp

This program demonstrates using mouse events and how to make and use a mask image (black and white) .