包含其他所有的so功能,上述博文就是对的。
如果不包含,需要一定的加载技巧。
代码范例如下:
package taishan; import java.io.file;import java.util.linkedlist;import java.util.list;import org.opencv.core.cvtype;import org.opencv.core.mat; @suppresswarnings(serial)public class opencvtest{ public final static string lib_path = /home/wuxi/eclipse-workspace/opencvtest/libs/bin; private static list<file> getopencvfiles(final string dirname) { if (dirname == null) { return null; } file dir = new file(dirname); if (!dir.exists() || !dir.isdirectory()) { return null; } file[] files = dir.listfiles(); list<file> filelist = new linkedlist<file>(); for (file file : files) { string name = file.getname(); if ( name.startswith(lib) && name.endswith(.so)) { filelist.add(file); } } return filelist; } private static void loadnativeopencv(final string dirname) { list<file> filelist = getopencvfiles(dirname); if (filelist == null || filelist.size() == 0) { return; } while (filelist.size() > 0) { for (int i=0; i
以上就是java怎么在linux上加载opencv so库的详细内容。
