File tree Expand file tree Collapse file tree
main/java/io/github/doblon8/openpnp/capture Expand file tree Collapse file tree Original file line number Diff line number Diff line change 33import static io .github .doblon8 .openpnp .capture .bindings .openpnp_capture .Cap_closeStream ;
44import static io .github .doblon8 .openpnp .capture .bindings .openpnp_capture .Cap_isOpenStream ;
55
6- public class CaptureStream {
6+ public class CaptureStream implements AutoCloseable {
77 private final CaptureContext context ;
88 private final int id ;
99
@@ -27,6 +27,7 @@ public boolean isOpen() {
2727 *
2828 * @throws CaptureException if an error occurs while closing the capture stream.
2929 */
30+ @ Override
3031 public void close () {
3132 int result = Cap_closeStream (context .getSegment (), id );
3233 CaptureResult captureResult = CaptureResult .values ()[result ];
Original file line number Diff line number Diff line change @@ -9,14 +9,18 @@ void main() {
99 var version = OpenPnpCapture .getLibraryVersion ();
1010 System .out .println ("OpenPnP Capture Library Version: " + version );
1111
12- setLogLevel (LogLevel .ERROR );
12+ setLogLevel (LogLevel .DEBUG );
1313 installCustomLogFunction ((logLevel , message ) -> System .out .println ("Custom Log [" + logLevel + "]: " + message ));
1414
1515 try (var capture = new OpenPnpCapture ()) {
1616 // No checking if devices and format are available, just get the first ones for testing
1717 var device = capture .getDevices ().getFirst ();
1818 var format = device .getFormats ().getFirst ();
1919 System .out .println ("Using device '" + device .getName () + "' with format " + format );
20+
21+ try (var stream = device .openStream (format )) {
22+ System .out .println ("Stream is open: " + stream .isOpen ());
23+ }
2024 } catch (CaptureException e ) {
2125 System .err .println ("Error using CaptureContext: " + e .getMessage ());
2226 }
You can’t perform that action at this time.
0 commit comments