找不到符号-core.NATIVE_LIBRARY_NAME

时间:2019-01-31 05:59:35

标签: java opencv

Facedetection.java:22:错误:找不到符号         System.loadLibrary(Core.NATIVE_LIBRARY_NAME);                                ^   符号:变量NATIVE_LIBRARY_NAME   地点:核心班 1个错误

我什至认为我的opencv.jar也包含错误

我在做tomcat,在任何地方都找不到此错误 我在这里找到代码 https://www.geeksforgeeks.org/image-processing-java-set-9-face-detection/

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

public class Facedetection 
{ 
    public static void main(String[] args) 
    { 

        // For proper execution of native libraries 
        // Core.NATIVE_LIBRARY_NAME must be loaded before 
        // calling any of the opencv methods 
        //nu.pattern.OpenCV.loadShared();
        System.loadLibrary(Core.NATIVE_LIBRARY_NAME); 

        // Face detector creation by loading source cascade xml file 
        // using CascadeClassifier. 
        // the file can be downloade from 
        // https://github.com/opencv/opencv/blob/master/data/haarcascades/ 
        // haarcascade_frontalface_alt.xml 
        // and must be placed in same directory of the source java file 
        CascadeClassifier faceDetector = new CascadeClassifier(); 
        faceDetector.load("haarcascade_frontalface_alt.xml"); 

        // Input image 
        Mat image = Imgcodecs.imread(":Downloads/apache-tomcat-8.5.37/webapps/ROOT/image/photo1.jpeg"); 

        // Detecting faces 
        MatOfRect faceDetections = new MatOfRect(); 
        faceDetector.detectMultiScale(image, faceDetections); 

        // Creating a rectangular box showing faces detected 
        for (Rect rect : faceDetections.toArray()) 
        { 
            Core.rectangle(image, new Point(rect.x, rect.y), 
             new Point(rect.x + rect.width, rect.y + rect.height), 
                                           new Scalar(0, 255, 0)); 
            //changing Imgproc to Core
        } 

        // Saving the output image 
        String filename = "Ouput.jpeg"; 
        Imgcodecs.imwrite(":/Downloads/apache-tomcat-8.5.37/webapps/ROOT/image/"+filename, image); 
    } 
} 

人脸检测

0 个答案:

没有答案