ARToolkit Part 2: Contour Detection 详解

转载自:http://chriskirkham.co.uk/2011/06/27/dismantling-artoolkit-part-2-contour-detection/

Contours

So what do we mean by the word contourWiktionary offers two definitions:

  1. An outline, boundary or border, usually of curved shape.
  2. A line on a map or chart delineating those points which have the same altitude or other plotted quantity: a contour line or isopleth.

Any readers familiar with map- or chart-based navigation will perhaps be more used to the latter definition; that was certainly the case for me. In the context of marker detection, the former is the more appropriate definition. It is the prominent black border of a marker that is detected using the technique discussed here.

Sample ARToolkit Marker

In simple terms, the technique is as follows: starting at some vertex, walk clockwise around the marker chaining together the pixels discovered until one ends up back at the starting vertex. The outline of the marker has then been traced. But how exactly does one walk around the marker?

Moore-Neighbor Tracing

This method of contour detection is known as Moore-Neighbor Tracing. The code to do so in ARToolkit can be found in arDetectMarker2.c in the function arGetContour(…). The steps taken in said function are described below.

  1. A clip region is one of the outputs from labeling2(…) which stores the minimum and maximum x and y co-ordinates. One cannot simply assume that the top left pixel is a vertex of the marker — the maker could be rotated about any of its three axes, distorting the image. All that is known is that there is a vertex somewhere on the top row of the clipped region. A linear search, moving from left to right, will reveal this. Consider this vertex Vstart.

  2. Set Pcurrent = Vstart. Now consider the pixel directly above Pcurrent; let’s call it Pcheck.

  3. If Pcheck is not black (i.e. its label is zero), set Pcheck as the pixel one step round in a clockwise direction, about Pcurrent. Repeat until a black pixel is found. Consider this black pixel as Pcurrent and add it to the chain.

  4. If Pcurrent == Vstart, stop. Otherwise…

  5. Set Pcheck as the previous pixel (i.e. the one just added to the chain), then advance it one clockwise step about Pcurrent. Go to 3.

Assuming the blob that’s being checked is a marker, the border of said marker has then been traced. Ensuring the traced blob is a marker occurs at a latter stage and will be the subject of another blog post.

After this occurs in arGetContour(…) the chain array is then re-ordered, moving all pixels identified beyond the furthest pixel from Vstart to the front of the array and adds the necessary link to complete the contour. Right now, I have no idea why this is done. One can only assume it helps at a later stage in the program.

My next challenge: work out how ARToolkit ensures the blobs are actually squares.


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值