问题描述
我正在尝试在树莓派上安装OpenCV,并且在多次尝试配置cmake之后,已经成功产生了opencv-400.jar和libopencv_java400.so.网络上的各种指南都没有说明下一步该怎么做.
I am trying to install OpenCV on a raspberry pi and, after many tries configuring cmake, have succeeded in producing opencv-400.jar and libopencv_java400.so The various guides on the web do not say what to do next.
我在类路径中有jar文件,测试代码可以正常编译,并且打印出System.getProperty("java.library.path")
包含包含.so文件的目录.在另一个目录/usr/local/lib中,make进程放置了一堆.a文件.通过使库不共享所需部分而表示的cmake指令将全部放入java .so文件中.我不确定这是否有意义?我还必须将/usr/local指定为构建前缀-也许那应该是pi上的其他名称?
I have the jar in my class path, the test code compiles fine, and printing out System.getProperty("java.library.path")
includes the directory containing the .so file. In a different directory, /usr/local/lib, the make process has put a stack of .a files. The cmake instructions said by making the libraries non shared the required parts would all be put in the java .so file. I am not sure this makes sense? I also had to specify /usr/local as the build prefix - perhaps that should be something else on a pi?
...当然不应该.如果有人将rpi摄像机连接到opencv并从java访问它,也许您可以共享cmake参数.
... which it shouldn't of course. If anyone is connecting the rpi camera to opencv and accessing that from java, perhaps you could share the cmake parameters.
推荐答案
恢复到opencv 3.3.0之后,我不需要弄清楚cmake了,我让opencv用c ++在pi上工作.然后,我将所需的opencv命令包装在JNI中...,但仍然出现段错误.然后,我学会了使用gdb并非常迅速地将错误跟踪到libopenmpt.快速搜索说,这在内存不足时会导致分段错误.
After reverting to opencv 3.3.0 so I did not need to figure out cmake, I got opencv working on the pi with c++. I then wrapped my required opencv commands in JNI... and still got segmenation fault. I then learnt to use gdb and traced the error, very quickly, to libopenmpt. A quick search said this causes a segmentation fault when out of memory.
在这种情况下,解决方案是运行java -Xss128m ...
来运行我的代码.
The solution in this case is to run java -Xss128m ...
to run my code.
我猜这是从内置的Java组件中使用opencv 4的修复程序.
This, I am guessing, is a fix for using opencv 4 from the built java components.
这篇关于RPI上的OpenCV-System.loadLibrary中的分段错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!