MCPcopy Create free account
hub / github.com/KAlO2/PerfectShow / getNativePointArray

Function getNativePointArray

jni/platform/jni_bridge.cpp:40–61  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

38}
39
40std::vector<cv::Point2f> getNativePointArray(JNIEnv *env, jobjectArray _points)
41{
42 jclass class_PointF = env->FindClass("android/graphics/PointF");
43 jfieldID field_x = env->GetFieldID(class_PointF, "x", "F");
44 jfieldID field_y = env->GetFieldID(class_PointF, "y", "F");
45 assert(class_PointF != nullptr);
46 assert(field_x != nullptr && field_y != nullptr);
47
48 // Get<Primitive>ArrayRegion, no GetObjectArrayRegion method, fetch element one by one.
49 jsize feature_point_count = env->GetArrayLength(_points);
50 std::vector<cv::Point2f> points(feature_point_count);
51 for(jsize i = 0; i < feature_point_count; ++i)
52 {
53 jobject element = env->GetObjectArrayElement(_points, i);
54 float x = env->GetFloatField(element, field_x);
55 float y = env->GetFloatField(element, field_y);
56 points[i] = cv::Point2f(x, y);
57 env->DeleteLocalRef(element);
58 }
59
60 return points;
61}
62
63#ifdef ANDROID
64uint32_t* lockJavaBitmap(JNIEnv* env, jobject bitmap, AndroidBitmapInfo& info)

Calls

no outgoing calls

Tested by

no test coverage detected