forked from VlSomers/native-opencv-android-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
native-lib.cpp
29 lines (22 loc) · 945 Bytes
/
native-lib.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#include <jni.h>
#include <android/log.h>
#include <opencv2/core/core.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#define TAG "NativeLib"
using namespace std;
using namespace cv;
extern "C" {
void JNICALL
Java_com_example_nativeopencvandroidtemplate_MainActivity_adaptiveThresholdFromJNI(JNIEnv *env,
jobject instance,
jlong matAddr) {
// get Mat from raw address
Mat &mat = *(Mat *) matAddr;
clock_t begin = clock();
cv::adaptiveThreshold(mat, mat, 255, ADAPTIVE_THRESH_MEAN_C, THRESH_BINARY_INV, 21, 5);
// log computation time to Android Logcat
double totalTime = double(clock() - begin) / CLOCKS_PER_SEC;
__android_log_print(ANDROID_LOG_INFO, TAG, "adaptiveThreshold computation time = %f seconds\n",
totalTime);
}
}