File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 22
33Java Foreign Function & Memory bindings for [ openpnp-capture] ( https://github.com/openpnp/openpnp-capture ) .
44
5+ ## Example
6+
7+ ``` java
8+ import io.github.doblon8.openpnp.capture.* ;
9+
10+ import javax.imageio.ImageIO ;
11+
12+ import static io.github.doblon8.openpnp.capture.OpenPnpCapture.* ;
13+
14+ void main() throws Exception {
15+ System . out. println(" openpnp-capture version: " + OpenPnpCapture . getLibraryVersion());
16+
17+ setLogLevel(LogLevel . INFO );
18+ installCustomLogFunction((logLevel, message) - > System . out. println(" Log [" + logLevel + " ]: " + message));
19+
20+ try (var capture = new OpenPnpCapture ()) {
21+ var device = capture. getDevices(). stream()
22+ .findFirst()
23+ .orElseThrow(() - > new CaptureException (" No capture devices found." ));
24+
25+ var format = device. getFormats(). stream()
26+ .findFirst()
27+ .orElseThrow(() - > new CaptureException (" No formats found." ));
28+
29+ try (var stream = device. openStream(format)) {
30+ TimeUnit . SECONDS. sleep(1 ); // let the camera initialize
31+
32+ var zoomLimits = stream. getPropertyLimits(CaptureProperty . ZOOM );
33+ System . out. println(" Zoom limits: " + zoomLimits);
34+
35+ var image = stream. capture();
36+ ImageIO . write(image, " png" , new File (" /tmp/image.png" ));
37+ System . out. println(" Captured image saved to /tmp/image.png" );
38+ }
39+ }
40+ }
41+ ```
42+
543## License
644
745This project is licensed under the MIT License, the same as the ` openpnp-capture ` library.
You can’t perform that action at this time.
0 commit comments