ARToolkit (ARToolkitPlus) and WPF

Summary

For starters introducing ARToolkit and writing a simple skelton code is quite troublesome. Some of the reasons are that it need many extra components and that it is written in old type C++ language. In fact, I prefer .Net environment and the C# language much. Brains-N-Brawn has written C# wrapper code for ARToolkitPlus,  DirectShow.NET provides video capturing feature for C# programmers, and Windows Presentation Foundation(WPF) itself already has 3D drawing features. In this circumstance, it is theoritically possible to make Augmented Reality program by pure C# coding. It is what I am tying to do here.

Useful Links

  • brains-N-Brawn/wpfAugReal. I use his great results, which is, ``ARToolKitPlus - modified to be a DLL and export C-style functions that can be pInvoked from C#'' and ``ARTKPManagedWrapper - C# wrapper for pInvoking ARToolKitPlus''. I express great thanks to him. MarkerMaker, which is also availbale in his site, is useful when one is willing to generate many markers all at once.
  • DirectShow.NET. It is a set of pure C# and public domain codes which wraps DirectShow, which is very useful when one is willing to add a video capturing feature to his/her C# program.
  • GML C++ Camera Calibration Toolbox. This is a standalone camera calibration program whose resulting parameters are compatible with ARToolkitPlus' camera calibration parameters. For detailed instruction of how to calibrate your camera, see this subsection.
  • The original ARToolkit page.
  • The original ARToolkitPlus page.

Sample Codes

Please visit the ``Download'' page. Currently a C# solution which implements a most basic feature of augmented reality, overlaying prism object on markes appear on a captured video image, is available. It uses DirectShow.Net for video capturing and Windows Presentation Foundation for 3D drawing, so no extra components needed. Visual C# 2008 is all you need to build the solution. For this reason it may be a good skelton for starters.

Now other C# solutions are also available.
  • ARWithWPFMiku: A 3D model of Miku HATSUNE is hovering and rotating above the marker.
  • ARWithWPFMikuEmitted: Miku-s are emitted from the marker and then free-falls.
  • WMPWPFTest: A simple skelton code for an implementation of Windows Media Player visualizer plugin. No AR features included. I write this skelton for a preparing purpose of making WMPEmitMiku.
  • WMPEmitMiku: A Windows Media Player visualizer plugin using augmented reality technology. The bandwidth of a music is split in 6 segments. The power corresponds to each segment decides emmitance rate of Miku-s.

Video





How to: Camera Calibration

You can use the GML Camera Calibration Toolbox to calibrate your PC camera by your own. For calibration to be executed, you need some (>=3) photos taken by the camera. Photos must satisfy some condition. See http://research.graphicon.ru/calibration/recommendations-for-taking-calibration-photos.html. PDF files availbale in ``Calibration pattern'' directry under the installation directry may be used as the chekerboard pattern. Further, note that the photos must have the same size. Let (xsize, ysize) be the size of the photo images.

The calibration results in the following set of parameters: focal length (fc_x, fc_y), principal point (cc_x, cc_y), distortion (kc1, kc2, kc3, kc4). Now make a text file which has the following format.

ARToolKitPlus_CamCal_Rev02
xsize ysize cc_x cc_y fc_x fc_y kc1 kc2 kc3 kc3 kc5 kc6 iter

``kc5'', ``kc6'' can be 0. The larger the ``iter'' be, the more accurate and the more slower the calculation be. I recommend  the value to be from 0 to 10.

To use your own calibration file with ``ARWithWPF'' C# program which can be downloaded from ``download'' page of this site,  please read the readme-en.txt or readme-jp.txt.