This how-to demonstrates how to take a picture from webcam using Java and Marvin. You just need to use MarvinJavaCVAdapter to connect to the webcam and request the camera frame.

WebcamPicture.java:

public class WebcamPicture {
	public static void main(String[] args) {
		try{
			MarvinVideoInterface videoAdapter = new MarvinJavaCVAdapter();
			videoAdapter.connect(0);
			MarvinImage image = videoAdapter.getFrame();
			MarvinImageIO.saveImage(image, "./res/webcam_picture.jpg");
		} catch(MarvinVideoInterfaceException e){
			e.printStackTrace();
		}
	}
}

Was this how-to helpful? Share it:

Do not you know how to setup Marvin? Read how to develop your First Application.