about cube detection algorithm
In previous entry, I made cube marker demo.
This time, I explain the detection procedure of the cube marker, step by step.
To detect cube marker, I use 3 marker files.
- top32.pat: Marker to detect the top of cube.
- cube-basic32.pat: Marker to detect side of cube.
- sideQ.pat: Marker to detect which side of cube it is.
The algorithm to detect the cube marker is composed of 3 steps.
- Compare the marker candidate with top32.pat.
If candidate is corresponding to top32.pat, Detector consider the square is top of cube and detection is finish.
- To detect side of cube.
Compare the marker candidates except upper right 1/4 with cube-basic32.pat.
4 cube side markers are same ,excluding upper right 1/4.
Then, Detector compares marker candidate excluding upper right 1/4 with cube-basic32.pat.
If candidate is corresponding to cube-basic32.pat, Detector consider the square is side of cube.
- Compare a corresponding marker candidate to cube-basic32.pat with sideQ.pat.
If candidate is side of cube, Detector compares candidate’s upper right 1/4 with sideQ.pat to get direction.
If direction is 0, square is BACK of cube.
Else if direction is 1, square is RIGHT of cube.
Else if direction is 2, square is FRONT of cube.
Else if direction is 3, square is LEFT of cube.
- Compare the marker candidates except upper right 1/4 with cube-basic32.pat.