1
2//
3// This file is auto-generated, please don't edit!
4//
5
6#define LOG_TAG "org.opencv.videoio"
7
8#include "common.h"
9
10#include "opencv2/opencv_modules.hpp"
11#ifdef HAVE_OPENCV_VIDEOIO
12
13#include <string>
14
15#include "opencv2/videoio.hpp"
16
17#include "../../videoio/include/opencv2/videoio/videoio_c.h"
18#include "../../videoio/include/opencv2/videoio.hpp"
19
20using namespace cv;
21
22/// throw java exception
23static void throwJavaException(JNIEnv *env, const std::exception *e, const char *method) {
24  std::string what = "unknown exception";
25  jclass je = 0;
26
27  if(e) {
28    std::string exception_type = "std::exception";
29
30    if(dynamic_cast<const cv::Exception*>(e)) {
31      exception_type = "cv::Exception";
32      je = env->FindClass("org/opencv/core/CvException");
33    }
34
35    what = exception_type + ": " + e->what();
36  }
37
38  if(!je) je = env->FindClass("java/lang/Exception");
39  env->ThrowNew(je, what.c_str());
40
41  LOGE("%s caught %s", method, what.c_str());
42  (void)method;        // avoid "unused" warning
43}
44
45
46extern "C" {
47
48
49//
50//   VideoCapture()
51//
52
53JNIEXPORT jlong JNICALL Java_org_opencv_videoio_VideoCapture_VideoCapture_10 (JNIEnv*, jclass);
54
55JNIEXPORT jlong JNICALL Java_org_opencv_videoio_VideoCapture_VideoCapture_10
56  (JNIEnv* env, jclass )
57{
58    static const char method_name[] = "videoio::VideoCapture_10()";
59    try {
60        LOGD("%s", method_name);
61
62        cv::VideoCapture* _retval_ = new cv::VideoCapture(  );
63        return (jlong) _retval_;
64    } catch(const std::exception &e) {
65        throwJavaException(env, &e, method_name);
66    } catch (...) {
67        throwJavaException(env, 0, method_name);
68    }
69    return 0;
70}
71
72
73
74//
75//   VideoCapture(String filename)
76//
77
78JNIEXPORT jlong JNICALL Java_org_opencv_videoio_VideoCapture_VideoCapture_11 (JNIEnv*, jclass, jstring);
79
80JNIEXPORT jlong JNICALL Java_org_opencv_videoio_VideoCapture_VideoCapture_11
81  (JNIEnv* env, jclass , jstring filename)
82{
83    static const char method_name[] = "videoio::VideoCapture_11()";
84    try {
85        LOGD("%s", method_name);
86        const char* utf_filename = env->GetStringUTFChars(filename, 0); String n_filename( utf_filename ? utf_filename : "" ); env->ReleaseStringUTFChars(filename, utf_filename);
87        cv::VideoCapture* _retval_ = new cv::VideoCapture( n_filename );
88        return (jlong) _retval_;
89    } catch(const std::exception &e) {
90        throwJavaException(env, &e, method_name);
91    } catch (...) {
92        throwJavaException(env, 0, method_name);
93    }
94    return 0;
95}
96
97
98
99//
100//   VideoCapture(int device)
101//
102
103JNIEXPORT jlong JNICALL Java_org_opencv_videoio_VideoCapture_VideoCapture_12 (JNIEnv*, jclass, jint);
104
105JNIEXPORT jlong JNICALL Java_org_opencv_videoio_VideoCapture_VideoCapture_12
106  (JNIEnv* env, jclass , jint device)
107{
108    static const char method_name[] = "videoio::VideoCapture_12()";
109    try {
110        LOGD("%s", method_name);
111
112        cv::VideoCapture* _retval_ = new cv::VideoCapture( (int)device );
113        return (jlong) _retval_;
114    } catch(const std::exception &e) {
115        throwJavaException(env, &e, method_name);
116    } catch (...) {
117        throwJavaException(env, 0, method_name);
118    }
119    return 0;
120}
121
122
123
124//
125//  bool open(String filename)
126//
127
128JNIEXPORT jboolean JNICALL Java_org_opencv_videoio_VideoCapture_open_10 (JNIEnv*, jclass, jlong, jstring);
129
130JNIEXPORT jboolean JNICALL Java_org_opencv_videoio_VideoCapture_open_10
131  (JNIEnv* env, jclass , jlong self, jstring filename)
132{
133    static const char method_name[] = "videoio::open_10()";
134    try {
135        LOGD("%s", method_name);
136        cv::VideoCapture* me = (cv::VideoCapture*) self; //TODO: check for NULL
137        const char* utf_filename = env->GetStringUTFChars(filename, 0); String n_filename( utf_filename ? utf_filename : "" ); env->ReleaseStringUTFChars(filename, utf_filename);
138        bool _retval_ = me->open( n_filename );
139        return _retval_;
140    } catch(const std::exception &e) {
141        throwJavaException(env, &e, method_name);
142    } catch (...) {
143        throwJavaException(env, 0, method_name);
144    }
145    return 0;
146}
147
148
149
150//
151//  bool open(int device)
152//
153
154JNIEXPORT jboolean JNICALL Java_org_opencv_videoio_VideoCapture_open_11 (JNIEnv*, jclass, jlong, jint);
155
156JNIEXPORT jboolean JNICALL Java_org_opencv_videoio_VideoCapture_open_11
157  (JNIEnv* env, jclass , jlong self, jint device)
158{
159    static const char method_name[] = "videoio::open_11()";
160    try {
161        LOGD("%s", method_name);
162        cv::VideoCapture* me = (cv::VideoCapture*) self; //TODO: check for NULL
163        bool _retval_ = me->open( (int)device );
164        return _retval_;
165    } catch(const std::exception &e) {
166        throwJavaException(env, &e, method_name);
167    } catch (...) {
168        throwJavaException(env, 0, method_name);
169    }
170    return 0;
171}
172
173
174
175//
176//  bool isOpened()
177//
178
179JNIEXPORT jboolean JNICALL Java_org_opencv_videoio_VideoCapture_isOpened_10 (JNIEnv*, jclass, jlong);
180
181JNIEXPORT jboolean JNICALL Java_org_opencv_videoio_VideoCapture_isOpened_10
182  (JNIEnv* env, jclass , jlong self)
183{
184    static const char method_name[] = "videoio::isOpened_10()";
185    try {
186        LOGD("%s", method_name);
187        cv::VideoCapture* me = (cv::VideoCapture*) self; //TODO: check for NULL
188        bool _retval_ = me->isOpened(  );
189        return _retval_;
190    } catch(const std::exception &e) {
191        throwJavaException(env, &e, method_name);
192    } catch (...) {
193        throwJavaException(env, 0, method_name);
194    }
195    return 0;
196}
197
198
199
200//
201//  void release()
202//
203
204JNIEXPORT void JNICALL Java_org_opencv_videoio_VideoCapture_release_10 (JNIEnv*, jclass, jlong);
205
206JNIEXPORT void JNICALL Java_org_opencv_videoio_VideoCapture_release_10
207  (JNIEnv* env, jclass , jlong self)
208{
209    static const char method_name[] = "videoio::release_10()";
210    try {
211        LOGD("%s", method_name);
212        cv::VideoCapture* me = (cv::VideoCapture*) self; //TODO: check for NULL
213        me->release(  );
214        return;
215    } catch(const std::exception &e) {
216        throwJavaException(env, &e, method_name);
217    } catch (...) {
218        throwJavaException(env, 0, method_name);
219    }
220    return;
221}
222
223
224
225//
226//  bool grab()
227//
228
229JNIEXPORT jboolean JNICALL Java_org_opencv_videoio_VideoCapture_grab_10 (JNIEnv*, jclass, jlong);
230
231JNIEXPORT jboolean JNICALL Java_org_opencv_videoio_VideoCapture_grab_10
232  (JNIEnv* env, jclass , jlong self)
233{
234    static const char method_name[] = "videoio::grab_10()";
235    try {
236        LOGD("%s", method_name);
237        cv::VideoCapture* me = (cv::VideoCapture*) self; //TODO: check for NULL
238        bool _retval_ = me->grab(  );
239        return _retval_;
240    } catch(const std::exception &e) {
241        throwJavaException(env, &e, method_name);
242    } catch (...) {
243        throwJavaException(env, 0, method_name);
244    }
245    return 0;
246}
247
248
249
250//
251//  bool retrieve(Mat& image, int flag = 0)
252//
253
254JNIEXPORT jboolean JNICALL Java_org_opencv_videoio_VideoCapture_retrieve_10 (JNIEnv*, jclass, jlong, jlong, jint);
255
256JNIEXPORT jboolean JNICALL Java_org_opencv_videoio_VideoCapture_retrieve_10
257  (JNIEnv* env, jclass , jlong self, jlong image_nativeObj, jint flag)
258{
259    static const char method_name[] = "videoio::retrieve_10()";
260    try {
261        LOGD("%s", method_name);
262        cv::VideoCapture* me = (cv::VideoCapture*) self; //TODO: check for NULL
263        Mat& image = *((Mat*)image_nativeObj);
264        bool _retval_ = me->retrieve( image, (int)flag );
265        return _retval_;
266    } catch(const std::exception &e) {
267        throwJavaException(env, &e, method_name);
268    } catch (...) {
269        throwJavaException(env, 0, method_name);
270    }
271    return 0;
272}
273
274
275
276JNIEXPORT jboolean JNICALL Java_org_opencv_videoio_VideoCapture_retrieve_11 (JNIEnv*, jclass, jlong, jlong);
277
278JNIEXPORT jboolean JNICALL Java_org_opencv_videoio_VideoCapture_retrieve_11
279  (JNIEnv* env, jclass , jlong self, jlong image_nativeObj)
280{
281    static const char method_name[] = "videoio::retrieve_11()";
282    try {
283        LOGD("%s", method_name);
284        cv::VideoCapture* me = (cv::VideoCapture*) self; //TODO: check for NULL
285        Mat& image = *((Mat*)image_nativeObj);
286        bool _retval_ = me->retrieve( image );
287        return _retval_;
288    } catch(const std::exception &e) {
289        throwJavaException(env, &e, method_name);
290    } catch (...) {
291        throwJavaException(env, 0, method_name);
292    }
293    return 0;
294}
295
296
297
298//
299//  bool read(Mat& image)
300//
301
302JNIEXPORT jboolean JNICALL Java_org_opencv_videoio_VideoCapture_read_10 (JNIEnv*, jclass, jlong, jlong);
303
304JNIEXPORT jboolean JNICALL Java_org_opencv_videoio_VideoCapture_read_10
305  (JNIEnv* env, jclass , jlong self, jlong image_nativeObj)
306{
307    static const char method_name[] = "videoio::read_10()";
308    try {
309        LOGD("%s", method_name);
310        cv::VideoCapture* me = (cv::VideoCapture*) self; //TODO: check for NULL
311        Mat& image = *((Mat*)image_nativeObj);
312        bool _retval_ = me->read( image );
313        return _retval_;
314    } catch(const std::exception &e) {
315        throwJavaException(env, &e, method_name);
316    } catch (...) {
317        throwJavaException(env, 0, method_name);
318    }
319    return 0;
320}
321
322
323
324//
325//  bool set(int propId, double value)
326//
327
328JNIEXPORT jboolean JNICALL Java_org_opencv_videoio_VideoCapture_set_10 (JNIEnv*, jclass, jlong, jint, jdouble);
329
330JNIEXPORT jboolean JNICALL Java_org_opencv_videoio_VideoCapture_set_10
331  (JNIEnv* env, jclass , jlong self, jint propId, jdouble value)
332{
333    static const char method_name[] = "videoio::set_10()";
334    try {
335        LOGD("%s", method_name);
336        cv::VideoCapture* me = (cv::VideoCapture*) self; //TODO: check for NULL
337        bool _retval_ = me->set( (int)propId, (double)value );
338        return _retval_;
339    } catch(const std::exception &e) {
340        throwJavaException(env, &e, method_name);
341    } catch (...) {
342        throwJavaException(env, 0, method_name);
343    }
344    return 0;
345}
346
347
348
349//
350//  double get(int propId)
351//
352
353JNIEXPORT jdouble JNICALL Java_org_opencv_videoio_VideoCapture_get_10 (JNIEnv*, jclass, jlong, jint);
354
355JNIEXPORT jdouble JNICALL Java_org_opencv_videoio_VideoCapture_get_10
356  (JNIEnv* env, jclass , jlong self, jint propId)
357{
358    static const char method_name[] = "videoio::get_10()";
359    try {
360        LOGD("%s", method_name);
361        cv::VideoCapture* me = (cv::VideoCapture*) self; //TODO: check for NULL
362        double _retval_ = me->get( (int)propId );
363        return _retval_;
364    } catch(const std::exception &e) {
365        throwJavaException(env, &e, method_name);
366    } catch (...) {
367        throwJavaException(env, 0, method_name);
368    }
369    return 0;
370}
371
372
373
374JNIEXPORT jstring JNICALL Java_org_opencv_videoio_VideoCapture_getSupportedPreviewSizes_10
375  (JNIEnv *env, jclass, jlong self);
376
377JNIEXPORT jstring JNICALL Java_org_opencv_videoio_VideoCapture_getSupportedPreviewSizes_10
378  (JNIEnv *env, jclass, jlong self)
379{
380    static const char method_name[] = "videoio::VideoCapture_getSupportedPreviewSizes_10()";
381    try {
382        LOGD("%s", method_name);
383        VideoCapture* me = (VideoCapture*) self; //TODO: check for NULL
384        union {double prop; const char* name;} u;
385        u.prop = me->get(CAP_PROP_ANDROID_PREVIEW_SIZES_STRING);
386        return env->NewStringUTF(u.name);
387    } catch(const std::exception &e) {
388        throwJavaException(env, &e, method_name);
389    } catch (...) {
390        throwJavaException(env, 0, method_name);
391    }
392    return env->NewStringUTF("");
393}
394
395
396//
397//  native support for java finalize()
398//  static void cv::VideoCapture::delete( __int64 self )
399//
400JNIEXPORT void JNICALL Java_org_opencv_videoio_VideoCapture_delete(JNIEnv*, jclass, jlong);
401
402JNIEXPORT void JNICALL Java_org_opencv_videoio_VideoCapture_delete
403  (JNIEnv*, jclass, jlong self)
404{
405    delete (cv::VideoCapture*) self;
406}
407
408
409
410} // extern "C"
411
412#endif // HAVE_OPENCV_VIDEOIO
413