On Linux, simply use the v4l2-ctl
command to reduce all saturation and get the camera to spit out grayscale output:
v4l2-ctl -c saturation=0
Of course, that will work only if your webcam supports the saturation
option. To check whether it does, take a look at all available controls:
v4l2-ctl -l