javaandroidopencvaruco

Android Studio/Java Cannot resolve symbol 'getPredefinedDictionary' when using OpenCV (4.11.0) Dictionary


I'm trying to set up Aruco marker detection in an Android studio Java application. Currently I'm generating my markers in python using this OpenCV aruco dictionary I create:

dictionary = aruco.getPredefinedDictionary(aruco.DICT_4X4_50)

However I cannot then refer to a similar dictionary to then detect these markers created in my java code.

My java code is as below:

Dictionary dictionary = Dictionary.getPredefinedDictionary(Dictionary.DICT_4X4_50);

However this gives the errors:

Cannot resolve method 'getPredefinedDictionary' in 'Dictionary'
Cannot resolve symbol 'DICT_4X4_50'

It seems that I only have these methods for Dictionary, with no sign of the getPredefinedDictionary method:

__fromPtr__(long addr)
getBitsFromByteList(Mat byteList, int markerSize)
class
getByteListFromBits(Mat bits)

Is there something wrong in how I am using OpenCV or the dictionary? This is how I am importing everything:

import org.opencv.android.OpenCVLoader;
import org.opencv.core.Mat;
import org.opencv.imgcodecs.Imgcodecs;
import org.opencv.imgproc.Imgproc;
import org.opencv.objdetect.ArucoDetector;
import org.opencv.objdetect.Dictionary;

Solution

  • To resolve this I used Objdetect's getPredefinedDictionary method as shown below:

    for the import:

    import org.opencv.objdetect.Objdetect;
    

    And for the usage in code:

    Dictionary dictionary = Objdetect.getPredefinedDictionary(Objdetect.DICT_4X4_50);