Aruco java, trying to get marker IDs [solved]
Hi all, first of all thanks for this amazing library. I´m working on my final degree project, using a Lego Mindstorm EV3 that uses my Android phone camera as its eyes. I´ve implemented an android app wich uses the Aruco module (openCVLibrary 3.4.0 dev), everything works perfectly, the app detects and draws all the Aruco markers, but I´m trying to get the IDs from the IDs Mat, how can I get those IDs stored in the Mat?
public void drawDetectedMarkers(Mat mRgba) {
Aruco.drawDetectedMarkers(mRgba, corners, arucoIDs, new Scalar(0, 255, 0));
Imgproc.putText(mRgba, "Aruco:"+ **arucoIDs.get(1,1)**, new Point(30, 30), 3, 1, new Scalar(255, 0, 0, 255), 1);
}
I´ve tried using arucoIDs.get() function, but it doesn´t give me the marker ID that I need, depending on the ID, the robot will move to the left or right side. Thanks so much and regards
we need to see the type of
arucoIDs
. how do you declare it ?also, c++, java, python all start indexing at
0
,not1
. if you only have 1 marker,(1,1)
is probably invalidHi @berak,thanks for your answer. "arucoIDs" is a Mat type, declared at onCameraViewStarted as:
public Mat arucoIDs = new Mat();
First the app detect the Aruco markers using:
Aruco.detectMarkers(imageAruco, dictionary, corners, arucoIDs);
Then it draws the detected markers using:
This is the Aruco.java code called from drawDetectedMarkers function:
please try to print out the shape/size of your
arucoIDs
Using "putText" function I get these info:
That Aruco marker comes from the DICT_4X4_50 dictionary.
i bet with 2 markers, the next is at
ids.get(0,1);
, 0,2...0,3... etc.I´ve solved the problem, I´ve got a String value using toString() function:
Now I got this:
So from now, the robot can "decide" depending on the marker ID if it should turn left or right.
Maybe there is a way to get an integer value (5) instead of a double value (5.0?
Thanks berak.
Mat.get()
returns adouble[]
, whatever is in it. you're safe here to simply cast it like