我刚刚按照this设置了版本3.4.3的openCV项目,并且我已经成功编译了项目,但是我收到了此消息
java.lang.UnsatisfiedLinkError: No implementation found for long org.opencv.video.Video.createBackgroundSubtractorMOG2_3() (tried Java_org_opencv_video_Video_createBackgroundSubtractorMOG2_13 and Java_org_opencv_video_Video_createBackgroundSubtractorMOG2_13__)
at org.opencv.video.Video.createBackgroundSubtractorMOG2_3(Native Method)
at org.opencv.video.Video.createBackgroundSubtractorMOG2(Video.java:145)
at com.example.maciej.imageprocessing.MainActivity.onCreate(MainActivity.kt:80)
每当我尝试创建subtructor时都调用var backSub = Video.createBackgroundSubtractorMOG2()
。
我是openCV的新手,这是我第一次在android项目中使用本机库。
答案 0 :(得分:1)
事实证明,某些openCV库是异步加载的,backSub = Video.createBackgroundSubtractorMOG2()
应该用如下的insinde onManagerConnected
方法初始化:
private val mLoaderCallback = object: BaseLoaderCallback(this) {
override fun onManagerConnected(status: Int) {
when (status) {
LoaderCallbackInterface.SUCCESS -> {
Log.i(TAG, "OpenCV loaded successfully")
mOpenCvCameraView?.enableView()
backSub = Video.createBackgroundSubtractorMOG2()
}
else -> {
super.onManagerConnected(status)
}
}
}
}