15/02/11

FlarToolkit / Flash Realidad Aumentada Getting Started Primeros pasos

FlarToolkit/Flash Augmented Reality
Primeros pasos Getting Started

FlarToolkit Makes Me Happy?

Últimamente he estado tratando de hacer algo de tiempo para jugar con FlarToolkit. Lately I've been trying to make some time to play around with FlarToolkit . Si usted no sabe lo que es FlarToolkit, FlarToolkit es una biblioteca de código fuente abierto para la Realidad Aumentada en Flash. Me lo explique más detalladamente aquí, en este post . If you don't know what FlarToolkit is, FlarToolkit is an open source code library for Augmented Reality in Flash. I explain it more detail here in this post .

Para este post me decidí a explicar sin embargo la manera de empezar a desarrollar con FlarToolkit. For this post I decided to however explain how to start developing with FlarToolkit. FlarToolkit es un poco más difíciles de recoger y correr con sólo porque casi todos los comentarios en el código está en japonés así que si quieres seguir el código (y usted no habla japonés) que realmente tienen que profundizar veces y leer con cuidado. FlarToolkit is a bit harder to pickup and just run with because almost all of the commenting in the code is in Japanese so if you want follow the code (and you do not speak Japanese) you really have to sometimes dig deep and read carefully.

Antes de ir más lejos descargar este ejemplo . Before you go any further download this example . Se trata básicamente de ejemplo simple cubo Saqoosha, pero sólo un poco simplificada para facilitar la lectura. It's basically Saqoosha's simple cube example but just simplified a bit for readability.

Ahora vamos a empezar a trabajar en FlarToolkit: Now let's get started on FlarToolkit:

Paso 1: Descargue Step 1: Download
La primera vez que fui al blog de Saqoosha ni siquiera estaba usando el traductor de Google para traducir la página, pero vi tres letras familiares "SVN". The very first time I went to Saqoosha's blog I wasn't even using the Google Translater to translate the page but I saw three familiar letters “SVN”. HAH ... Tengo muy emocionado de poder descargar el FlarToolkit entero. HAH… I got very excited to be able to download the entire FlarToolkit.

Descargar FlarToolkit desde el siguiente enlace: Download FlarToolkit from the following url:

http://www.libspark.org/svn/as3/FLARToolKit/trunk http://www.libspark.org/svn/as3/FLARToolKit/trunk

Si usted nunca ha usado antes de SVN por favor visita este enlace . If you've never used SVN before please check out this link . En él se explica cómo descargar Papervision tan sólo tienes que seguir todo lo más que utilizar el enlace de arriba. It explains how to download Papervision so just follow everything else but use the link above.

Paso 2: Inspeccione Step 2: Inspect
Esto es lo que hago cuando estoy tratando de aprender cómo utilizar alguna biblioteca particular. This is what I do when I'm trying to learn how to use some particular library. Empiezo por mirar ejemplos o la inspección de la biblioteca de código. I begin by looking at examples or inspecting the code library. Voy a tratar de resumir lo que he descubierto mientras inspeccionaba FlarToolkit. I'll try to summarize what I've found out while inspecting FlarToolkit.

Empecé siguiente SimpleCube ejemplo Saqoosha. I started out following Saqoosha's SimpleCube example . Yo personalmente no le gustaba la forma en que fue escrito para una aplicación de ejemplo. I personally did not like how it was written for an example app. (Aunque para la reutilización de la forma en que está escrito es bastante bueno) En este ejemplo hay tres clases ARAppBase, PV3DARApp, y finalmente SimpleCube. (although for re-usability the way it is written is pretty good) In that example there are three classes ARAppBase , PV3DARApp , and finally SimpleCube .

Cada una de las tres clases maneja una parte de la aplicación de AR, pero es difícil de seguir porque PV3DARApp ARAppBase se extiende y se extiende SimpleCube PV3DARApp. Each of the 3 classes handles one part of the AR app but it's hard to follow because PV3DARApp extends ARAppBase and SimpleCube extends PV3DARApp . Así que por causa de simplicidad que combina todas estas tres clases en una clase. So for simplicities sake I combined all these 3 classes into one class. (Menos reutilizable más fácil de seguir) (less re-usable easier to follow)

Si no se ha descargado el ejemplo anterior descargarlo ahora If you didn't download the example above download it now

