admin管理员组

文章数量:1123566

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;

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;
Share Improve this question asked 15 hours ago OliOli 314 bronze badges New contributor Oli is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct. 3
  • 1 The methods listed are the static methods which based on the API is correct. Using this docs there is no getPredefinedDictionary static (or instance) method so you may need to explain your expectation. Include a reference to the docs you are using and specifically the library used. Note the Aruco class does have this static method (but that is version 3.4) and the referenced constant. – Computable Commented 15 hours ago
  • 2 In the 4.x release the getPredefinedDictionary is found in the Objdetect class - docs here. As well as the constants required. Give that a try and update and that can be added as solution. – Computable Commented 15 hours ago
  • the aruco API in opencv was severely "redecorated" over the past few years. some of what still exists may be removed eventually. you should expect that you'll have to adjust the code to work with future releases of opencv. – Christoph Rackwitz Commented 12 hours ago
Add a comment  | 

1 Answer 1

Reset to default 2

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);

本文标签: