Skip to content

doblon8/openpnp-capture-java

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

75 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

openpnp-capture-java

Java Foreign Function & Memory bindings for OpenPnP Capture.

Installation

openpnp-capture-java is available from Maven Central.

To add openpnp-capture-java as a dependency using Maven, include the following in your pom.xml:

<dependency>
  <groupId>io.github.doblon8</groupId>
  <artifactId>openpnp-capture-java</artifactId>
  <version>0.0.3</version>
</dependency>

For other build tools, retrieve the dependency from Maven Central using the same coordinates.

openpnp-capture-java bundles the native openpnp-capture libraries for supported platforms, sourced from the sparrowwallet/openpnp-capture repository, so no system-wide installation is required.

Example

import io.github.doblon8.openpnp.capture.*;

import javax.imageio.ImageIO;

void main() throws Exception {
	System.out.println("openpnp-capture version: " + OpenPnpCapture.getLibraryVersion());

    OpenPnpCapture.setLogLevel(LogLevel.INFO);
    OpenPnpCapture.installCustomLogFunction((logLevel, message) -> System.out.println("Log [" + logLevel + "]: " + message));
    
    try (var capture = new OpenPnpCapture()) {
        var device = capture.getDevices().stream()
                .findFirst()
                .orElseThrow(() -> new CaptureException("No capture devices found."));

        var format = device.getFormats().stream()
                .findFirst()
                .orElseThrow(() -> new CaptureException("No formats found."));

        try (var stream = device.openStream(format)) {
            TimeUnit.SECONDS.sleep(1); // let the camera initialize

            var exposureLimits = stream.getPropertyLimits(CaptureProperty.EXPOSURE);
            System.out.println("Exposure limits: " + exposureLimits);

            var image = stream.capture();
            ImageIO.write(image, "png", new File("/tmp/image.png"));
            System.out.println("Captured image saved to /tmp/image.png");
        }
    }
}

License

This project is licensed under the MIT License, the same as the openpnp-capture library.

See the LICENSE file for details.

About

Java Foreign Function & Memory bindings for OpenPnP Capture

Topics

Resources

License

Stars

0 stars

Watchers

1 watching

Forks

Packages

 
 
 

Contributors

Languages