Hay 4 partes de una aplicación FLAR. There are 4 parts to a Flar app.
1. 1. Cámara archivo de parámetros Camera parameter file
2. 2. Marcador de archivo Marker file
3. 3. Marcador detector de Marker detector
4. 4. Flar nodo Base Flar Base Node
5. 5. Papervision Papervision

Parámetros de la cámara Camera Parameters
El archivo de parámetros de la cámara es un archivo binario que se carga pulg No tenía ni idea en un principio lo que este archivo se acerca, pero seguí Saqoosha del blog y le preguntó qué se trata todo esto y que las EFS es un archivo que viene de un programa que viene con ARToolkit . The camera parameter file is a binary file that is loaded in. I had no idea at first what this file was about, but I went on Saqoosha's blog and asked him what this is all about and he sais it's a file that comes from a program that comes with ARToolkit . (El original FlarToolkit aplicación original fue portado a) El programa que genera estos archivos se llama "calib_camera2". (the original original app FLARToolkit was ported from) The program that generates these files is called “ calib_camera2” .

Calib_camera2 crea el archivo binario y los datos de ese archivo binario se utiliza para corregir la distorsión de la lente de su cámara web. Calib_camera2 creates the binary file and the data from that binary file is used to correct lens distortion from your webcam. Puede descargar el programa aquí , sin embargo creo que con el mismo "camera_para.dat" que viene con FlarToolkit debe estar bien. You can download that program here , however I think using the same “camera_para.dat” that comes with FLARToolkit should be fine. (Supongo que esto es lo que la mayoría de la gente está haciendo) (I'm guessing this is what most people are doing)

Marcador Archivo Marker File
El archivo de marcador es un patrón que FLAR buscará desde tu webcam. The marker file is a pattern that Flar will look for from your webcam. Si usted abre el archivo de marcadores, la mía está en "lib / mikko.pat", te darás cuenta de que hay cuatro matrices de 16 × 48. If you open up the marker file, mine is in “lib/mikko.pat” , you'll notice that there are four 16×48 matrices. Este es el marcador de 4 direcciones diferentes. This is your marker from 4 different directions. Flar ve su marcador como un código de barras de 16 × 16 2d. Flar sees your marker as a 16×16 2d barcode. En el archivo de cada matriz es de 16 × 48, porque en realidad es de 16 por 16 veces tres colores (rojo, verde y azul). In the file each matrix is 16×48 because it's actually 16 by 16 times three colours (red, green, and blue).
Saqoosha ha creado una aplicación de aire para crear estos archivos marcador. Saqoosha has created an Air app for creating these marker files . Usted puede descargar esa aplicación aérea de aquí . You can download that Air app from here .


A continuación, siga los siguientes pasos: Then follow the following steps:

1. 1. Diseño de un marcador con las siguientes especificaciones. Design a marker using the following specs. Usted puede poner lo que quieras en el centro de la plaza, aunque creo que algunas formas de trabajo mejores que otros para experimentar. You can put whatever you want in the middle of the square although I think some shapes work better than others so experiment.

Flar Toolkit Marker Guide
2. 2. Imprima el marcador de abrir la aplicación de aire y apunte el marcador a su cámara web. Print out the marker open up the air app and point the marker at your webcam. Cuando usted consigue un cuadro rojo alrededor de su marcador clic en "Guardar Patrón" y ya está. When you get a red square around your marker hit “Save Pattern” and you're done.

Los dos archivos son uno de los mayores obstáculos para mí para empezar a desarrollar con FlarToolkit. Those two files were one of the biggest hindrances for me to start developing with FlarToolkit. Siempre he sido una de esas personas que quiere saber cómo funcionan las cosas y sólo va alrededor sin saber lo que estos archivos se me estaba matando. I've always been one of those people who wants to know how things work and just going about without knowing what these files were was killing me.

Marcador Detector Marker Detector
El detector marcador simplemente con tan sólo mirar a través de su BitmapData que está dibujando de la cámara y buscar el patrón de marcadores definidos en el archivo de marcadores. The marker detector will simply just look through your BitmapData you are drawing from the camera and look for the marker pattern defined in your marker file. Una vez que se encuentra el marcador que le permitirá saber que se encuentran el marcador y luego le dan una "confianza" porcentaje para la búsqueda de su marcador. Once it finds your marker it will let you know it found the marker and then give you a “confidence” percentage for finding your marker. Después de esto usted puede obtener una traducción de la matriz para manipular su FLAR Base nodo. After this you can get a translation matrix to manipulate your Flar Base Node .

Flar nodo Base Flar Base Node
El FLAR Base nodo es sólo un DisplayObject3d Papervision que usted puede lanzar su material en 3D (en el caso de mi ejemplo de un plano y un cubo). The Flar Base Node is just a Papervision DisplayObject3d that you can throw your 3d stuff into (in my example's case a plane and a cube). Se aplicará la matriz de transformación recibido de marcador detector para hacer su mirada cosas 3d derecha. You will apply the transformation matrix received from Marker Detector to make your 3d stuff look right.

Papervision Papervision
Esta es la última pieza del rompecabezas para una aplicación FLAR y realmente no quiero entrar en demasiados detalles acerca de esto. This is the last piece of the puzzle for a Flar app and really I don't want to go into too much detail about this one. Si usted está interesado en Papervision sólo tiene que ir a Google y buscar Papervision. If you are interested in Papervision just go on Google and look for Papervision. Hay un montón de información sobre Papervision por ahí. There is a ton of information on Papervision out there.

Algunos errores SOME GOTCHAS
He encontrado dos aspectos críticos en el desarrollo con FlarToolkit hasta ahora. I've found two gotchas when developing with FlarToolkit so far.

1. 1. La primera vez que intenta compilar FlarToolkit después de conseguir Papervision incluso los ejemplos no se compilará y obtendrá este mensaje de error: The very first time you try to compile FlarToolkit after getting Papervision even the examples will not compile and you will get this error message:

Error: Intento de acceso _projection propiedad inaccesibles a través de una referencia con tipo estático org.libspark.flartoolkit.pv3d: FLARCamera3D. Error: Attempted access of inaccessible property _projection through a reference with static type org.libspark.flartoolkit.pv3d:FLARCamera3D.

Para solucionar este problema basta con ir a la clase- To fix this just go into the class-
org.papervision3d.cameras.Camera3D org.papervision3d.cameras.Camera3D

Y cambia la línea And change the line-
var _projection privado: Matrix3D; private var _projection:Matrix3D;
a to
protegidas var _projection: Matrix3D; protected var _projection:Matrix3D;

Esto no va a romper Papervision sin embargo, sólo se permiten los FlarCamera3D FlarToolkit utilizar la matriz de proyección de la clase Camera3d. This will not break Papervision however it will just allow FlarToolkit's FlarCamera3D to use the projection matrix of the Camera3d class.

2. 2. Se trata de un gotcha que ni siquiera estoy seguro de lo que está pasando. This is a gotcha where I'm not even sure what is going on. Por alguna razón, usted tiene que fijar la vista Papervision a ser dos veces el tamaño de tu vídeo. For some reason you have to set the Papervision viewport to be twice the size of your video. Si no lo hace su escena renderizada en 3D no se alineará con el vídeo de la cámara web. If you do not do this your rendered 3d scene will not line up with your video from the webcam. Incluso después de haber hecho esto, las cosas todavía no parecen alinearse perfectamente. Even after you've done this, things still don't seem to line up perfectly. En el ejemplo Saqoosha de que las compensaciones de la vista por otro -4 píxeles. In Saqoosha's example he offsets the viewport by another -4 pixels. En realidad no me apetece hacer esto porque no quería que se confunda nadie, ya que la ampliación de 2 veces puede. I didn't really feel like doing this because I didn't want it to confuse anyone anymore than scaling up 2 times might.

Lo demás depende de ti. He comentado mi código de fondo por lo que es bastante fácil de seguir. Now the rest is up to you. I've commented my code thoroughly so it's quite easy to follow. Espero que este post se ha llenado en algunos de los espacios en blanco sobre el desarrollo FlarToolkit. I hope this post has filled in some of the blanks about FLARToolkit development. Si usted tiene alguna pregunta por favor no dude en preguntar a continuación. If you have any questions please feel free to ask below. No sé todas las respuestas, porque estoy aprendiendo estas cosas también, pero voy a tratar de hacer mi mejor esfuerzo para responderlas. I don't know all the answers because I'm learning this stuff too but I'll try to do my best to answer them.

2 comentarios:

Anónimo dijo...

Hi checkout this amazing project from random interactive:

Create AR apps just using an XML config file !!

https://github.com/hassanvfx/openRAXT

kaareem9 dijo...

Hello
En nuestra empresa venimos realizando diseño e implementaciones de juegos serios para la Formación de Recursos Humanos, desde hace varios años. Involucramos diversas tecnologías, nivelando la cuota de juego versus la cuota de conocimientos que deben adquirirse, optimizando los resultados

realidad aumentada