我目前正在嘗試開發一個項目的ArUco立方體檢測器。我們的目標是在不使用大型ArUco電路板的情況下獲得更加穩定和準確的姿態估計。然而,爲了這個工作,我需要知道每個標記的方向。使用draw3dAxis方法,我發現X和Y軸不會始終出現在相同的位置。這裏是一個視頻演示問題:https://youtu.be/gS7BWKm2nmgArUco Axis交換時繪圖3dAxis
這似乎是與Rvec檢測問題。 Rvec的前兩個值有一個明顯的轉變,在軸交換之前它將保持相當一致。當這個軸交換髮生時,值可以在2-6的任何位置變化。該ARuco庫並試圖解決旋轉如圖所示Marker.calculateMarkerId()方法:
/**
* Return the id read in the code inside a marker. Each marker is divided into 7x7 regions
* of which the inner 5x5 contain info, the border should always be black. This function
* assumes that the code has been extracted previously.
* @return the id of the marker
*/
protected int calculateMarkerId(){
// check all the rotations of code
Code[] rotations = new Code[4];
rotations[0] = code;
int[] dists = new int[4];
dists[0] = hammDist(rotations[0]);
int[] minDist = {dists[0],0};
for(int i=1;i<4;i++){
// rotate
rotations[i] = Code.rotate(rotations[i-1]);
dists[i] = hammDist(rotations[i]);
if(dists[i] < minDist[0]){
minDist[0] = dists[i];
minDist[1] = i;
}
}
this.rotations = minDist[1];
if(minDist[0] != 0){
return -1; // matching id not found
}
else{
this.id = mat2id(rotations[minDist[1]]);
}
return id;
}
和MarkerDetector.detect()不調用該方法,並使用getRotations()方法:
// identify the markers
for(int i=0;i<nCandidates;i++){
if(toRemove.get(i) == 0){
Marker marker = candidateMarkers.get(i);
Mat canonicalMarker = new Mat();
warp(in, canonicalMarker, new Size(50,50), marker.toList());
marker.setMat(canonicalMarker);
marker.extractCode();
if(marker.checkBorder()){
int id = marker.calculateMarkerId();
if(id != -1){
// rotate the points of the marker so they are always in the same order no matter the camera orientation
Collections.rotate(marker.toList(), 4-marker.getRotations());
newMarkers.add(marker);
}
}
}
}
爲ArUco庫完整的源代碼是在這裏:https://github.com/sidberg/aruco-android/blob/master/Aruco/src/es/ava/aruco/MarkerDetector.java
如果任何人有任何意見或解決方案,我會非常親切。如果您有任何疑問,請與我聯繫。