AR marker detection on GPU using WebGL*
- Section 2: Current status of the prototype code and the constraints.
- Section 3: Algorithm steps, so you can modify them for different types of AR markers or purposes.
- Section 4: Latency measurements using slow motion camera and EXT_disjoint_timer_query.
1.1 Developing the algorithm
2. Current status and constraints
2.1 This is a first step, prototype code
2.2 Implementation supports 3x3 AR codes
2.3 It is fast and can detect multiple markers simultaneously
2.4 Demo requires controlled lighting
2.5 Browser requirements
about:configpage and set
dom.webcomponents.shadowdom.enabledto true. This dependency is related only to page layout code and it can be easily removed, to avoid the need for dealing with
3. Algorithm and the code
3.1 Pass #0: Threshold and edges code
calculateEdgeCodeToGradientDirectionMapfunction so it does not repeat on every frame. Pre-calculated data for all of the potential neighbor values is supplied as a uniform array to the shader. The shader samples neighbors s0 to s7, forms a lookup into the precalculated array, and writes vec4(B/8.0, S/8.0, E/8.0, 0.0) to framebuffer - to texture color-attached to framebuffer that will be input for the next step.
3.2 Pass #1: Corner candidates from edges codes
3.3 Pass #2: Refine neighbor corners
3.4 Pass #3: Reduce corners texture dimensions, divide both by 5
3.5 Pass #4: Detect straight line edges between corners
3.6 Pass #5: Identify markers, their edges, corners, orientation and the code
3.6.1 3x3 marker data encoding: Base corner
3.7 Pass #6: Rendering to screen
4. Latency measurements
To query it asynchronously, beginQuery is placed just before issuing drawing calls related to recognition rendering passes. After the last of the recognition render passes, an endQuery call is coupled with it. We do not attempt to read the query results until the next rendering call, to give the pending query enough time to complete. If the result is available, it is printed to the console and the new query call can begin.
4.2 Slow motion camera
5.1 Additional reading