OpenCV(由OpenPnP打包)库未加载

3htmauhk  于 2023-06-24  发布在  其他
关注(0)|答案(1)|浏览(154)

我尝试使用OpenVC,遇到一个错误,说它不在java.library.path中。我遵循了这个版本的OpenCV(https://github.com/openpnp/opencv)的github页面,但仍然存在问题,我尝试使用maven,但它仍然无法找到文件。
我尝试使用maven,但依赖项无法工作,然后我使用IntelliJ中内置的库系统,但我经常收到这个错误:

Exception in thread "main" java.lang.UnsatisfiedLinkError: no opencv_java460 in java.library.path: /Users/ranveerbehl/Library/Java/Extensions:/Library/Java/Extensions:/Network/Library/Java/Extensions:/System/Library/Java/Extensions:/usr/lib/java:.
    at java.base/java.lang.ClassLoader.loadLibrary(ClassLoader.java:2434)
    at java.base/java.lang.Runtime.loadLibrary0(Runtime.java:848)
    at java.base/java.lang.System.loadLibrary(System.java:2015)
    at Main.main(Main.java:13)

我试图压缩视频文件作为我以前的图书馆(IVCompressor)只是平原停止工作一天,经过几天的故障排除,我无法修复它。下面是我写的代码供参考:

public static void main(String[] args){

        // Load the OpenCV library
        nu.pattern.OpenCV.loadLocally();
        System.loadLibrary(org.opencv.core.Core.NATIVE_LIBRARY_NAME);
        // Define the input and output file paths
        String inputFile = "input.mov";
        String outputFile = "output.mov";

        // Create a VideoCapture object to read the input video
        VideoCapture capture = new VideoCapture(inputFile);

        // Get the video frames per second
        double fps = capture.get(Videoio.CAP_PROP_FPS);

        // Get the video frame size
        int frameWidth = (int) capture.get(Videoio.CAP_PROP_FRAME_WIDTH);
        int frameHeight = (int) capture.get(Videoio.CAP_PROP_FRAME_HEIGHT);

        // Create a VideoWriter object to write the output video
        VideoWriter writer = new VideoWriter(outputFile, VideoWriter.fourcc('M', 'P', '4', 'V'), fps, new Size(frameWidth, frameHeight));

        // Read and write the video frames
        Mat frame = new Mat();
        while (capture.read(frame)) {
            writer.write(frame);
        }

        // Release the resources
        capture.release();
        writer.release();
    }

所有进口都是进口的。
我觉得主要的问题在于这两行代码,如果不是库安装本身的话:

// Load the OpenCV library
        nu.pattern.OpenCV.loadLocally();
        System.loadLibrary(org.opencv.core.Core.NATIVE_LIBRARY_NAME);

OpenCV版本4.6.0。
谢谢你。

w1e3prcc

w1e3prcc1#

我在openpnp 4.7.0-0上也有同样的错误。
而不是

nu.pattern.OpenCV.loadLocally();
System.loadLibrary(org.opencv.core.Core.NATIVE_LIBRARY_NAME);

我以前

nu.pattern.OpenCV.loadShared();
System.loadLibrary(org.opencv.core.Core.NATIVE_LIBRARY_NAME);

它解决了它。

相关问题