Skip to content

Commit 183e169

Browse files
committed
Expose saturation in JNI
Signed-off-by: Jade Turner <spacey-sooty@proton.me>
1 parent 86ce412 commit 183e169

File tree

3 files changed

+34
-4
lines changed

3 files changed

+34
-4
lines changed

include/libcamera_jni.hpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,15 @@ JNIEXPORT jboolean JNICALL
9696
Java_org_photonvision_raspi_LibCameraJNI_setAutoExposure(
9797
JNIEnv *env, jclass, jlong, jboolean doAutoExposure);
9898

99+
/*
100+
* Class: org_photonvision_raspi_LibCameraJNI
101+
* Method: setSaturation
102+
* Signature: (I)Z
103+
*/
104+
JNIEXPORT jboolean JNICALL
105+
Java_org_photonvision_raspi_LibCameraJNI_setSaturation(JNIEnv *, jclass, jlong,
106+
jint);
107+
99108
/*
100109
* Class: org_photonvision_raspi_LibCameraJNI
101110
* Method: setBrightness

src/libcamera_jni.cpp

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -227,19 +227,19 @@ Java_org_photonvision_raspi_LibCameraJNI_setThresholds
227227

228228
/*
229229
* Class: org_photonvision_raspi_LibCameraJNI
230-
* Method: setExposure
230+
* Method: setSaturation
231231
* Signature: (JI)Z
232232
*/
233233
JNIEXPORT jboolean JNICALL
234-
Java_org_photonvision_raspi_LibCameraJNI_setExposure
235-
(JNIEnv *, jclass, jlong runner_, jint exposure)
234+
Java_org_photonvision_raspi_LibCameraJNI_setSaturation
235+
(JNIEnv *, jclass, jlong runner_, jint saturation)
236236
{
237237
CameraRunner *runner = reinterpret_cast<CameraRunner *>(runner_);
238238
if (!runner) {
239239
return false;
240240
}
241241

242-
runner->cameraGrabber().cameraSettings().exposureTimeUs = exposure;
242+
runner->cameraGrabber().cameraSettings().saturation = saturation;
243243
return true;
244244
}
245245

@@ -261,6 +261,24 @@ Java_org_photonvision_raspi_LibCameraJNI_setAutoExposure
261261
return true;
262262
}
263263

264+
/*
265+
* Class: org_photonvision_raspi_LibCameraJNI
266+
* Method: setExposure
267+
* Signature: (JI)Z
268+
*/
269+
JNIEXPORT jboolean JNICALL
270+
Java_org_photonvision_raspi_LibCameraJNI_setExposure
271+
(JNIEnv *, jclass, jlong runner_, jint exposure)
272+
{
273+
CameraRunner *runner = reinterpret_cast<CameraRunner *>(runner_);
274+
if (!runner) {
275+
return false;
276+
}
277+
278+
runner->cameraGrabber().cameraSettings().exposureTimeUs = exposure;
279+
return true;
280+
}
281+
264282
/*
265283
* Class: org_photonvision_raspi_LibCameraJNI
266284
* Method: setBrightness

src/main/java/org/photonvision/raspi/LibCameraJNI.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,9 @@ public static native boolean setThresholds(
114114
// Exposure time, in microseconds
115115
public static native boolean setExposure(long r_ptr, int exposureUs);
116116

117+
// Saturation
118+
public static native boolean setSaturation(long r_ptr, int saturation);
119+
117120
// Set brightness on [-1, 1]
118121
public static native boolean setBrightness(long r_ptr, double brightness);
119122

0 commit comments

Comments
 (0)