Image capture with Processing and OpenCV

You may find some ideas how to do that in an older processing forum.

https://forum.processing.org/one/topic/save-an-image-from-webcam-capture.html

Not checked but you may find an approach to get it solved. OpenCV is not needed.