android: use .getRowStride() in JavaCamera2View

This commit is contained in:
Alexander Alekhin
2019-10-27 11:14:17 +00:00
parent d8ab83600b
commit 80c4cedd25
4 changed files with 90 additions and 14 deletions
+27 -1
View File
@@ -74,7 +74,7 @@ JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1Mat__IIILjava_nio_ByteBuffer
JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1Mat__IIILjava_nio_ByteBuffer_2
(JNIEnv* env, jclass, jint rows, jint cols, jint type, jobject data)
{
static const char method_name[] = "Mat::n_1Mat__IIILByteBuffer()";
static const char method_name[] = "Mat::n_1Mat__IIILjava_nio_ByteBuffer_2()";
try {
LOGD("%s", method_name);
return (jlong) new Mat( rows, cols, type, (void*)env->GetDirectBufferAddress(data) );
@@ -88,6 +88,32 @@ JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1Mat__IIILjava_nio_ByteBuffer
}
/*
* Class: org_opencv_core_Mat
* Method: n_Mat
* Signature: (IIILjava/nio/ByteBuffer;J)J
*
* Mat::Mat(int rows, int cols, int type, void* data, size_t step)
*/
JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1Mat__IIILjava_nio_ByteBuffer_2J
(JNIEnv* env, jclass, jint rows, jint cols, jint type, jobject data, jlong step);
JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1Mat__IIILjava_nio_ByteBuffer_2J
(JNIEnv* env, jclass, jint rows, jint cols, jint type, jobject data, jlong step)
{
static const char method_name[] = "Mat::n_1Mat__IIILjava_nio_ByteBuffer_2J()";
try {
LOGD("%s", method_name);
return (jlong) new Mat(rows, cols, type, (void*)env->GetDirectBufferAddress(data), (size_t)step);
} catch(const std::exception &e) {
throwJavaException(env, &e, method_name);
} catch (...) {
throwJavaException(env, 0, method_name);
}
return 0;
}
//
// Mat::Mat(int rows, int cols, int type)