import uk.co.caprica.picam.Camera;
import uk.co.caprica.picam.CameraConfiguration;
import uk.co.caprica.picam.CaptureFailedException;
import uk.co.caprica.picam.FilePictureCaptureHandler;
import uk.co.caprica.picam.enums.AutomaticWhiteBalanceMode;
import uk.co.caprica.picam.enums.Encoding;
import java.io.File;
import static uk.co.caprica.picam.CameraConfiguration.cameraConfiguration;
public class MyCameraApplication {
public static void main(String[] args) {
CameraConfiguration config = cameraConfiguration()
.width(1920)
.height(1080)
.automaticWhiteBalance(AutomaticWhiteBalanceMode.AUTO)
.encoding(Encoding.JPEG)
.quality(85);
try (Camera camera = new Camera(config)) {
camera.takePicture(new FilePictureCaptureHandler(new File("photo.jpg")));
}
catch (CaptureFailedException e) {
e.printStackTrace();
}
// Camera will be automatically closed
}
}