This works better on a white background

Show/hide code - webcam.js

Example of output