Skip to content

mbari-media-management/vars-avfoundation

Repository files navigation

MBARI logo

vars-avfoundation

Java interface to native Mac OS image capture using AVFoundation. Works with hardware capture cards (as well as built-in cameras).

Build

mvn package

Usage

import org.mbari.vars.avfoundation.AVFImageCapture;

// Native libraries are extracted under the hood and automatimaclly
// Added to java.library.path
AVFImageCapture ic = new AVFImageCapture();

// List all available devices
String[] devices = ic.videoDevicesAsStrings();

// Pick one to capture from
ic.startSessionWithNamedDevice(devices[0]);

// Do some capturing, capture as many images as you want. Images are
// written to where you specify. Also, read and returned as java.awt.Image
Optional<java.awt.Image> image = ic.capture(new File("foo.png"));

// When done. release the device.
ic.stopSession()