javawebcam-capture

How to access front/back camera using java (webcam-capture)


I am using this java library to access camera in laptop/pc. Webcam-capture

Webcam webcam = Webcam.getDefault();
webcam.open();
ImageIO.write(webcam.getImage(), "PNG", new File(path));

Above code giving me back camera streaming, i want to switch both front/back cameras programatically.

I am following this Webcam-capture Guide but unable to find any related documentation for switching cameras.


Solution

  • WebCam.getWebcams() returns a list of available Webcams which you can iterate and use, instead of using the one getDefault() returns.