@@ -101,6 +101,43 @@ public PropertyLimits getPropertyLimits(CaptureProperty property) {
101101 }
102102 }
103103
104+ /**
105+ * Get the current value of a camera/stream property (e.g. zoom, exposure etc.).
106+ *
107+ * @param property the property to get the value for.
108+ * @return the current value of the property.
109+ * @throws CaptureException if an error occurs while getting the property value.
110+ */
111+ public int getPropertyValue (CaptureProperty property ) {
112+ try (Arena arena = Arena .ofConfined ()) {
113+ MemorySegment valuePointer = arena .allocate (ValueLayout .JAVA_INT );
114+ int result = Cap_getProperty (context .getSegment (), id , property .value (), valuePointer );
115+ CaptureResult captureResult = CaptureResult .values ()[result ];
116+ return switch (captureResult ) {
117+ case OK -> valuePointer .get (ValueLayout .JAVA_INT , 0 );
118+ case PROPERTY_NOT_SUPPORTED -> throw new CaptureException ("Property " + property + " is not supported by this stream." );
119+ default -> throw new CaptureException ("Error getting property value for property " + property + ": context, stream are invalid or value is null." );
120+ };
121+ }
122+ }
123+
124+ /**
125+ * Set the value of a camera/stream property (e.g. zoom, exposure etc.).
126+ *
127+ * @param property the property to set the value for.
128+ * @param value the value to set for the property.
129+ * @throws CaptureException if an error occurs while setting the property value.
130+ */
131+ public void setProperty (CaptureProperty property , int value ) {
132+ int result = Cap_setProperty (context .getSegment (), id , property .value (), value );
133+ CaptureResult captureResult = CaptureResult .values ()[result ];
134+ switch (captureResult ) {
135+ case OK -> {}
136+ case PROPERTY_NOT_SUPPORTED -> throw new CaptureException ("Property " + property + " is not supported by this stream." );
137+ default -> throw new CaptureException ("Error getting property limit for property " + property + ": context, stream are invalid." );
138+ }
139+ }
140+
104141 /**
105142 * Check if a stream is open, i.e. is capturing data.
106143 *
0 commit comments