英文:
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);
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论