您好,欢迎访问一九零五行业门户网

Java怎么在LINUX上加载OpenCV so库

这个范例不一定能跑起来。原因就是依赖库加载的问题。如果libopencv_java.so:
包含其他所有的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 关键的一句就是要正确找到so包。
以上就是java怎么在linux上加载opencv so库的详细内容。
其它类似信息

推荐信息