SOLVED The method putText(Mat, String, Point, int, int, Scaler) is undefined for the type Imgproc
Eclipse IDE for JAVA Developers: Version: Oxygen.3 Release (4.7.3)
JRE System Library [JavaSE-1.7]
OpenCV 3.4.0
The original sample "Smoothing Images" C++ script is here:
The original sample "Smoothing Images" Java script is here:
And
The original sample "Smoothing Images" Python script is here:
I have read about the above software and have those versions. I have run the sample C++ script of "Smoothing Images" and it works fine. Now I am trying to run the Java script. But, I get the error message
“The method putText(Mat, String, Point, int, int, Scaler) is undefined for the type Imgproc”
What am I doing wrong?
I have gutted the original Java script but, left the code causing the error.
The offending code follows:
package openCV_340_PACKAGE;
import org.opencv.core.*;
import org.opencv.highgui.HighGui;
import org.opencv.imgcodecs.Imgcodecs;
import org.opencv.imgproc.Imgproc;
public class Smoothing_Images2 {
public static void main(String[] args) {
// Load the native library.
System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
Mat src = new Mat(), dst = new Mat();
dst = Mat.zeros(src.size(), src.type());
Imgproc.putText(src, "Original Image",
new Point(src.cols() / 4, src.rows() / 2),
Core.FONT_HERSHEY_COMPLEX, 1, new Scalar(255, 255, 255));
}
}
EDIT ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
I have no training in Java or OpenCV. That is why I rely on the sample scripts so much. I would expect that the sample scripts would run as is. That is the case with C++ but, not with Java. I have read your message. Notwithstanding . . .
I HAVE run my code snippet and I get the following possible errors . . .
From Intelli-sense On line 26:
Imgproc.putText(src, "Original Image”, new Point(src.cols() / 4, src.rows() / 2),
Core.FONT_HERSHEY_COMPLEX, 1, new Scalar (255, 255, 255));
The error about putText
The method putText(Mat, String, Point, int, int, Scaler) is undefined for the type Imgproc
Also: Is the possible error about POINT. With three options for the import of Point . . .
Import ‘Point’ (java.awt)
Import ‘Point’ (lejos.robotics.geometry) and
Import ‘Point’ (org.opencv.core)
From execution A possible error on execution is again about Point . . .
Exception in thread "main" java.lang.Error: Unresolved compilation problem: Point cannot be resolved to a type at openCV_340_PACKAGE.Smoothing_Images2.main(Smoothing_Images2.java:26)
For some unknown reason, I cannot run your snippet but, Intelli-sense finds an error at Improc.putText! You have obviously run a snippet to completion and shown the results. My current snippet that I am trying to run is
package openCV_340_PACKAGE;
import org.opencv.core.Mat;
import org.opencv.core.Scalar;
import org.opencv.core.Point;
public class berak {
Mat src = new Mat(400,400,16,Scalar.all(127));
Imgproc.putText
(src,
"The Image",
new org.opencv.core.Point( src.cols()/5,
src.rows()/3),
Core.FONT_HERSHEY_COMPLEX,
1,
new Scalar(255, 255, 255));
}
Note: I cannot find org.opencv.Imgproc.putText
Please post your entire snippet including the imports.
you obviously did not try to run the code above (it does not reproduce the error)
https://docs.opencv.org/master/javado...