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.

Detection Algorithm

cube markers
The algorithm to detect the cube marker is composed of 3 steps.

  1. 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.

  2. To detect side of cube.
    1. 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.
      (Figure: side)

    2. 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.





  • Add this article to hatena bookmark
  • 0





  1. Chrysto says:


    Bulgaria flash comunity says “Hi” to you! Really nice effects man, amazing augumented reallity. Is it possible to write some more advanced tutorials about augumented reality –> for example simple animating sprites, worm that mooves or something like this? I started to learn FLARToolkit and PPV3D about a week ago, got 2 years of as3 oop expirience , but just can’t find enough tutorials and source codes to go on :)

    the flash community from Japan are the best in augumenter reality :)

  2. tarotarorg says:

    Hi, Chrysto.

    Please check this site.
    This is very good tutorial.


Leave a Comment

Your email address will not be published. Required fields are marked *