1 #define LOG_TAG "org.opencv.core.Mat"
6 #include "opencv2/core/core.hpp"
10 /// throw java exception
11 static void throwJavaException(JNIEnv *env, const std::exception *e, const char *method) {
12 std::string what = "unknown exception";
16 std::string exception_type = "std::exception";
18 if(dynamic_cast<const cv::Exception*>(e)) {
19 exception_type = "cv::Exception";
20 je = env->FindClass("org/opencv/core/CvException");
23 what = exception_type + ": " + e->what();
26 if(!je) je = env->FindClass("java/lang/Exception");
27 env->ThrowNew(je, what.c_str());
29 LOGE("%s caught %s", method, what.c_str());
30 (void)method; // avoid "unused" warning
41 JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1Mat__
44 JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1Mat__
47 LOGD("Mat::n_1Mat__()");
48 return (jlong) new cv::Mat();
54 // Mat::Mat(int rows, int cols, int type)
57 JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1Mat__III
58 (JNIEnv* env, jclass, jint rows, jint cols, jint type);
60 JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1Mat__III
61 (JNIEnv* env, jclass, jint rows, jint cols, jint type)
63 static const char method_name[] = "Mat::n_1Mat__III()";
65 LOGD("%s", method_name);
66 return (jlong) new Mat( rows, cols, type );
67 } catch(const std::exception &e) {
68 throwJavaException(env, &e, method_name);
70 throwJavaException(env, 0, method_name);
79 // Mat::Mat(Size size, int type)
82 JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1Mat__DDI
83 (JNIEnv* env, jclass, jdouble size_width, jdouble size_height, jint type);
85 JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1Mat__DDI
86 (JNIEnv* env, jclass, jdouble size_width, jdouble size_height, jint type)
88 static const char method_name[] = "Mat::n_1Mat__DDI()";
90 LOGD("%s", method_name);
91 Size size((int)size_width, (int)size_height);
92 return (jlong) new Mat( size, type );
93 } catch(const std::exception &e) {
94 throwJavaException(env, &e, method_name);
96 throwJavaException(env, 0, method_name);
105 // Mat::Mat(int rows, int cols, int type, Scalar s)
108 JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1Mat__IIIDDDD
109 (JNIEnv* env, jclass, jint rows, jint cols, jint type, jdouble s_val0, jdouble s_val1, jdouble s_val2, jdouble s_val3);
112 JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1Mat__IIIDDDD
113 (JNIEnv* env, jclass, jint rows, jint cols, jint type, jdouble s_val0, jdouble s_val1, jdouble s_val2, jdouble s_val3)
115 static const char method_name[] = "Mat::n_1Mat__IIIDDDD()";
117 LOGD("%s", method_name);
118 Scalar s(s_val0, s_val1, s_val2, s_val3);
119 return (jlong) new Mat( rows, cols, type, s );
120 } catch(const std::exception &e) {
121 throwJavaException(env, &e, method_name);
123 throwJavaException(env, 0, method_name);
132 // Mat::Mat(Size size, int type, Scalar s)
135 JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1Mat__DDIDDDD
136 (JNIEnv* env, jclass, jdouble size_width, jdouble size_height, jint type, jdouble s_val0, jdouble s_val1, jdouble s_val2, jdouble s_val3);
138 JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1Mat__DDIDDDD
139 (JNIEnv* env, jclass, jdouble size_width, jdouble size_height, jint type, jdouble s_val0, jdouble s_val1, jdouble s_val2, jdouble s_val3)
141 static const char method_name[] = "Mat::n_1Mat__DDIDDDD()";
143 LOGD("%s", method_name);
144 Size size((int)size_width, (int)size_height);
145 Scalar s(s_val0, s_val1, s_val2, s_val3);
146 return (jlong) new Mat( size, type, s );
147 } catch(const std::exception &e) {
148 throwJavaException(env, &e, method_name);
150 throwJavaException(env, 0, method_name);
159 // Mat::Mat(Mat m, Range rowRange, Range colRange = Range::all())
162 JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1Mat__JIIII
163 (JNIEnv* env, jclass, jlong m_nativeObj, jint rowRange_start, jint rowRange_end, jint colRange_start, jint colRange_end);
165 JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1Mat__JIIII
166 (JNIEnv* env, jclass, jlong m_nativeObj, jint rowRange_start, jint rowRange_end, jint colRange_start, jint colRange_end)
168 static const char method_name[] = "Mat::n_1Mat__JIIII()";
170 LOGD("%s", method_name);
171 Range rowRange(rowRange_start, rowRange_end);
172 Range colRange(colRange_start, colRange_end);
173 return (jlong) new Mat( (*(Mat*)m_nativeObj), rowRange, colRange );
174 } catch(const std::exception &e) {
175 throwJavaException(env, &e, method_name);
177 throwJavaException(env, 0, method_name);
184 JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1Mat__JII
185 (JNIEnv* env, jclass, jlong m_nativeObj, jint rowRange_start, jint rowRange_end);
188 JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1Mat__JII
189 (JNIEnv* env, jclass, jlong m_nativeObj, jint rowRange_start, jint rowRange_end)
191 static const char method_name[] = "Mat::n_1Mat__JII()";
193 LOGD("%s", method_name);
194 Range rowRange(rowRange_start, rowRange_end);
195 return (jlong) new Mat( (*(Mat*)m_nativeObj), rowRange );
196 } catch(const std::exception &e) {
197 throwJavaException(env, &e, method_name);
199 throwJavaException(env, 0, method_name);
207 // Mat Mat::adjustROI(int dtop, int dbottom, int dleft, int dright)
210 JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1adjustROI
211 (JNIEnv* env, jclass, jlong self, jint dtop, jint dbottom, jint dleft, jint dright);
213 JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1adjustROI
214 (JNIEnv* env, jclass, jlong self, jint dtop, jint dbottom, jint dleft, jint dright)
216 static const char method_name[] = "Mat::n_1adjustROI()";
218 LOGD("%s", method_name);
219 Mat* me = (Mat*) self; //TODO: check for NULL
220 Mat _retval_ = me->adjustROI( dtop, dbottom, dleft, dright );
221 return (jlong) new Mat(_retval_);
222 } catch(const std::exception &e) {
223 throwJavaException(env, &e, method_name);
225 throwJavaException(env, 0, method_name);
234 // void Mat::assignTo(Mat m, int type = -1)
237 JNIEXPORT void JNICALL Java_org_opencv_core_Mat_n_1assignTo__JJI
238 (JNIEnv* env, jclass, jlong self, jlong m_nativeObj, jint type);
240 JNIEXPORT void JNICALL Java_org_opencv_core_Mat_n_1assignTo__JJI
241 (JNIEnv* env, jclass, jlong self, jlong m_nativeObj, jint type)
243 static const char method_name[] = "Mat::n_1assignTo__JJI()";
245 LOGD("%s", method_name);
246 Mat* me = (Mat*) self; //TODO: check for NULL
247 me->assignTo( (*(Mat*)m_nativeObj), type );
248 } catch(const std::exception &e) {
249 throwJavaException(env, &e, method_name);
251 throwJavaException(env, 0, method_name);
256 JNIEXPORT void JNICALL Java_org_opencv_core_Mat_n_1assignTo__JJ
257 (JNIEnv* env, jclass, jlong self, jlong m_nativeObj);
259 JNIEXPORT void JNICALL Java_org_opencv_core_Mat_n_1assignTo__JJ
260 (JNIEnv* env, jclass, jlong self, jlong m_nativeObj)
262 static const char method_name[] = "Mat::n_1assignTo__JJ()";
264 LOGD("%s", method_name);
265 Mat* me = (Mat*) self; //TODO: check for NULL
266 me->assignTo( (*(Mat*)m_nativeObj) );
267 } catch(const std::exception &e) {
268 throwJavaException(env, &e, method_name);
270 throwJavaException(env, 0, method_name);
277 // int Mat::channels()
280 JNIEXPORT jint JNICALL Java_org_opencv_core_Mat_n_1channels
281 (JNIEnv* env, jclass, jlong self);
283 JNIEXPORT jint JNICALL Java_org_opencv_core_Mat_n_1channels
284 (JNIEnv* env, jclass, jlong self)
286 static const char method_name[] = "Mat::n_1channels()";
288 LOGD("%s", method_name);
289 Mat* me = (Mat*) self; //TODO: check for NULL
290 return me->channels( );
291 } catch(const std::exception &e) {
292 throwJavaException(env, &e, method_name);
294 throwJavaException(env, 0, method_name);
303 // int Mat::checkVector(int elemChannels, int depth = -1, bool requireContinuous = true)
306 JNIEXPORT jint JNICALL Java_org_opencv_core_Mat_n_1checkVector__JIIZ
307 (JNIEnv* env, jclass, jlong self, jint elemChannels, jint depth, jboolean requireContinuous);
309 JNIEXPORT jint JNICALL Java_org_opencv_core_Mat_n_1checkVector__JIIZ
310 (JNIEnv* env, jclass, jlong self, jint elemChannels, jint depth, jboolean requireContinuous)
312 static const char method_name[] = "Mat::n_1checkVector__JIIZ()";
314 LOGD("%s", method_name);
315 Mat* me = (Mat*) self; //TODO: check for NULL
316 return me->checkVector( elemChannels, depth, requireContinuous );
317 } catch(const std::exception &e) {
318 throwJavaException(env, &e, method_name);
320 throwJavaException(env, 0, method_name);
328 JNIEXPORT jint JNICALL Java_org_opencv_core_Mat_n_1checkVector__JII
329 (JNIEnv* env, jclass, jlong self, jint elemChannels, jint depth);
331 JNIEXPORT jint JNICALL Java_org_opencv_core_Mat_n_1checkVector__JII
332 (JNIEnv* env, jclass, jlong self, jint elemChannels, jint depth)
334 static const char method_name[] = "Mat::n_1checkVector__JII()";
336 LOGD("%s", method_name);
337 Mat* me = (Mat*) self; //TODO: check for NULL
338 return me->checkVector( elemChannels, depth );
339 } catch(const std::exception &e) {
340 throwJavaException(env, &e, method_name);
342 throwJavaException(env, 0, method_name);
349 JNIEXPORT jint JNICALL Java_org_opencv_core_Mat_n_1checkVector__JI
350 (JNIEnv* env, jclass, jlong self, jint elemChannels);
353 JNIEXPORT jint JNICALL Java_org_opencv_core_Mat_n_1checkVector__JI
354 (JNIEnv* env, jclass, jlong self, jint elemChannels)
356 static const char method_name[] = "Mat::n_1checkVector__JI()";
358 LOGD("%s", method_name);
359 Mat* me = (Mat*) self; //TODO: check for NULL
360 return me->checkVector( elemChannels );
361 } catch(const std::exception &e) {
362 throwJavaException(env, &e, method_name);
364 throwJavaException(env, 0, method_name);
376 JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1clone
377 (JNIEnv* env, jclass, jlong self);
380 JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1clone
381 (JNIEnv* env, jclass, jlong self)
383 static const char method_name[] = "Mat::n_1clone()";
385 LOGD("%s", method_name);
386 Mat* me = (Mat*) self; //TODO: check for NULL
387 Mat _retval_ = me->clone( );
388 return (jlong) new Mat(_retval_);
389 } catch(const std::exception &e) {
390 throwJavaException(env, &e, method_name);
392 throwJavaException(env, 0, method_name);
401 // Mat Mat::col(int x)
404 JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1col
405 (JNIEnv* env, jclass, jlong self, jint x);
407 JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1col
408 (JNIEnv* env, jclass, jlong self, jint x)
410 static const char method_name[] = "Mat::n_1col()";
412 LOGD("%s", method_name);
413 Mat* me = (Mat*) self; //TODO: check for NULL
414 Mat _retval_ = me->col( x );
415 return (jlong) new Mat(_retval_);
416 } catch(const std::exception &e) {
417 throwJavaException(env, &e, method_name);
419 throwJavaException(env, 0, method_name);
428 // Mat Mat::colRange(int startcol, int endcol)
431 JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1colRange
432 (JNIEnv* env, jclass, jlong self, jint startcol, jint endcol);
434 JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1colRange
435 (JNIEnv* env, jclass, jlong self, jint startcol, jint endcol)
437 static const char method_name[] = "Mat::n_1colRange()";
439 LOGD("%s", method_name);
440 Mat* me = (Mat*) self; //TODO: check for NULL
441 Mat _retval_ = me->colRange( startcol, endcol );
442 return (jlong) new Mat(_retval_);
443 } catch(const std::exception &e) {
444 throwJavaException(env, &e, method_name);
446 throwJavaException(env, 0, method_name);
458 JNIEXPORT jint JNICALL Java_org_opencv_core_Mat_n_1dims
459 (JNIEnv* env, jclass, jlong self);
461 JNIEXPORT jint JNICALL Java_org_opencv_core_Mat_n_1dims
462 (JNIEnv* env, jclass, jlong self)
464 static const char method_name[] = "Mat::n_1dims()";
466 LOGD("%s", method_name);
467 Mat* me = (Mat*) self; //TODO: check for NULL
469 } catch(cv::Exception e) {
470 throwJavaException(env, &e, method_name);
472 throwJavaException(env, 0, method_name);
484 JNIEXPORT jint JNICALL Java_org_opencv_core_Mat_n_1cols
485 (JNIEnv* env, jclass, jlong self);
487 JNIEXPORT jint JNICALL Java_org_opencv_core_Mat_n_1cols
488 (JNIEnv* env, jclass, jlong self)
490 static const char method_name[] = "Mat::n_1cols()";
492 LOGD("%s", method_name);
493 Mat* me = (Mat*) self; //TODO: check for NULL
495 } catch(const std::exception &e) {
496 throwJavaException(env, &e, method_name);
498 throwJavaException(env, 0, method_name);
507 // void Mat::convertTo(Mat& m, int rtype, double alpha = 1, double beta = 0)
510 JNIEXPORT void JNICALL Java_org_opencv_core_Mat_n_1convertTo__JJIDD
511 (JNIEnv* env, jclass, jlong self, jlong m_nativeObj, jint rtype, jdouble alpha, jdouble beta);
513 JNIEXPORT void JNICALL Java_org_opencv_core_Mat_n_1convertTo__JJIDD
514 (JNIEnv* env, jclass, jlong self, jlong m_nativeObj, jint rtype, jdouble alpha, jdouble beta)
516 static const char method_name[] = "Mat::n_1convertTo__JJIDD()";
518 LOGD("%s", method_name);
519 Mat* me = (Mat*) self; //TODO: check for NULL
520 Mat& m = *((Mat*)m_nativeObj);
521 me->convertTo( m, rtype, alpha, beta );
522 } catch(const std::exception &e) {
523 throwJavaException(env, &e, method_name);
525 throwJavaException(env, 0, method_name);
530 JNIEXPORT void JNICALL Java_org_opencv_core_Mat_n_1convertTo__JJID
531 (JNIEnv* env, jclass, jlong self, jlong m_nativeObj, jint rtype, jdouble alpha);
533 JNIEXPORT void JNICALL Java_org_opencv_core_Mat_n_1convertTo__JJID
534 (JNIEnv* env, jclass, jlong self, jlong m_nativeObj, jint rtype, jdouble alpha)
536 static const char method_name[] = "Mat::n_1convertTo__JJID()";
538 LOGD("%s", method_name);
539 Mat* me = (Mat*) self; //TODO: check for NULL
540 Mat& m = *((Mat*)m_nativeObj);
541 me->convertTo( m, rtype, alpha );
542 } catch(const std::exception &e) {
543 throwJavaException(env, &e, method_name);
545 throwJavaException(env, 0, method_name);
550 JNIEXPORT void JNICALL Java_org_opencv_core_Mat_n_1convertTo__JJI
551 (JNIEnv* env, jclass, jlong self, jlong m_nativeObj, jint rtype);
553 JNIEXPORT void JNICALL Java_org_opencv_core_Mat_n_1convertTo__JJI
554 (JNIEnv* env, jclass, jlong self, jlong m_nativeObj, jint rtype)
556 static const char method_name[] = "Mat::n_1convertTo__JJI()";
558 LOGD("%s", method_name);
559 Mat* me = (Mat*) self; //TODO: check for NULL
560 Mat& m = *((Mat*)m_nativeObj);
561 me->convertTo( m, rtype );
562 } catch(const std::exception &e) {
563 throwJavaException(env, &e, method_name);
565 throwJavaException(env, 0, method_name);
572 // void Mat::copyTo(Mat& m)
575 JNIEXPORT void JNICALL Java_org_opencv_core_Mat_n_1copyTo__JJ
576 (JNIEnv* env, jclass, jlong self, jlong m_nativeObj);
578 JNIEXPORT void JNICALL Java_org_opencv_core_Mat_n_1copyTo__JJ
579 (JNIEnv* env, jclass, jlong self, jlong m_nativeObj)
581 static const char method_name[] = "Mat::n_1copyTo__JJ()";
583 LOGD("%s", method_name);
584 Mat* me = (Mat*) self; //TODO: check for NULL
585 Mat& m = *((Mat*)m_nativeObj);
587 } catch(const std::exception &e) {
588 throwJavaException(env, &e, method_name);
590 throwJavaException(env, 0, method_name);
597 // void Mat::copyTo(Mat& m, Mat mask)
600 JNIEXPORT void JNICALL Java_org_opencv_core_Mat_n_1copyTo__JJJ
601 (JNIEnv* env, jclass, jlong self, jlong m_nativeObj, jlong mask_nativeObj);
603 JNIEXPORT void JNICALL Java_org_opencv_core_Mat_n_1copyTo__JJJ
604 (JNIEnv* env, jclass, jlong self, jlong m_nativeObj, jlong mask_nativeObj)
606 static const char method_name[] = "Mat::n_1copyTo__JJJ()";
608 LOGD("%s", method_name);
609 Mat* me = (Mat*) self; //TODO: check for NULL
610 Mat& m = *((Mat*)m_nativeObj);
611 Mat& mask = *((Mat*)mask_nativeObj);
612 me->copyTo( m, mask );
613 } catch(const std::exception &e) {
614 throwJavaException(env, &e, method_name);
616 throwJavaException(env, 0, method_name);
623 // void Mat::create(int rows, int cols, int type)
626 JNIEXPORT void JNICALL Java_org_opencv_core_Mat_n_1create__JIII
627 (JNIEnv* env, jclass, jlong self, jint rows, jint cols, jint type);
629 JNIEXPORT void JNICALL Java_org_opencv_core_Mat_n_1create__JIII
630 (JNIEnv* env, jclass, jlong self, jint rows, jint cols, jint type)
632 static const char method_name[] = "Mat::n_1create__JIII()";
634 LOGD("%s", method_name);
635 Mat* me = (Mat*) self; //TODO: check for NULL
636 me->create( rows, cols, type );
637 } catch(const std::exception &e) {
638 throwJavaException(env, &e, method_name);
640 throwJavaException(env, 0, method_name);
647 // void Mat::create(Size size, int type)
650 JNIEXPORT void JNICALL Java_org_opencv_core_Mat_n_1create__JDDI
651 (JNIEnv* env, jclass, jlong self, jdouble size_width, jdouble size_height, jint type);
653 JNIEXPORT void JNICALL Java_org_opencv_core_Mat_n_1create__JDDI
654 (JNIEnv* env, jclass, jlong self, jdouble size_width, jdouble size_height, jint type)
656 static const char method_name[] = "Mat::n_1create__JDDI()";
658 LOGD("%s", method_name);
659 Mat* me = (Mat*) self; //TODO: check for NULL
660 Size size((int)size_width, (int)size_height);
661 me->create( size, type );
662 } catch(const std::exception &e) {
663 throwJavaException(env, &e, method_name);
665 throwJavaException(env, 0, method_name);
672 // Mat Mat::cross(Mat m)
675 JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1cross
676 (JNIEnv* env, jclass, jlong self, jlong m_nativeObj);
678 JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1cross
679 (JNIEnv* env, jclass, jlong self, jlong m_nativeObj)
681 static const char method_name[] = "Mat::n_1cross()";
683 LOGD("%s", method_name);
684 Mat* me = (Mat*) self; //TODO: check for NULL
685 Mat& m = *((Mat*)m_nativeObj);
686 Mat _retval_ = me->cross( m );
687 return (jlong) new Mat(_retval_);
688 } catch(const std::exception &e) {
689 throwJavaException(env, &e, method_name);
691 throwJavaException(env, 0, method_name);
700 // long Mat::dataAddr()
703 JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1dataAddr
704 (JNIEnv*, jclass, jlong self);
706 JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1dataAddr
707 (JNIEnv*, jclass, jlong self)
709 LOGD("Mat::n_1dataAddr()");
710 Mat* me = (Mat*) self; //TODO: check for NULL
711 return (jlong) me->data;
720 JNIEXPORT jint JNICALL Java_org_opencv_core_Mat_n_1depth
721 (JNIEnv* env, jclass, jlong self);
723 JNIEXPORT jint JNICALL Java_org_opencv_core_Mat_n_1depth
724 (JNIEnv* env, jclass, jlong self)
726 static const char method_name[] = "Mat::n_1depth()";
728 LOGD("%s", method_name);
729 Mat* me = (Mat*) self; //TODO: check for NULL
731 } catch(const std::exception &e) {
732 throwJavaException(env, &e, method_name);
734 throwJavaException(env, 0, method_name);
743 // Mat Mat::diag(int d = 0)
746 JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1diag__JI
747 (JNIEnv* env, jclass, jlong self, jint d);
749 JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1diag__JI
750 (JNIEnv* env, jclass, jlong self, jint d)
752 static const char method_name[] = "Mat::n_1diag__JI()";
754 LOGD("%s", method_name);
755 Mat* me = (Mat*) self; //TODO: check for NULL
756 Mat _retval_ = me->diag( d );
757 return (jlong) new Mat(_retval_);
758 } catch(const std::exception &e) {
759 throwJavaException(env, &e, method_name);
761 throwJavaException(env, 0, method_name);
771 // static Mat Mat::diag(Mat d)
774 JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1diag__J
775 (JNIEnv* env, jclass, jlong d_nativeObj);
777 JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1diag__J
778 (JNIEnv* env, jclass, jlong d_nativeObj)
780 static const char method_name[] = "Mat::n_1diag__J()";
782 LOGD("%s", method_name);
783 Mat _retval_ = Mat::diag( (*(Mat*)d_nativeObj) );
784 return (jlong) new Mat(_retval_);
785 } catch(const std::exception &e) {
786 throwJavaException(env, &e, method_name);
788 throwJavaException(env, 0, method_name);
797 // double Mat::dot(Mat m)
800 JNIEXPORT jdouble JNICALL Java_org_opencv_core_Mat_n_1dot
801 (JNIEnv* env, jclass, jlong self, jlong m_nativeObj);
803 JNIEXPORT jdouble JNICALL Java_org_opencv_core_Mat_n_1dot
804 (JNIEnv* env, jclass, jlong self, jlong m_nativeObj)
806 static const char method_name[] = "Mat::n_1dot()";
808 LOGD("%s", method_name);
809 Mat* me = (Mat*) self; //TODO: check for NULL
810 Mat& m = *((Mat*)m_nativeObj);
812 } catch(const std::exception &e) {
813 throwJavaException(env, &e, method_name);
815 throwJavaException(env, 0, method_name);
824 // size_t Mat::elemSize()
827 JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1elemSize
828 (JNIEnv* env, jclass, jlong self);
830 JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1elemSize
831 (JNIEnv* env, jclass, jlong self)
833 static const char method_name[] = "Mat::n_1elemSize()";
835 LOGD("%s", method_name);
836 Mat* me = (Mat*) self; //TODO: check for NULL
837 return me->elemSize( );
838 } catch(const std::exception &e) {
839 throwJavaException(env, &e, method_name);
841 throwJavaException(env, 0, method_name);
850 // size_t Mat::elemSize1()
853 JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1elemSize1
854 (JNIEnv* env, jclass, jlong self);
856 JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1elemSize1
857 (JNIEnv* env, jclass, jlong self)
859 static const char method_name[] = "Mat::n_1elemSize1()";
861 LOGD("%s", method_name);
862 Mat* me = (Mat*) self; //TODO: check for NULL
863 return me->elemSize1( );
864 } catch(const std::exception &e) {
865 throwJavaException(env, &e, method_name);
867 throwJavaException(env, 0, method_name);
879 JNIEXPORT jboolean JNICALL Java_org_opencv_core_Mat_n_1empty
880 (JNIEnv* env, jclass, jlong self);
882 JNIEXPORT jboolean JNICALL Java_org_opencv_core_Mat_n_1empty
883 (JNIEnv* env, jclass, jlong self)
885 static const char method_name[] = "Mat::n_1empty()";
887 LOGD("%s", method_name);
888 Mat* me = (Mat*) self; //TODO: check for NULL
890 } catch(const std::exception &e) {
891 throwJavaException(env, &e, method_name);
893 throwJavaException(env, 0, method_name);
902 // static Mat Mat::eye(int rows, int cols, int type)
905 JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1eye__III
906 (JNIEnv* env, jclass, jint rows, jint cols, jint type);
908 JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1eye__III
909 (JNIEnv* env, jclass, jint rows, jint cols, jint type)
911 static const char method_name[] = "Mat::n_1eye__III()";
913 LOGD("%s", method_name);
914 Mat _retval_ = Mat::eye( rows, cols, type );
915 return (jlong) new Mat(_retval_);
916 } catch(const std::exception &e) {
917 throwJavaException(env, &e, method_name);
919 throwJavaException(env, 0, method_name);
928 // static Mat Mat::eye(Size size, int type)
931 JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1eye__DDI
932 (JNIEnv* env, jclass, jdouble size_width, jdouble size_height, jint type);
934 JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1eye__DDI
935 (JNIEnv* env, jclass, jdouble size_width, jdouble size_height, jint type)
937 static const char method_name[] = "Mat::n_1eye__DDI()";
939 LOGD("%s", method_name);
940 Size size((int)size_width, (int)size_height);
941 Mat _retval_ = Mat::eye( size, type );
942 return (jlong) new Mat(_retval_);
943 } catch(const std::exception &e) {
944 throwJavaException(env, &e, method_name);
946 throwJavaException(env, 0, method_name);
955 // Mat Mat::inv(int method = DECOMP_LU)
958 JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1inv__JI
959 (JNIEnv* env, jclass, jlong self, jint method);
961 JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1inv__JI
962 (JNIEnv* env, jclass, jlong self, jint method)
964 static const char method_name[] = "Mat::n_1inv__JI()";
966 LOGD("%s", method_name);
967 Mat* me = (Mat*) self; //TODO: check for NULL
968 Mat _retval_ = me->inv( method );
969 return (jlong) new Mat(_retval_);
970 } catch(const std::exception &e) {
971 throwJavaException(env, &e, method_name);
973 throwJavaException(env, 0, method_name);
980 JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1inv__J
981 (JNIEnv* env, jclass, jlong self);
983 JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1inv__J
984 (JNIEnv* env, jclass, jlong self)
986 static const char method_name[] = "Mat::n_1inv__J()";
988 LOGD("%s", method_name);
989 Mat* me = (Mat*) self; //TODO: check for NULL
990 Mat _retval_ = me->inv( );
991 return (jlong) new Mat(_retval_);
992 } catch(const std::exception &e) {
993 throwJavaException(env, &e, method_name);
995 throwJavaException(env, 0, method_name);
1004 // bool Mat::isContinuous()
1007 JNIEXPORT jboolean JNICALL Java_org_opencv_core_Mat_n_1isContinuous
1008 (JNIEnv* env, jclass, jlong self);
1010 JNIEXPORT jboolean JNICALL Java_org_opencv_core_Mat_n_1isContinuous
1011 (JNIEnv* env, jclass, jlong self)
1013 static const char method_name[] = "Mat::n_1isContinuous()";
1015 LOGD("%s", method_name);
1016 Mat* me = (Mat*) self; //TODO: check for NULL
1017 return me->isContinuous( );
1018 } catch(const std::exception &e) {
1019 throwJavaException(env, &e, method_name);
1021 throwJavaException(env, 0, method_name);
1030 // bool Mat::isSubmatrix()
1033 JNIEXPORT jboolean JNICALL Java_org_opencv_core_Mat_n_1isSubmatrix
1034 (JNIEnv* env, jclass, jlong self);
1036 JNIEXPORT jboolean JNICALL Java_org_opencv_core_Mat_n_1isSubmatrix
1037 (JNIEnv* env, jclass, jlong self)
1039 static const char method_name[] = "Mat::n_1isSubmatrix()";
1041 LOGD("%s", method_name);
1042 Mat* me = (Mat*) self; //TODO: check for NULL
1043 return me->isSubmatrix( );
1044 } catch(const std::exception &e) {
1045 throwJavaException(env, &e, method_name);
1047 throwJavaException(env, 0, method_name);
1056 // void Mat::locateROI(Size wholeSize, Point ofs)
1059 JNIEXPORT void JNICALL Java_org_opencv_core_Mat_locateROI_10
1060 (JNIEnv* env, jclass, jlong self, jdoubleArray wholeSize_out, jdoubleArray ofs_out);
1062 JNIEXPORT void JNICALL Java_org_opencv_core_Mat_locateROI_10
1063 (JNIEnv* env, jclass, jlong self, jdoubleArray wholeSize_out, jdoubleArray ofs_out)
1065 static const char method_name[] = "core::locateROI_10()";
1067 LOGD("%s", method_name);
1068 Mat* me = (Mat*) self; //TODO: check for NULL
1071 me->locateROI( wholeSize, ofs );
1072 jdouble tmp_wholeSize[2] = {wholeSize.width, wholeSize.height}; env->SetDoubleArrayRegion(wholeSize_out, 0, 2, tmp_wholeSize); jdouble tmp_ofs[2] = {ofs.x, ofs.y}; env->SetDoubleArrayRegion(ofs_out, 0, 2, tmp_ofs);
1073 } catch(const std::exception &e) {
1074 throwJavaException(env, &e, method_name);
1076 throwJavaException(env, 0, method_name);
1083 // Mat Mat::mul(Mat m, double scale = 1)
1086 JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1mul__JJD
1087 (JNIEnv* env, jclass, jlong self, jlong m_nativeObj, jdouble scale);
1089 JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1mul__JJD
1090 (JNIEnv* env, jclass, jlong self, jlong m_nativeObj, jdouble scale)
1092 static const char method_name[] = "Mat::n_1mul__JJD()";
1094 LOGD("%s", method_name);
1095 Mat* me = (Mat*) self; //TODO: check for NULL
1096 Mat& m = *((Mat*)m_nativeObj);
1097 Mat _retval_ = me->mul( m, scale );
1098 return (jlong) new Mat(_retval_);
1099 } catch(const std::exception &e) {
1100 throwJavaException(env, &e, method_name);
1102 throwJavaException(env, 0, method_name);
1110 JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1mul__JJ
1111 (JNIEnv* env, jclass, jlong self, jlong m_nativeObj);
1113 JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1mul__JJ
1114 (JNIEnv* env, jclass, jlong self, jlong m_nativeObj)
1116 static const char method_name[] = "Mat::n_1mul__JJ()";
1118 LOGD("%s", method_name);
1119 Mat* me = (Mat*) self; //TODO: check for NULL
1120 Mat& m = *((Mat*)m_nativeObj);
1121 Mat _retval_ = me->mul( m );
1122 return (jlong) new Mat(_retval_);
1123 } catch(const std::exception &e) {
1124 throwJavaException(env, &e, method_name);
1126 throwJavaException(env, 0, method_name);
1135 // static Mat Mat::ones(int rows, int cols, int type)
1138 JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1ones__III
1139 (JNIEnv* env, jclass, jint rows, jint cols, jint type);
1141 JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1ones__III
1142 (JNIEnv* env, jclass, jint rows, jint cols, jint type)
1144 static const char method_name[] = "Mat::n_1ones__III()";
1146 LOGD("%s", method_name);
1147 Mat _retval_ = Mat::ones( rows, cols, type );
1148 return (jlong) new Mat(_retval_);
1149 } catch(const std::exception &e) {
1150 throwJavaException(env, &e, method_name);
1152 throwJavaException(env, 0, method_name);
1161 // static Mat Mat::ones(Size size, int type)
1164 JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1ones__DDI
1165 (JNIEnv* env, jclass, jdouble size_width, jdouble size_height, jint type);
1167 JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1ones__DDI
1168 (JNIEnv* env, jclass, jdouble size_width, jdouble size_height, jint type)
1170 static const char method_name[] = "Mat::n_1ones__DDI()";
1172 LOGD("%s", method_name);
1173 Size size((int)size_width, (int)size_height);
1174 Mat _retval_ = Mat::ones( size, type );
1175 return (jlong) new Mat(_retval_);
1176 } catch(const std::exception &e) {
1177 throwJavaException(env, &e, method_name);
1179 throwJavaException(env, 0, method_name);
1188 // void Mat::push_back(Mat m)
1191 JNIEXPORT void JNICALL Java_org_opencv_core_Mat_n_1push_1back
1192 (JNIEnv* env, jclass, jlong self, jlong m_nativeObj);
1194 JNIEXPORT void JNICALL Java_org_opencv_core_Mat_n_1push_1back
1195 (JNIEnv* env, jclass, jlong self, jlong m_nativeObj)
1197 static const char method_name[] = "Mat::n_1push_1back()";
1199 LOGD("%s", method_name);
1200 Mat* me = (Mat*) self; //TODO: check for NULL
1201 me->push_back( (*(Mat*)m_nativeObj) );
1202 } catch(const std::exception &e) {
1203 throwJavaException(env, &e, method_name);
1205 throwJavaException(env, 0, method_name);
1212 // void Mat::release()
1215 JNIEXPORT void JNICALL Java_org_opencv_core_Mat_n_1release
1216 (JNIEnv* env, jclass, jlong self);
1218 JNIEXPORT void JNICALL Java_org_opencv_core_Mat_n_1release
1219 (JNIEnv* env, jclass, jlong self)
1221 static const char method_name[] = "Mat::n_1release()";
1223 LOGD("%s", method_name);
1224 Mat* me = (Mat*) self; //TODO: check for NULL
1226 } catch(const std::exception &e) {
1227 throwJavaException(env, &e, method_name);
1229 throwJavaException(env, 0, method_name);
1236 // Mat Mat::reshape(int cn, int rows = 0)
1239 JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1reshape__JII
1240 (JNIEnv* env, jclass, jlong self, jint cn, jint rows);
1242 JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1reshape__JII
1243 (JNIEnv* env, jclass, jlong self, jint cn, jint rows)
1245 static const char method_name[] = "Mat::n_1reshape__JII()";
1247 LOGD("%s", method_name);
1248 Mat* me = (Mat*) self; //TODO: check for NULL
1249 Mat _retval_ = me->reshape( cn, rows );
1250 return (jlong) new Mat(_retval_);
1251 } catch(const std::exception &e) {
1252 throwJavaException(env, &e, method_name);
1254 throwJavaException(env, 0, method_name);
1262 JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1reshape__JI
1263 (JNIEnv* env, jclass, jlong self, jint cn);
1265 JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1reshape__JI
1266 (JNIEnv* env, jclass, jlong self, jint cn)
1268 static const char method_name[] = "Mat::n_1reshape__JI()";
1270 LOGD("%s", method_name);
1271 Mat* me = (Mat*) self; //TODO: check for NULL
1272 Mat _retval_ = me->reshape( cn );
1273 return (jlong) new Mat(_retval_);
1274 } catch(const std::exception &e) {
1275 throwJavaException(env, &e, method_name);
1277 throwJavaException(env, 0, method_name);
1286 // Mat Mat::row(int y)
1289 JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1row
1290 (JNIEnv* env, jclass, jlong self, jint y);
1292 JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1row
1293 (JNIEnv* env, jclass, jlong self, jint y)
1295 static const char method_name[] = "Mat::n_1row()";
1297 LOGD("%s", method_name);
1298 Mat* me = (Mat*) self; //TODO: check for NULL
1299 Mat _retval_ = me->row( y );
1300 return (jlong) new Mat(_retval_);
1301 } catch(const std::exception &e) {
1302 throwJavaException(env, &e, method_name);
1304 throwJavaException(env, 0, method_name);
1313 // Mat Mat::rowRange(int startrow, int endrow)
1316 JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1rowRange
1317 (JNIEnv* env, jclass, jlong self, jint startrow, jint endrow);
1319 JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1rowRange
1320 (JNIEnv* env, jclass, jlong self, jint startrow, jint endrow)
1322 static const char method_name[] = "Mat::n_1rowRange()";
1324 LOGD("%s", method_name);
1325 Mat* me = (Mat*) self; //TODO: check for NULL
1326 Mat _retval_ = me->rowRange( startrow, endrow );
1327 return (jlong) new Mat(_retval_);
1328 } catch(const std::exception &e) {
1329 throwJavaException(env, &e, method_name);
1331 throwJavaException(env, 0, method_name);
1343 JNIEXPORT jint JNICALL Java_org_opencv_core_Mat_n_1rows
1344 (JNIEnv* env, jclass, jlong self);
1346 JNIEXPORT jint JNICALL Java_org_opencv_core_Mat_n_1rows
1347 (JNIEnv* env, jclass, jlong self)
1349 static const char method_name[] = "Mat::n_1rows()";
1351 LOGD("%s", method_name);
1352 Mat* me = (Mat*) self; //TODO: check for NULL
1354 } catch(const std::exception &e) {
1355 throwJavaException(env, &e, method_name);
1357 throwJavaException(env, 0, method_name);
1366 // Mat Mat::operator =(Scalar s)
1369 JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1setTo__JDDDD
1370 (JNIEnv* env, jclass, jlong self, jdouble s_val0, jdouble s_val1, jdouble s_val2, jdouble s_val3);
1372 JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1setTo__JDDDD
1373 (JNIEnv* env, jclass, jlong self, jdouble s_val0, jdouble s_val1, jdouble s_val2, jdouble s_val3)
1375 static const char method_name[] = "Mat::n_1setTo__JDDDD()";
1377 LOGD("%s", method_name);
1378 Mat* me = (Mat*) self; //TODO: check for NULL
1379 Scalar s(s_val0, s_val1, s_val2, s_val3);
1380 Mat _retval_ = me->operator =( s );
1381 return (jlong) new Mat(_retval_);
1382 } catch(const std::exception &e) {
1383 throwJavaException(env, &e, method_name);
1385 throwJavaException(env, 0, method_name);
1394 // Mat Mat::setTo(Scalar value, Mat mask = Mat())
1397 JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1setTo__JDDDDJ
1398 (JNIEnv* env, jclass, jlong self, jdouble s_val0, jdouble s_val1, jdouble s_val2, jdouble s_val3, jlong mask_nativeObj);
1400 JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1setTo__JDDDDJ
1401 (JNIEnv* env, jclass, jlong self, jdouble s_val0, jdouble s_val1, jdouble s_val2, jdouble s_val3, jlong mask_nativeObj)
1403 static const char method_name[] = "Mat::n_1setTo__JDDDDJ()";
1405 LOGD("%s", method_name);
1406 Mat* me = (Mat*) self; //TODO: check for NULL
1407 Scalar s(s_val0, s_val1, s_val2, s_val3);
1408 Mat& mask = *((Mat*)mask_nativeObj);
1409 Mat _retval_ = me->setTo( s, mask );
1410 return (jlong) new Mat(_retval_);
1411 } catch(const std::exception &e) {
1412 throwJavaException(env, &e, method_name);
1414 throwJavaException(env, 0, method_name);
1423 // Mat Mat::setTo(Mat value, Mat mask = Mat())
1426 JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1setTo__JJJ
1427 (JNIEnv* env, jclass, jlong self, jlong value_nativeObj, jlong mask_nativeObj);
1429 JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1setTo__JJJ
1430 (JNIEnv* env, jclass, jlong self, jlong value_nativeObj, jlong mask_nativeObj)
1432 static const char method_name[] = "Mat::n_1setTo__JJJ()";
1434 LOGD("%s", method_name);
1435 Mat* me = (Mat*) self; //TODO: check for NULL
1436 Mat& value = *((Mat*)value_nativeObj);
1437 Mat& mask = *((Mat*)mask_nativeObj);
1438 Mat _retval_ = me->setTo( value, mask );
1439 return (jlong) new Mat(_retval_);
1440 } catch(const std::exception &e) {
1441 throwJavaException(env, &e, method_name);
1443 throwJavaException(env, 0, method_name);
1451 JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1setTo__JJ
1452 (JNIEnv* env, jclass, jlong self, jlong value_nativeObj);
1454 JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1setTo__JJ
1455 (JNIEnv* env, jclass, jlong self, jlong value_nativeObj)
1457 static const char method_name[] = "Mat::n_1setTo__JJ()";
1459 LOGD("%s", method_name);
1460 Mat* me = (Mat*) self; //TODO: check for NULL
1461 Mat& value = *((Mat*)value_nativeObj);
1462 Mat _retval_ = me->setTo( value );
1463 return (jlong) new Mat(_retval_);
1464 } catch(const std::exception &e) {
1465 throwJavaException(env, &e, method_name);
1467 throwJavaException(env, 0, method_name);
1479 JNIEXPORT jdoubleArray JNICALL Java_org_opencv_core_Mat_n_1size
1480 (JNIEnv* env, jclass, jlong self);
1482 JNIEXPORT jdoubleArray JNICALL Java_org_opencv_core_Mat_n_1size
1483 (JNIEnv* env, jclass, jlong self)
1485 static const char method_name[] = "Mat::n_1size()";
1487 LOGD("%s", method_name);
1488 Mat* me = (Mat*) self; //TODO: check for NULL
1489 Size _retval_ = me->size( );
1490 jdoubleArray _da_retval_ = env->NewDoubleArray(2);
1491 jdouble _tmp_retval_[2] = {_retval_.width, _retval_.height};
1492 env->SetDoubleArrayRegion(_da_retval_, 0, 2, _tmp_retval_);
1494 } catch(const std::exception &e) {
1495 throwJavaException(env, &e, method_name);
1497 throwJavaException(env, 0, method_name);
1506 // size_t Mat::step1(int i = 0)
1509 JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1step1__JI
1510 (JNIEnv* env, jclass, jlong self, jint i);
1512 JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1step1__JI
1513 (JNIEnv* env, jclass, jlong self, jint i)
1515 static const char method_name[] = "Mat::n_1step1__JI()";
1517 LOGD("%s", method_name);
1518 Mat* me = (Mat*) self; //TODO: check for NULL
1519 return me->step1( i );
1520 } catch(const std::exception &e) {
1521 throwJavaException(env, &e, method_name);
1523 throwJavaException(env, 0, method_name);
1531 JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1step1__J
1532 (JNIEnv* env, jclass, jlong self);
1534 JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1step1__J
1535 (JNIEnv* env, jclass, jlong self)
1537 static const char method_name[] = "Mat::n_1step1__J()";
1539 LOGD("%s", method_name);
1540 Mat* me = (Mat*) self; //TODO: check for NULL
1541 return me->step1( );
1542 } catch(const std::exception &e) {
1543 throwJavaException(env, &e, method_name);
1545 throwJavaException(env, 0, method_name);
1552 // Mat Mat::operator()(Range rowRange, Range colRange)
1555 JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1submat_1rr
1556 (JNIEnv* env, jclass, jlong self, jint rowRange_start, jint rowRange_end, jint colRange_start, jint colRange_end);
1558 JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1submat_1rr
1559 (JNIEnv* env, jclass, jlong self, jint rowRange_start, jint rowRange_end, jint colRange_start, jint colRange_end)
1561 static const char method_name[] = "Mat::n_1submat_1rr()";
1563 LOGD("%s", method_name);
1564 Mat* me = (Mat*) self; //TODO: check for NULL
1565 Range rowRange(rowRange_start, rowRange_end);
1566 Range colRange(colRange_start, colRange_end);
1567 Mat _retval_ = me->operator()( rowRange, colRange );
1568 return (jlong) new Mat(_retval_);
1569 } catch(const std::exception &e) {
1570 throwJavaException(env, &e, method_name);
1572 throwJavaException(env, 0, method_name);
1581 // Mat Mat::operator()(Rect roi)
1584 JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1submat
1585 (JNIEnv* env, jclass, jlong self, jint roi_x, jint roi_y, jint roi_width, jint roi_height);
1587 JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1submat
1588 (JNIEnv* env, jclass, jlong self, jint roi_x, jint roi_y, jint roi_width, jint roi_height)
1590 static const char method_name[] = "Mat::n_1submat()";
1592 LOGD("%s", method_name);
1593 Mat* me = (Mat*) self; //TODO: check for NULL
1594 Rect roi(roi_x, roi_y, roi_width, roi_height);
1595 Mat _retval_ = me->operator()( roi );
1596 return (jlong) new Mat(_retval_);
1597 } catch(const std::exception &e) {
1598 throwJavaException(env, &e, method_name);
1600 throwJavaException(env, 0, method_name);
1612 JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1t
1613 (JNIEnv* env, jclass, jlong self);
1615 JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1t
1616 (JNIEnv* env, jclass, jlong self)
1618 static const char method_name[] = "Mat::n_1t()";
1620 LOGD("%s", method_name);
1621 Mat* me = (Mat*) self; //TODO: check for NULL
1622 Mat _retval_ = me->t( );
1623 return (jlong) new Mat(_retval_);
1624 } catch(const std::exception &e) {
1625 throwJavaException(env, &e, method_name);
1627 throwJavaException(env, 0, method_name);
1636 // size_t Mat::total()
1639 JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1total
1640 (JNIEnv* env, jclass, jlong self);
1642 JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1total
1643 (JNIEnv* env, jclass, jlong self)
1645 static const char method_name[] = "Mat::n_1total()";
1647 LOGD("%s", method_name);
1648 Mat* me = (Mat*) self; //TODO: check for NULL
1649 return me->total( );
1650 } catch(const std::exception &e) {
1651 throwJavaException(env, &e, method_name);
1653 throwJavaException(env, 0, method_name);
1665 JNIEXPORT jint JNICALL Java_org_opencv_core_Mat_n_1type
1666 (JNIEnv* env, jclass, jlong self);
1668 JNIEXPORT jint JNICALL Java_org_opencv_core_Mat_n_1type
1669 (JNIEnv* env, jclass, jlong self)
1671 static const char method_name[] = "Mat::n_1type()";
1673 LOGD("%s", method_name);
1674 Mat* me = (Mat*) self; //TODO: check for NULL
1676 } catch(const std::exception &e) {
1677 throwJavaException(env, &e, method_name);
1679 throwJavaException(env, 0, method_name);
1688 // static Mat Mat::zeros(int rows, int cols, int type)
1691 JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1zeros__III
1692 (JNIEnv* env, jclass, jint rows, jint cols, jint type);
1694 JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1zeros__III
1695 (JNIEnv* env, jclass, jint rows, jint cols, jint type)
1697 static const char method_name[] = "Mat::n_1zeros__III()";
1699 LOGD("%s", method_name);
1700 Mat _retval_ = Mat::zeros( rows, cols, type );
1701 return (jlong) new Mat(_retval_);
1702 } catch(const std::exception &e) {
1703 throwJavaException(env, &e, method_name);
1705 throwJavaException(env, 0, method_name);
1714 // static Mat Mat::zeros(Size size, int type)
1717 JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1zeros__DDI
1718 (JNIEnv* env, jclass, jdouble size_width, jdouble size_height, jint type);
1720 JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1zeros__DDI
1721 (JNIEnv* env, jclass, jdouble size_width, jdouble size_height, jint type)
1723 static const char method_name[] = "Mat::n_1zeros__DDI()";
1725 LOGD("%s", method_name);
1726 Size size((int)size_width, (int)size_height);
1727 Mat _retval_ = Mat::zeros( size, type );
1728 return (jlong) new Mat(_retval_);
1729 } catch(const std::exception &e) {
1730 throwJavaException(env, &e, method_name);
1732 throwJavaException(env, 0, method_name);
1741 // native support for java finalize()
1742 // static void Mat::n_delete( __int64 self )
1745 JNIEXPORT void JNICALL Java_org_opencv_core_Mat_n_1delete
1746 (JNIEnv*, jclass, jlong self);
1748 JNIEXPORT void JNICALL Java_org_opencv_core_Mat_n_1delete
1749 (JNIEnv*, jclass, jlong self)
1754 // unlike other nPut()-s this one (with double[]) should convert input values to correct type
1755 #define PUT_ITEM(T, R, C) { T*dst = (T*)me->ptr(R, C); for(int ch=0; ch<me->channels() && count>0; count--,ch++,src++,dst++) *dst = cv::saturate_cast<T>(*src); }
1757 JNIEXPORT jint JNICALL Java_org_opencv_core_Mat_nPutD
1758 (JNIEnv* env, jclass, jlong self, jint row, jint col, jint count, jdoubleArray vals);
1760 JNIEXPORT jint JNICALL Java_org_opencv_core_Mat_nPutD
1761 (JNIEnv* env, jclass, jlong self, jint row, jint col, jint count, jdoubleArray vals)
1763 static const char method_name[] = "Mat::nPutD()";
1765 LOGD("%s", method_name);
1766 cv::Mat* me = (cv::Mat*) self;
1767 if(!me || !me->data) return 0; // no native object behind
1768 if(me->rows<=row || me->cols<=col) return 0; // indexes out of range
1770 int rest = ((me->rows - row) * me->cols - col) * me->channels();
1771 if(count>rest) count = rest;
1773 double* values = (double*)env->GetPrimitiveArrayCritical(vals, 0);
1774 double* src = values;
1776 for(c=col; c<me->cols && count>0; c++)
1778 switch(me->depth()) {
1779 case CV_8U: PUT_ITEM(uchar, row, c); break;
1780 case CV_8S: PUT_ITEM(schar, row, c); break;
1781 case CV_16U: PUT_ITEM(ushort, row, c); break;
1782 case CV_16S: PUT_ITEM(short, row, c); break;
1783 case CV_32S: PUT_ITEM(int, row, c); break;
1784 case CV_32F: PUT_ITEM(float, row, c); break;
1785 case CV_64F: PUT_ITEM(double, row, c); break;
1789 for(r=row+1; r<me->rows && count>0; r++)
1790 for(c=0; c<me->cols && count>0; c++)
1792 switch(me->depth()) {
1793 case CV_8U: PUT_ITEM(uchar, r, c); break;
1794 case CV_8S: PUT_ITEM(schar, r, c); break;
1795 case CV_16U: PUT_ITEM(ushort, r, c); break;
1796 case CV_16S: PUT_ITEM(short, r, c); break;
1797 case CV_32S: PUT_ITEM(int, r, c); break;
1798 case CV_32F: PUT_ITEM(float, r, c); break;
1799 case CV_64F: PUT_ITEM(double, r, c); break;
1803 env->ReleasePrimitiveArrayCritical(vals, values, 0);
1805 } catch(const std::exception &e) {
1806 throwJavaException(env, &e, method_name);
1808 throwJavaException(env, 0, method_name);
1817 template<typename T> static int mat_put(cv::Mat* m, int row, int col, int count, char* buff)
1820 if(! buff) return 0;
1823 int rest = ((m->rows - row) * m->cols - col) * (int)m->elemSize();
1824 if(count>rest) count = rest;
1827 if( m->isContinuous() )
1829 memcpy(m->ptr(row, col), buff, count);
1832 int num = (m->cols - col) * (int)m->elemSize(); // 1st partial row
1833 if(count<num) num = count;
1834 uchar* data = m->ptr(row++, col);
1836 memcpy(data, buff, num);
1839 num = m->cols * (int)m->elemSize();
1840 if(count<num) num = count;
1841 data = m->ptr(row++, 0);
1850 JNIEXPORT jint JNICALL Java_org_opencv_core_Mat_nPutB
1851 (JNIEnv* env, jclass, jlong self, jint row, jint col, jint count, jbyteArray vals);
1853 JNIEXPORT jint JNICALL Java_org_opencv_core_Mat_nPutB
1854 (JNIEnv* env, jclass, jlong self, jint row, jint col, jint count, jbyteArray vals)
1856 static const char method_name[] = "Mat::nPutB()";
1858 LOGD("%s", method_name);
1859 cv::Mat* me = (cv::Mat*) self;
1860 if(! self) return 0; // no native object behind
1861 if(me->depth() != CV_8U && me->depth() != CV_8S) return 0; // incompatible type
1862 if(me->rows<=row || me->cols<=col) return 0; // indexes out of range
1864 char* values = (char*)env->GetPrimitiveArrayCritical(vals, 0);
1865 int res = mat_put<char>(me, row, col, count, values);
1866 env->ReleasePrimitiveArrayCritical(vals, values, 0);
1868 } catch(const std::exception &e) {
1869 throwJavaException(env, &e, method_name);
1871 throwJavaException(env, 0, method_name);
1877 JNIEXPORT jint JNICALL Java_org_opencv_core_Mat_nPutS
1878 (JNIEnv* env, jclass, jlong self, jint row, jint col, jint count, jshortArray vals);
1880 JNIEXPORT jint JNICALL Java_org_opencv_core_Mat_nPutS
1881 (JNIEnv* env, jclass, jlong self, jint row, jint col, jint count, jshortArray vals)
1883 static const char method_name[] = "Mat::nPutS()";
1885 LOGD("%s", method_name);
1886 cv::Mat* me = (cv::Mat*) self;
1887 if(! self) return 0; // no native object behind
1888 if(me->depth() != CV_16U && me->depth() != CV_16S) return 0; // incompatible type
1889 if(me->rows<=row || me->cols<=col) return 0; // indexes out of range
1891 char* values = (char*)env->GetPrimitiveArrayCritical(vals, 0);
1892 int res = mat_put<short>(me, row, col, count, values);
1893 env->ReleasePrimitiveArrayCritical(vals, values, 0);
1895 } catch(const std::exception &e) {
1896 throwJavaException(env, &e, method_name);
1898 throwJavaException(env, 0, method_name);
1904 JNIEXPORT jint JNICALL Java_org_opencv_core_Mat_nPutI
1905 (JNIEnv* env, jclass, jlong self, jint row, jint col, jint count, jintArray vals);
1907 JNIEXPORT jint JNICALL Java_org_opencv_core_Mat_nPutI
1908 (JNIEnv* env, jclass, jlong self, jint row, jint col, jint count, jintArray vals)
1910 static const char method_name[] = "Mat::nPutI()";
1912 LOGD("%s", method_name);
1913 cv::Mat* me = (cv::Mat*) self;
1914 if(! self) return 0; // no native object behind
1915 if(me->depth() != CV_32S) return 0; // incompatible type
1916 if(me->rows<=row || me->cols<=col) return 0; // indexes out of range
1918 char* values = (char*)env->GetPrimitiveArrayCritical(vals, 0);
1919 int res = mat_put<int>(me, row, col, count, values);
1920 env->ReleasePrimitiveArrayCritical(vals, values, 0);
1922 } catch(const std::exception &e) {
1923 throwJavaException(env, &e, method_name);
1925 throwJavaException(env, 0, method_name);
1931 JNIEXPORT jint JNICALL Java_org_opencv_core_Mat_nPutF
1932 (JNIEnv* env, jclass, jlong self, jint row, jint col, jint count, jfloatArray vals);
1934 JNIEXPORT jint JNICALL Java_org_opencv_core_Mat_nPutF
1935 (JNIEnv* env, jclass, jlong self, jint row, jint col, jint count, jfloatArray vals)
1937 static const char method_name[] = "Mat::nPutF()";
1939 LOGD("%s", method_name);
1940 cv::Mat* me = (cv::Mat*) self;
1941 if(! self) return 0; // no native object behind
1942 if(me->depth() != CV_32F) return 0; // incompatible type
1943 if(me->rows<=row || me->cols<=col) return 0; // indexes out of range
1945 char* values = (char*)env->GetPrimitiveArrayCritical(vals, 0);
1946 int res = mat_put<float>(me, row, col, count, values);
1947 env->ReleasePrimitiveArrayCritical(vals, values, 0);
1949 } catch(const std::exception &e) {
1950 throwJavaException(env, &e, method_name);
1952 throwJavaException(env, 0, method_name);
1961 template<typename T> int mat_get(cv::Mat* m, int row, int col, int count, char* buff)
1964 if(! buff) return 0;
1966 int bytesToCopy = count * sizeof(T);
1967 int bytesRestInMat = ((m->rows - row) * m->cols - col) * (int)m->elemSize();
1968 if(bytesToCopy > bytesRestInMat) bytesToCopy = bytesRestInMat;
1969 int res = bytesToCopy;
1971 if( m->isContinuous() )
1973 memcpy(buff, m->ptr(row, col), bytesToCopy);
1976 int bytesInRow = (m->cols - col) * (int)m->elemSize(); // 1st partial row
1977 while(bytesToCopy > 0)
1979 int len = std::min(bytesToCopy, bytesInRow);
1980 memcpy(buff, m->ptr(row, col), len);
1985 bytesInRow = m->cols * (int)m->elemSize();
1993 JNIEXPORT jint JNICALL Java_org_opencv_core_Mat_nGetB
1994 (JNIEnv* env, jclass, jlong self, jint row, jint col, jint count, jbyteArray vals);
1996 JNIEXPORT jint JNICALL Java_org_opencv_core_Mat_nGetB
1997 (JNIEnv* env, jclass, jlong self, jint row, jint col, jint count, jbyteArray vals)
1999 static const char method_name[] = "Mat::nGetB()";
2001 LOGD("%s", method_name);
2002 cv::Mat* me = (cv::Mat*) self;
2003 if(! self) return 0; // no native object behind
2004 if(me->depth() != CV_8U && me->depth() != CV_8S) return 0; // incompatible type
2005 if(me->rows<=row || me->cols<=col) return 0; // indexes out of range
2007 char* values = (char*)env->GetPrimitiveArrayCritical(vals, 0);
2008 int res = mat_get<char>(me, row, col, count, values);
2009 env->ReleasePrimitiveArrayCritical(vals, values, 0);
2011 } catch(const std::exception &e) {
2012 throwJavaException(env, &e, method_name);
2014 throwJavaException(env, 0, method_name);
2020 JNIEXPORT jint JNICALL Java_org_opencv_core_Mat_nGetS
2021 (JNIEnv* env, jclass, jlong self, jint row, jint col, jint count, jshortArray vals);
2023 JNIEXPORT jint JNICALL Java_org_opencv_core_Mat_nGetS
2024 (JNIEnv* env, jclass, jlong self, jint row, jint col, jint count, jshortArray vals)
2026 static const char method_name[] = "Mat::nGetS()";
2028 LOGD("%s", method_name);
2029 cv::Mat* me = (cv::Mat*) self;
2030 if(! self) return 0; // no native object behind
2031 if(me->depth() != CV_16U && me->depth() != CV_16S) return 0; // incompatible type
2032 if(me->rows<=row || me->cols<=col) return 0; // indexes out of range
2034 char* values = (char*)env->GetPrimitiveArrayCritical(vals, 0);
2035 int res = mat_get<short>(me, row, col, count, values);
2036 env->ReleasePrimitiveArrayCritical(vals, values, 0);
2038 } catch(const std::exception &e) {
2039 throwJavaException(env, &e, method_name);
2041 throwJavaException(env, 0, method_name);
2047 JNIEXPORT jint JNICALL Java_org_opencv_core_Mat_nGetI
2048 (JNIEnv* env, jclass, jlong self, jint row, jint col, jint count, jintArray vals);
2050 JNIEXPORT jint JNICALL Java_org_opencv_core_Mat_nGetI
2051 (JNIEnv* env, jclass, jlong self, jint row, jint col, jint count, jintArray vals)
2053 static const char method_name[] = "Mat::nGetI()";
2055 LOGD("%s", method_name);
2056 cv::Mat* me = (cv::Mat*) self;
2057 if(! self) return 0; // no native object behind
2058 if(me->depth() != CV_32S) return 0; // incompatible type
2059 if(me->rows<=row || me->cols<=col) return 0; // indexes out of range
2061 char* values = (char*)env->GetPrimitiveArrayCritical(vals, 0);
2062 int res = mat_get<int>(me, row, col, count, values);
2063 env->ReleasePrimitiveArrayCritical(vals, values, 0);
2065 } catch(const std::exception &e) {
2066 throwJavaException(env, &e, method_name);
2068 throwJavaException(env, 0, method_name);
2074 JNIEXPORT jint JNICALL Java_org_opencv_core_Mat_nGetF
2075 (JNIEnv* env, jclass, jlong self, jint row, jint col, jint count, jfloatArray vals);
2077 JNIEXPORT jint JNICALL Java_org_opencv_core_Mat_nGetF
2078 (JNIEnv* env, jclass, jlong self, jint row, jint col, jint count, jfloatArray vals)
2080 static const char method_name[] = "Mat::nGetF()";
2082 LOGD("%s", method_name);
2083 cv::Mat* me = (cv::Mat*) self;
2084 if(! self) return 0; // no native object behind
2085 if(me->depth() != CV_32F) return 0; // incompatible type
2086 if(me->rows<=row || me->cols<=col) return 0; // indexes out of range
2088 char* values = (char*)env->GetPrimitiveArrayCritical(vals, 0);
2089 int res = mat_get<float>(me, row, col, count, values);
2090 env->ReleasePrimitiveArrayCritical(vals, values, 0);
2092 } catch(const std::exception &e) {
2093 throwJavaException(env, &e, method_name);
2095 throwJavaException(env, 0, method_name);
2101 JNIEXPORT jint JNICALL Java_org_opencv_core_Mat_nGetD
2102 (JNIEnv* env, jclass, jlong self, jint row, jint col, jint count, jdoubleArray vals);
2104 JNIEXPORT jint JNICALL Java_org_opencv_core_Mat_nGetD
2105 (JNIEnv* env, jclass, jlong self, jint row, jint col, jint count, jdoubleArray vals)
2107 static const char method_name[] = "Mat::nGetD()";
2109 LOGD("%s", method_name);
2110 cv::Mat* me = (cv::Mat*) self;
2111 if(! self) return 0; // no native object behind
2112 if(me->depth() != CV_64F) return 0; // incompatible type
2113 if(me->rows<=row || me->cols<=col) return 0; // indexes out of range
2115 char* values = (char*)env->GetPrimitiveArrayCritical(vals, 0);
2116 int res = mat_get<double>(me, row, col, count, values);
2117 env->ReleasePrimitiveArrayCritical(vals, values, 0);
2119 } catch(const std::exception &e) {
2120 throwJavaException(env, &e, method_name);
2122 throwJavaException(env, 0, method_name);
2128 JNIEXPORT jdoubleArray JNICALL Java_org_opencv_core_Mat_nGet
2129 (JNIEnv* env, jclass, jlong self, jint row, jint col);
2131 JNIEXPORT jdoubleArray JNICALL Java_org_opencv_core_Mat_nGet
2132 (JNIEnv* env, jclass, jlong self, jint row, jint col)
2134 static const char method_name[] = "Mat::nGet()";
2136 LOGD("%s", method_name);
2137 cv::Mat* me = (cv::Mat*) self;
2138 if(! self) return 0; // no native object behind
2139 if(me->rows<=row || me->cols<=col) return 0; // indexes out of range
2141 jdoubleArray res = env->NewDoubleArray(me->channels());
2143 jdouble buff[CV_CN_MAX];//me->channels()
2145 switch(me->depth()){
2146 case CV_8U: for(i=0; i<me->channels(); i++) buff[i] = *((unsigned char*) me->ptr(row, col) + i); break;
2147 case CV_8S: for(i=0; i<me->channels(); i++) buff[i] = *((signed char*) me->ptr(row, col) + i); break;
2148 case CV_16U: for(i=0; i<me->channels(); i++) buff[i] = *((unsigned short*)me->ptr(row, col) + i); break;
2149 case CV_16S: for(i=0; i<me->channels(); i++) buff[i] = *((signed short*) me->ptr(row, col) + i); break;
2150 case CV_32S: for(i=0; i<me->channels(); i++) buff[i] = *((int*) me->ptr(row, col) + i); break;
2151 case CV_32F: for(i=0; i<me->channels(); i++) buff[i] = *((float*) me->ptr(row, col) + i); break;
2152 case CV_64F: for(i=0; i<me->channels(); i++) buff[i] = *((double*) me->ptr(row, col) + i); break;
2154 env->SetDoubleArrayRegion(res, 0, me->channels(), buff);
2157 } catch(const std::exception &e) {
2158 throwJavaException(env, &e, method_name);
2160 throwJavaException(env, 0, method_name);
2166 JNIEXPORT jstring JNICALL Java_org_opencv_core_Mat_nDump
2167 (JNIEnv *env, jclass, jlong self);
2169 JNIEXPORT jstring JNICALL Java_org_opencv_core_Mat_nDump
2170 (JNIEnv *env, jclass, jlong self)
2172 static const char method_name[] = "Mat::nDump()";
2174 LOGD("%s", method_name);
2175 cv::Mat* me = (cv::Mat*) self; //TODO: check for NULL
2176 std::stringstream s;
2178 std::string str = s.str();
2179 return env->NewStringUTF(str.c_str());
2180 } catch(const std::exception &e) {
2181 throwJavaException(env, &e, method_name);
2183 throwJavaException(env, 0, method_name);