Using an mask of type 16 bit returns the following error
java.lang.RuntimeException: java.lang.RuntimeException: OpenCV(3.4.2) C:\projects\javacpp-presets\opencv\cppbuild\windows-x86_64\opencv-3.4.2\modules\imgproc\src\contours.cpp:199: error: (-210:Unsupported format or combination of formats) [Start]FindContours supports only CV_8UC1 images when mode != CV_RETR_FLOODFILL otherwise supports CV_32SC1 images only in function 'cvStartFindContours_Impl'
Check the documentation of the function findContours.
It might be enough for 16-bit mask to make a copy of the plane and cast it to 32-bit.
The copy is to avoid changing the bit type of the user provided mask, which could have side effects if the user is using the mask in another process.
Using an mask of type 16 bit returns the following error
java.lang.RuntimeException: java.lang.RuntimeException: OpenCV(3.4.2) C:\projects\javacpp-presets\opencv\cppbuild\windows-x86_64\opencv-3.4.2\modules\imgproc\src\contours.cpp:199: error: (-210:Unsupported format or combination of formats) [Start]FindContours supports only CV_8UC1 images when mode != CV_RETR_FLOODFILL otherwise supports CV_32SC1 images only in function 'cvStartFindContours_Impl'
Check the documentation of the function findContours. It might be enough for 16-bit mask to make a copy of the plane and cast it to 32-bit.
The copy is to avoid changing the bit type of the user provided mask, which could have side effects if the user is using the mask in another process.