7

I installed OpenCV (opencv-3.0.0-alpha) and it works properly but I can't use that import:

import org.opencv.core.*;
import org.opencv.imgcodecs.Imgcodecs;

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.imgcodecs.Imgcodecs cannot be resolved

How can I solve this?

6
  • 1
    Do you have the proper libraries in your classpath? Commented May 24, 2016 at 8:54
  • I have opencv-2.4.1 jar in my library . Commented May 24, 2016 at 8:55
  • @SagorAhmed and you are not suspicious that the jar is a major release behind to the installation you claim you have? Also which native-library are you using the x64 or x86 one? Commented May 24, 2016 at 9:06
  • 1
    @SagorAhmed You say you use OpenCV 3.0.0 but your jar is OpenCV 2.4.1. The reason this is important is because they changed the functionality of Highgui (not used in OpenCV 3.0.0 anymore) Commented May 24, 2016 at 9:09
  • 1
    And while you're installing new stuff, please install OpenCV 3.1. Version 3.0 alpha is, well, an alpha.... Use a stable release Commented May 24, 2016 at 9:13

1 Answer 1

10

OpenCV 3.0.0 is using the import:

import org.opencv.imgcodecs.Imgcodecs;

However the library you are using (OpenCV 2.4.1) is using different import for the same functionalites:

import org.opencv.highgui.Highgui;

https://fossies.org/diffs/opencv/2.4.11_vs_3.0.0-rc1/modules/java/android_test/src/org/opencv/test/highgui/HighguiTest.java-diff.html

Basically you are trying to import something that doesn't exist in the version you are using.

Now you can either use Highgui or get the jar for OpenCV 3.1.x

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.