错误: “java: 找不到符号 – 符号: 方法inRange”

huangapple go评论80阅读模式
英文:

Error: "java: cannot find symbol - symbol: method inRange"

问题

我正在进行一个使用OpenCV 4.1.2进行图像处理的Java项目。然而,在使用Imgproc类时,我遇到了一个错误。我收到的具体错误消息是:

java: 找不到符号
  符号:   方法 inRange(org.opencv.core.Mat,org.opencv.core.Scalar,org.opencv.core.Scalar,org.opencv.core.Mat)
  位置: 类 org.opencv.imgproc.Imgproc

我已成功导入了必要的类,并验证我正在使用Java 8和OpenCV 4.1.2。Imgproc类的其他方法,如cvtColor和GaussianBlur,都能正常工作。然而,inRange方法似乎无法识别。以下是我的代码:

import org.opencv.core.Core;
import org.opencv.core.Mat;
import org.opencv.core.Scalar;
import org.opencv.core.Size;
import org.opencv.highgui.HighGui;
import org.opencv.imgcodecs.Imgcodecs;
import org.opencv.imgproc.Imgproc;

public class Main {
    public static void main(String[] args) {
        System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
        Mat image = Imgcodecs.imread("C:\\Users\\hp probook x360 435\\Videos\\pfa\1.jfif");
        Mat BLUR = new Mat();
        Mat DST = new Mat();
        Imgproc.GaussianBlur(image, BLUR, new Size(5, 5), 0);
        Scalar LOWER = new Scalar(18, 90, 180);
        Scalar UPPER = new Scalar(35, 255, 255);
        Imgproc.cvtColor(image, BLUR, Imgproc.COLOR_BGR2HSV);
        Imgproc.inRange(BLUR, LOWER, UPPER, DST);
        HighGui.imshow("Original Image", image);
        HighGui.imshow("Grayscale Image", BLUR);
        HighGui.waitKey(0);
    }
}

我已检查了构建配置,验证了正确的导入,并确保OpenCV库已正确设置。您有关于如何解决此问题并成功使用inRange方法的任何建议吗?提前感谢您的帮助。

英文:

I am working on a Java project that utilizes OpenCV 4.1.2 for image processing. However, I'm encountering an error when using the Imgproc class. The specific error message I'm receiving is:
java: cannot find symbol
symbol: method inRange(org.opencv.core.Mat,org.opencv.core.Scalar,org.opencv.core.Scalar,org.opencv.core.Mat)
location: class org.opencv.imgproc.Imgproc

I have successfully imported the necessary classes and have verified that I'm using OpenCV 4.1.2 with Java 8. The other methods of the Imgproc class, such as cvtColor and GaussianBlur, work fine. However, the inRange method seems to be unrecognized.my code:

import org.opencv.core.Core;
import org.opencv.core.Mat;
import org.opencv.core.Scalar;
import org.opencv.core.Size;
import org.opencv.highgui.HighGui;
import org.opencv.imgcodecs.Imgcodecs;
import org.opencv.imgproc.Imgproc;


public class Main {
    public static void main(String[] args) {
        // Press Alt+Entrée with your caret at the highlighted text to see how
        // IntelliJ IDEA suggests fixing it.

        System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
        Mat image = Imgcodecs.imread("C:\\Users\\hp probook x360 435\\Videos\\pfa\1.jfif");
        Mat BLUR = new Mat();
        Mat DST=new Mat();
        Imgproc.GaussianBlur(image, BLUR, new Size(5,5), 0);
        Scalar LOWER=new Scalar(18,90,180);
        Scalar UPPER=new Scalar(35,255,255);
        Imgproc.cvtColor(image, BLUR, Imgproc.COLOR_BGR2HSV);
        Imgproc.inRange(BLUR,LOWER,UPPER,DST);
        HighGui.imshow("Original Image", image);
        HighGui.imshow("Grayscale Image", BLUR);
        HighGui.waitKey(0);

        // Press Maj+F10 or click the green arrow button in the gutter to run the code.

    }
}

I have checked my build configuration, verified the correct imports, and ensured that the OpenCV library is properly set up.

Any suggestions on how I can resolve this issue and successfully use the inRange method? Thank you in advance for your help.

答案1

得分: 1

"我猜测方法“inRange”位于这个类“org.opencv.core.Core”中。

// 所以这一行
Imgproc.inRange(BLUR, LOWER, UPPER, DST)
应该更改为
Core.inRange(BLUR, LOWER, UPPER, DST);

英文:

I guess the method "inRange" is in this class "org.opencv.core.Core"

//so this line  
Imgproc.inRange(BLUR,LOWER,UPPER,DST) 
should be changed to 
Core.inRange(BLUR,LOWER,UPPER,DST);

huangapple
  • 本文由 发表于 2023年6月11日 20:57:43
  • 转载请务必保留本文链接:https://go.coder-hub.com/76450569.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定