There is another option to detect the markers corner points.
It will require some changes to the wrapper code and recompiling the Android binaries.
Fork or clone the artoolkit5 github repository and make the following changes:
Add an entry to ARMarker.h
float cornerPoints[8];
In ARMarkerSquare.cpp make a change in the updateWithDetectedMarkers method just after the code where a marker has been determined visible, update the cornerPoints:
// Consider marker visible if a match was found.
if (k != -1) {
visible = true;
m_cf = markerInfo[k].cf;
for (int c = 0; c < 4; c++) {
cornerPoints[c*2] = markerInfo[k].vertex[c][0];
cornerPoints[c*2 + 1] = markerInfo[k].vertex[c][1];
}
Add a new method ARToolKitWrapperExportedAPI.cpp to retrieve the corner points:
EXPORT_API bool arwQueryMarkerCornerPoints(int markerUID, float points[8])
{
ARMarker *marker;
if (!gARTK) return false;
if (!(marker = gARTK->findMarker(markerUID))) {
gARTK->logv(AR_LOG_LEVEL_ERROR, "arwQueryMarkerCornerPoints(): Couldn't locate marker with UID %d.", markerUID);
return false;
}
for (int i = 0; i < 8; i++) points[i] = (float)marker->cornerPoints[i];
return marker->visible;
}
And add the JNI definition for that:
JNIEXPORT jfloatArray JNICALL JNIFUNCTION(arwQueryMarkerCornerPoints(JNIEnv *env, jobject obj, jint markerUID))
{
float trans[8];
if (arwQueryMarkerCornerPoints(markerUID, trans)) return glArrayToJava(env, trans, 8);
return NULL;
}
After all that I recompile the ARWrapper shared objects in the android directory with the build.sh script and used these new shared objects.
In the he NativeInterface.java add the following method:
/**
* Retrieves the corner points for the specified marker
*
* @param markerUID The unique identifier (UID) of the marker to check
* @return A float array of size 8 containing the corner points starting at top left (x,y) top right, bottom right, bottom left.
* So
*/
public static native float[] arwQueryMarkerCornerPoints(int markerUID);
And finally add the method to ARToolKit.java as well:
/**
* Retrieves the corner points for the specified marker
*
* @param markerUID The unique identifier (UID) of the marker to check
* @return A float array of size 8 containing the corner points starting at top left (x,y) top right, bottom right, bottom left.
*
*/
public float[] arwQueryMarkerCornerPoints(int markerUID) {
if (!initedNative) return null;
return NativeInterface.arwQueryMarkerCornerPoints(markerUID);
}
See also:
https://archive.artoolkit.org/community/forums/viewtopic.php?f=26&t=16099
The changes can be seen seen in this fork as well: https://github.com/ekkelenkamp/artoolkit5/tree/marker_corner_points