@@ -30,8 +30,6 @@ public class LibCameraJNI {
30
30
private static boolean libraryLoaded = false ;
31
31
private static final Logger logger = new Logger (LibCameraJNI .class , LogGroup .Camera );
32
32
33
- public static final Object CAMERA_LOCK = new Object ();
34
-
35
33
public static synchronized void forceLoad () throws IOException {
36
34
if (libraryLoaded ) return ;
37
35
@@ -93,8 +91,13 @@ public String getFriendlyName() {
93
91
}
94
92
}
95
93
96
- public static SensorModel getSensorModel () {
97
- int model = getSensorModelRaw ();
94
+ public static SensorModel getSensorModel (long r_ptr ) {
95
+ int model = getSensorModelRaw (r_ptr );
96
+ return SensorModel .values ()[model ];
97
+ }
98
+
99
+ public static SensorModel getSensorModel (String name ) {
100
+ int model = getSensorModelRaw (name );
98
101
return SensorModel .values ()[model ];
99
102
}
100
103
@@ -107,88 +110,101 @@ public static boolean isSupported() {
107
110
108
111
private static native boolean isLibraryWorking ();
109
112
110
- public static native int getSensorModelRaw ();
113
+ public static native int getSensorModelRaw (long r_ptr );
114
+
115
+ public static native int getSensorModelRaw (String name );
111
116
112
117
// ======================================================== //
113
118
114
119
/**
115
120
* Creates a new runner with a given width/height/fps
116
121
*
122
+ * @param the path / name of the camera as given from libcamera.
117
123
* @param width Camera video mode width in pixels
118
124
* @param height Camera video mode height in pixels
119
125
* @param fps Camera video mode FPS
120
- * @return success of creating a camera object
126
+ * @return the runner pointer for the camera.
121
127
*/
122
- public static native boolean createCamera (int width , int height , int rotation );
128
+ public static native long createCamera (String name , int width , int height , int rotation );
123
129
124
130
/**
125
131
* Starts the camera thresholder and display threads running. Make sure that this function is
126
132
* called synchronously with stopCamera and returnFrame!
127
133
*/
128
- public static native boolean startCamera ();
134
+ public static native boolean startCamera (long r_ptr );
129
135
130
136
/** Stops the camera runner. Make sure to call prior to destroying the camera! */
131
- public static native boolean stopCamera ();
137
+ public static native boolean stopCamera (long r_ptr );
132
138
133
139
// Destroy all native resources associated with a camera. Ensure stop is called prior!
134
- public static native boolean destroyCamera ();
140
+ public static native boolean destroyCamera (long r_ptr );
135
141
136
142
// ======================================================== //
137
143
138
144
// Set thresholds on [0..1]
139
145
public static native boolean setThresholds (
140
- double hl , double sl , double vl , double hu , double su , double vu , boolean hueInverted );
146
+ long r_ptr ,
147
+ double hl ,
148
+ double sl ,
149
+ double vl ,
150
+ double hu ,
151
+ double su ,
152
+ double vu ,
153
+ boolean hueInverted );
141
154
142
- public static native boolean setAutoExposure (boolean doAutoExposure );
155
+ public static native boolean setAutoExposure (long r_ptr , boolean doAutoExposure );
143
156
144
157
// Exposure time, in microseconds
145
- public static native boolean setExposure (int exposureUs );
158
+ public static native boolean setExposure (long r_ptr , int exposureUs );
146
159
147
160
// Set brightness on [-1, 1]
148
- public static native boolean setBrightness (double brightness );
161
+ public static native boolean setBrightness (long r_ptr , double brightness );
149
162
150
163
// Unknown ranges for red and blue AWB gain
151
- public static native boolean setAwbGain (double red , double blue );
164
+ public static native boolean setAwbGain (long r_ptr , double red , double blue );
152
165
153
166
/**
154
167
* Get the time when the first pixel exposure was started, in the same timebase as libcamera gives
155
168
* the frame capture time. Units are nanoseconds.
156
169
*/
157
- public static native long getFrameCaptureTime ();
170
+ public static native long getFrameCaptureTime (long p_ptr );
158
171
159
172
/**
160
173
* Get the current time, in the same timebase as libcamera gives the frame capture time. Units are
161
174
* nanoseconds.
162
175
*/
163
176
public static native long getLibcameraTimestamp ();
164
177
165
- public static native long setFramesToCopy (boolean copyIn , boolean copyOut );
178
+ public static native long setFramesToCopy (long r_ptr , boolean copyIn , boolean copyOut );
166
179
167
180
// Analog gain multiplier to apply to all color channels, on [1, Big Number]
168
- public static native boolean setAnalogGain (double analog );
181
+ public static native boolean setAnalogGain (long r_ptr , double analog );
169
182
170
183
/** Block until a new frame is available from native code. */
171
- public static native boolean awaitNewFrame ();
184
+ public static native long awaitNewFrame (long r_ptr );
172
185
173
186
/**
174
187
* Get a pointer to the most recent color mat generated. Call this immediately after
175
188
* awaitNewFrame, and call only once per new frame!
176
189
*/
177
- public static native long takeColorFrame ();
190
+ public static native long takeColorFrame (long pair_ptr );
178
191
179
192
/**
180
193
* Get a pointer to the most recent processed mat generated. Call this immediately after
181
194
* awaitNewFrame, and call only once per new frame!
182
195
*/
183
- public static native long takeProcessedFrame ();
196
+ public static native long takeProcessedFrame (long pair_ptr );
184
197
185
198
/**
186
199
* Set the GPU processing type we should do. Enum of [none, HSV, greyscale, adaptive threshold].
187
200
*/
188
- public static native boolean setGpuProcessType (int type );
201
+ public static native boolean setGpuProcessType (long r_ptr , int type );
202
+
203
+ public static native int getGpuProcessType (long p_ptr );
189
204
190
- public static native int getGpuProcessType ();
205
+ /** Release a pair pointer back to the libcamera driver code to be filled again */
206
+ public static native boolean releasePair (long p_ptr );
191
207
192
- // Release a frame pointer back to the libcamera driver code to be filled again */
193
- // public static native long returnFrame(long frame );
208
+ /** Get an array containing the names/ids/paths of all connected CSI cameras from libcamera. */
209
+ public static native String [] getCameraNames ( );
194
210
}
0 commit comments