Lab 3 Augmented Reality
ARToolkit detecteer markers in 3D (Waarom is één camera genoeg?) Projecteert extra informatie bovenop werkelijkheid
Hough transformatie
Coördinaten Transformatie van markercoördinaten naar cameracoördinaten, rotatie+translatie rxx rxy rxz tx r yx ryy ryz ty rzx rzy rzz tz 0 0 0 1 laatste rij altijd 0 0 0 1: r r r t r r r t r r r t xx xy xz x yx yy yz y zx zy zz z
Coördinaten Inverse transformatie eenvoudig, rotatie is orthonormaal rxx rxy rxz tx r yx ryy ryz ty rzx rzy rzz tz 0 0 0 1 r r r t r r r t r r r t 0 0 0 1 xx yx zx x xy yy zy y xz yz zz z
Coördinaten Kolommen rotatie: richting van marker X, Y en Z as in camera assenstelsel r r r t r r r t r r r t xx xy xz x yx yy yz y zx zy zz z
3D Tranformaties 3D punt: kolomvector: [x, y, z, 1] T Marker matrix M Van marker coördinaten naar camera coördinaten: vermenigvuldig met M Van camera naar marker, vermenigvuldig met M 1 zie voorbeeldcode: Matrix world = XNAtoAR * trans * ARtoXNA;
Markers 80mm 80mm
Markers Maak eigen markers en bevestig ze bovenop de robots. Je mag ook extra markers plaatsen in omgeving Om zelf markers (pdf) te maken van jpeg afbeeldingen: http://www.osgart.org/index.php/creating_artoolkit_markers http://roarmot.co.nz/ar Gebruik mk_patt om de bijbehorende patt.x bestanden te maken
Tools to use LocateMarkers Runs AR Toolkit and sends marker information on a TCP connection XNAandAR (new) An XNA application with integrated AR library Kies één van beide
Tool LocateMarkers.exe LocateMarkers.exe zoekt markers in webcam beeld Gespecificeerd in een bestand object_data_ci zie documentatie Wacht op TCP client op poort 4242 Zendt dan data voor alle gedetecteerde markers naar de TCP client. Formaat: Marker n # (x, y, z) # [ ( rxx, ryx, rzx); (rxy, ryy, rzy); ( rxz, ryz, rzz)] # 0.0 #
Tool mk_patt.exe Eidere marker wordt beschreven met pattern bestand, bijv. patt.hiro met mk_patt.exe kun je eigen pattern files maken voor nieuwe markers
Augmented Reality Solution Visual Studio C#, AugmentedReality.sln AugmentedRealityLib klassen voor marshaling marker informatie over TCP TestClient testprogramma voor communicatie met LocateMarkers
AugmentedRealityLib Vector3D Matrix3D Marker: id, positie vector, oriëntatie matrix MarkerClient MessageReader
TestClient Voorbeeld C# applicatie om als client marker data te lezen van LocateMarkers tool Gebruikt AugmentedRealityLib Eerste aanzet to seriële communicatie (robots).net Framework: System.IO.Ports.SerialPort F1 in Visual Studio voor meer documentatie. Zend via de seriële link instructies naar robots over hun locatie / orientatie of beweging
Tips Robots / markers zijn altijd (bijna) op de vloer / parallel aan de vloer. Transformeer naar 2D! Camera scherpstellen Blokkering firewall opheffen als Windows daarom vraagt Make sure your webcam image is not mirrored! It may help to adjust the camera brightness and contrast settings
ARandXNA solution Directly integrates XNA with AR library Note that in the ARandXNA example, the AR library function is called with a parameter (1) indicating the number of the capture device to use. You may need to change it when your laptop has multiple devices (e.g., built incamera). If the setup method fails, check the Output window in Visual Studio for additional information.
ARandXNA solution The following dlls should be in the folder with the executable: ARlibrary.dll a wrapper for the AR library libarvideo.dll the actual AR library DSVL.dll the video processing library used by the AR library The Data directory should be in the same directory as the executable program you run Taken care of for the provided sample application
Data folder structure In the Data folder must be: WDM_camera2_flipV.xml an xml file with the settings to open the capture device you may experiment with the frame_width parameter chosing the camera resolution If the resolution does not exist a different one is chosen. Check the Height and Width variables in the XNA application to find the real size. 640/1024/1280 should work. Larger may be slower! Do not touch anything else unless you know what you are doing
Data folder structure In the Data folder must be: Camera_para.dat It contains the camera calibration data. Ideally one should recalibrate with the camera you are using, but the basic setting should do fine
Data folder structure In the Data folder must be: Object_data_ci A text file containing the descriptions of the markers the AR library will be looking for. For every marker it has A reference to a VRML model (not used, but must be kept!) Path to the marker pattern file (relative to the executable!) The size of the marker in mm (ususally 80.0) The logical center of the marker (usually 0.0 0.0) You can add new pattern data to this file
Data folder structure In the Data folder must finally be: The marker pattern files Patt.hiro, patt.kanji Contain the pattern information of the markers See elsewhere on how to create your own.
XNAandARGame XNAandARGame is a sample XNA application provided It shows the video capture image with information on the detected markers and adds models on top of the markers using the detected information The ARLibraryInterface class contains methods to activate a new marker detection cycle (updatear) and to obtain the detected marker information. See the XNAandAR application for examples of how to use these methods.
Opdracht Laat robots (al dan niet gecoördineerd) over een met witte lijnen begrensd speelveld lopen. Op speelveld staan objecten, detecteerbaar met de ultrasone afstandssensoren Observeer, en evt. stuur, de robots via de markers en een camera Visualiseer in 3D in XNA een kaart van het gebied bijv. huidige posities robots, gevonden grenzen, gevonden objecten Communiceer via Xbee met je robots
Opdracht Je eigen applicatie kan gebaseerd worden op het XNAandAR voorbeeld of TestClient met de externe LocateMarkers applicatie. (Een geheel nieuwe applicatie mag natuurlijk ook.) Als je XNAandAR gebruikt hoef je niet per se het opgenomen camera beeld weer te geven (maar het mag wel). Je kunt ook alleen de kaart visualiseren.