我有两个人脸检测项目。一个是Java项目,另一个是Kotlin。这两个项目都使用mlkit进行人脸检测,使用opencv c引擎进行人脸识别。C引擎在两个项目中完全相同。在构建了两个项目之后,当我运行它们时,它们的c++引擎运行时是不同的。Java项目比Kotlin更快。
JNIEXPORT jfloat JNICALL
FACE_ENGINE_METHOD(nativeExtractLiveFeature)(JNIEnv *env, jobject instance,
jobject bmp, jint left, jint top, jint right, jint bottom,
jfloatArray landmarksX, jfloatArray landmarksY, jfloatArray features)
字符串
这是我想称之为C++代码。我把它导入到这样的项目中。
@Keep
private native static float nativeExtractLiveFeature(Bitmap bmp, int leftFace, int topFace, int rightFace, int bottomFace, float[] landmarksX, float[] landmarksY, float[] features); // java
@Keep
private external fun nativeExtractLiveFeature(bmp: Bitmap, leftFace: Int, topFace: Int, rightFace: Int, bottomFace: Int, landmarksX: FloatArray, landmarksY: FloatArray, features: FloatArray): Float //kotlin
型
Java项目现在比Kotlin快2倍。请告诉我是什么原因造成的。我需要提高Kotlin项目的速度,使其与Java项目一样快。我想知道任何可能的方法。请帮帮我- 谢谢-谢谢
1条答案
按热度按时间ztmd8pv51#
看看我如何保存文件,然后打开它,然后找到脸。下面是如何实现的代码:
字符串