使用 OpenCV 在 Java 中加载并行处理模块时出错

问题描述 投票:0回答:2

我正在尝试使用 Java 中的 OpenCV 库检测图像中的人脸。我正在使用 OpenCV 的 4.7.0-dev 版。当我运行程序时,出现以下错误:

[ INFO:[email protected]] global registry_parallel.impl.hpp:96 cv::parallel::ParallelBackendRegistry::ParallelBackendRegistry core(parallel): Enabled backends(3, sorted by priority): ONETBB(1000); TBB(990); OPENMP(980)
[ INFO:[email protected]] global plugin_loader.impl.hpp:67 cv::plugin::impl::DynamicLib::libraryLoad load C:\Users\ricar\OneDrive\Documentos\libraries\opencv\build\java\x64\opencv_core_parallel_onetbb470_64d.dll => FAILED
[ INFO:[email protected]] global plugin_loader.impl.hpp:67 cv::plugin::impl::DynamicLib::libraryLoad load opencv_core_parallel_onetbb470_64d.dll => FAILED
[ INFO:[email protected]] global plugin_loader.impl.hpp:67 cv::plugin::impl::DynamicLib::libraryLoad load C:\Users\ricar\OneDrive\Documentos\libraries\opencv\build\java\x64\opencv_core_parallel_tbb470_64d.dll => FAILED
[ INFO:[email protected]] global plugin_loader.impl.hpp:67 cv::plugin::impl::DynamicLib::libraryLoad load opencv_core_parallel_tbb470_64d.dll => FAILED
[ INFO:[email protected]] global plugin_loader.impl.hpp:67 cv::plugin::impl::DynamicLib::libraryLoad load C:\Users\ricar\OneDrive\Documentos\libraries\opencv\build\java\x64\opencv_core_parallel_openmp470_64d.dll => FAILED
[ INFO:[email protected]] global plugin_loader.impl.hpp:67 cv::plugin::impl::DynamicLib::libraryLoad load opencv_core_parallel_openmp470_64d.dll => FAILED
[ INFO:[email protected]] global ocl.cpp:1186 cv::ocl::haveOpenCL Initialize OpenCL runtime...
[ INFO:[email protected]] global ocl.cpp:1192 cv::ocl::haveOpenCL OpenCL: found 2 platforms
[ INFO:[email protected]] global ocl.cpp:984 cv::ocl::OpenCLExecutionContext::Impl::getInitializedExecutionContext OpenCL: initializing thread execution context
[ INFO:[email protected]] global ocl.cpp:994 cv::ocl::OpenCLExecutionContext::Impl::getInitializedExecutionContext OpenCL: creating new execution context...
[ INFO:[email protected]] global ocl.cpp:1012 cv::ocl::OpenCLExecutionContext::Impl::getInitializedExecutionContext OpenCL: device=NVIDIA GeForce MX230
[ INFO:[email protected]] global ocl.cpp:5370 cv::ocl::Context::Impl::__init_buffer_pools OpenCL: Initializing buffer pool for context@0 with max capacity: poolSize=0 poolSizeHostPtr=0

这是我的代码。我相信我的问题是安装或配置问题。

import org.opencv.core.Core;
import org.opencv.core.Mat;
import org.opencv.core.MatOfRect;
import org.opencv.core.Rect;
import org.opencv.core.Scalar;
import org.opencv.imgcodecs.Imgcodecs;
import org.opencv.imgproc.Imgproc;
import org.opencv.objdetect.CascadeClassifier;

class Main{

    public static void main(String[] args){
        
        System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
        
        Mat image = Imgcodecs.imread("C:\\Users\\ricar\\Downloads\\DSC02281.JPG");
        
        CascadeClassifier classifier = new CascadeClassifier("C:\\Users\\ricar\\OneDrive\\Documentos\\workspace\\LearningJava\\src\\haarcascade_frontalface_default.xml");
        MatOfRect faceDetections = new MatOfRect();
        classifier.detectMultiScale(image, faceDetections);
        
        for(Rect rect : faceDetections.toArray()) {
            
            Imgproc.rectangle(image, rect, new Scalar(0, 0, 255));
            
        }
        Imgcodecs.imwrite("C:\\Users\\ricar\\Downloads\\output.jpg", image);
        
    }
    
}
java opencv installation configuration face-detection
2个回答
1
投票

错误消息表明问题出在OpenCV并行插件上。这可能是由于 OpenCV 用于并行处理的 TBB 库版本缺失或不兼容。

您应该检查您是否安装了正确版本的 TBB,并且它位于系统 PATH 环境变量中包含的目录中。


-1
投票

我遇到了同样的错误,你找到解决方案了吗?

© www.soinside.com 2019 - 2024. All rights reserved.