嗨,我正在使用quickbirdstudios opencv-android 4_1_0_contrib库,因为我的应用程序的部分功能是能够检测/读取aruco标记。我的android应用是用Kotlin编写的。当我在我的app / build.gradle中将该库用作外部依赖项时,该应用程序运行正常,没有错误:
implementation 'com.quickbirdstudios:opencv:4.1.0-contrib'
但是,当我改为将库添加为项目的一部分,并将其添加为模块,以便将app / build.gradle中的实现替换为:
implementation project(path: ':opencv4_1_0_contrib')
在运行应用程序时会引发此错误:
java.lang.UnsatisfiedLinkError: No implementation found for long org.opencv.aruco.Dictionary.get_0(int) (tried Java_org_opencv_aruco_Dictionary_get_10 and Java_org_opencv_aruco_Dictionary_get_10__I) at org.opencv.aruco.Dictionary.get_0(Native Method)
at org.opencv.aruco.Dictionary.get(Dictionary.java:104)
at com.walmart.svi.opencv.FrameKt.arucoTags(Frame.kt:43)
at com.walmart.svi.dto.FrameBufferKt.pushFrame(FrameBuffer.kt:48)
at com.walmart.svi.opencv.OpenCVActivity.onCameraFrame(OpenCVActivity.kt:103)
at org.opencv.android.CameraBridgeViewBase.deliverAndDrawFrame(CameraBridgeViewBase.java:392)
at org.opencv.android.JavaCameraView$CameraWorker.run(JavaCameraView.java:373)
at java.lang.Thread.run(Thread.java:764)
Dictionary.java
public static Dictionary get(int dict)
{
Dictionary retVal = Dictionary.__fromPtr__(get_0(dict)); //***line 104
return retVal;
}
Frame.kt
fun Frame.arucoTags(): List<Marker> {
val ids = Mat()
val corners = ArrayList<ArucoCorners>()
val placeholder = value.clone()
Imgproc.cvtColor(placeholder, placeholder, Imgproc.COLOR_RGBA2GRAY)
Aruco.detectMarkers(placeholder, Dictionary.get(Aruco.DICT_5X5_1000), corners, ids) //***line 43
val markers = parseMarkers(ids, corners)
for (corner in corners) {
corner.release()
}
ids.release()
return markers
}
FrameBuffer.kt
fun FrameBuffer.pushFrame(frame: Frame) = with(seenMarkers()) {
FrameBuffer(frame = frame,
frameHistory = frameHistory.plusElement(frame.arucoTags()).takeLast(buffer), //***line 48
buffer = buffer,
currentMarkers = this,
currentFocus = frame.centerMarker(this))
}
OpenCVActivity.kt
override fun onCameraFrame(inputFrame: CameraBridgeViewBase.CvCameraViewFrame): Mat {
currentFrame = Frame(inputFrame.rgba())
frameData = frameData?.let {
onNextFrame(it.pushFrame(currentFrame)) //*** line 103
} ?: FrameBuffer.new(currentFrame, frameBuffer)
return frameData!!.frame.value
}
CameraBridgeViewBase.java
protected void deliverAndDrawFrame(CvCameraViewFrame frame) {
Mat modified;
if (mListener != null) {
modified = mListener.onCameraFrame(frame); //***line 392
} else {
modified = frame.rgba();
}
...
}
任何帮助将不胜感激。谢谢。