可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
I installed OpenCV (opencv-3.0.0-alpha) and it works proberly but I can't use that import
import org.opencv.core.*; import org.opencv.highgui.Highgui; public class Main { public static void main(String[] args) { // System.loadLibrary("opencv_java244"); // Mat m = Highgui.imread("C:/Users/raj/Desktop/sa1.png", // Highgui.CV_LOAD_IMAGE_COLOR); // new LoadImage("C:/Users/raj/Desktop/dst1.jpg", m); } }
I get this error
The import org.opencv.highgui cannot be resolved
How can I solve this?
回答1:
in opencv3.0, there is no more highgui module in java.
the functionality was split up into new videoio and imgcodecs (that's where you will find imread) modules.
since there is no gui available from java, - no need to have a highgui module anymore.
import org.opencv.core.*; import org.opencv.imgcodecs; // imread, imwrite, etc import org.opencv.videoio; // VideoCapture
回答2:
import org.opencv.imgcodecs.Imgcodecs; // imread, imwrite
Not: org.opencv.imgcodecs;
Core.line
, Core.Rectangle
, Core.imread
, Core.imwrite
deprecated.
Use Imgcodecs.imread
, Imgcodecs.imwrite
, etc.