Saqoosha.net

  1. About
  2. Archives
  3. Search
  4. Say
Language:

ARToolKit を Flash に移植したよ。

こんちわ。さくーしゃです。
えーと、巷では Flash Player 10 beta で騒がしい感じになってきておりますが、そんな中、わたくしは ARToolKit を Flash (AS3) に移植してました。FLARToolKit と命名しておきましょう。まー、移植つっても本家からじゃなくって A虎@nyatla.jp 氏が Java に移植した NyARToolkit を AS3 で書き直したものなんだけど。言語仕様が近いだけあって C 版よりもはるかに移植しやすかったですな。

やっぱでもねー、速度的にはかなり厳しいもんがあるな。ラベリングの部分は Bitmap 師匠のコードをベースにほとんど書き直したんだけど、それでも複数マーカーの認識とかってのはかなり無理がありそう。

3D 表示部分も現状の Flash だとソフトウェアレンダリング(デモでは Papervision3D 使ってる)しか手がないわけで、そのへんもかなり足を引っ張る。(Astro なったらそのへんはある程度解消されるだろけど。)

つーわけで、まだいろいろ制限はあるものの Webcam とプリントされたマーカーさえあればブラウザだけでさくっと体験できちゃう Flash 版てのはお手軽でいーんじゃないかと思います。作るのも簡単だしね。

↓こちらが実際に動いてるデモ。
http://saqoosha.net/lab/FLARToolKit/
(※このマーカーをプリントして使ってくださいな → pattHiro.pdf

んでもってソースコードは Spark Project にコミットしてあるので適当にどーぞ。ライセンスは NyARToolKit が GPL なので FLARToolKit も GPL てことになりますな。(ソース内の Copyright 表記が NyARToolKit のまんまなんだけど追々なおします。。)まだ速度的にチューニングできる部分は結構残ってるので興味あるひとはいじってやってください。

さあて、これでなんかオモロイもんつくろかのー。

追記 (5/17 1:45):trick7 の人が体験ムービーをアップしてくれてるよ!wwww

追記(8/3 20:00):サンプルで使ってる Papervision3D (GrateWhite)、どうやら最新リビジョンではカメラ関係のクラスが結構かわってるようで、動かなくなったらしい。そのうち直す。
追記(8/14 2:40):↑直した。GreatWhite の Camera3D クラスにも手をいれないとダメなのがにんともかんとも。。。

追記(2008/12/5):フォーラムできました。FLARToolKit についてのいろいろはこちらで。

English version project page available now! (Special thanks to daoki2)

Edit (2008/12/5): FLARToolKit forum is setup. Please use this forum to exchange infomation about FLARToolKit.

25 Responses to “ARToolKit を Flash に移植したよ。”

  1. A虎@ Says:

    こんばんは。はじめまして。

    blogのコメント欄を見て飛んできました。

    ActionScript3版の実装成功おめでとうございます。
    私も同じ構成で作ろうとしていたんですが、先を越されちゃいましたねw

    JavaよりもFlashの方がユーザーに近いですし、色んな応用が出てくるんじゃないかと、個人的には楽しみにしてます。

    開発頑張ってくださいネ

    PS.
    mixiにNyARToolkitのコミュニティがあります。よければ遊びに来てください。http://mixi.jp/view_community.pl?id=3311281

  2. fladdict Says:

    スゴス!!!

    アストロのPixelBender使って、ラベリングの処理をFlashの外に出しちゃったら、結構スピードアップするんじゃないっすか??

  3. Shinobu Says:

    はじめまして。しのぶです。
    NyarToolkit DemoをAppletにしたりしております。

    FLARToolKitサッソク試してみました!さくさく動きますねー!
    オモロイもん期待してます☆

  4. れん Says:

    誰かやるとは思っていましたが流石!
    今日のteracoはスゴイコトになっている予感。w

  5. Saqoosha Says:

    みなさんこんにちわ。

    > A虎@さん
    すいませんすいません。公開したらコメントしにいこうとおもって、ブログ書いてたらそのまま忘れてたす。
    AS3 化は実は NyARToolKit 0.7 ぐらいのときにやっちゃってて、なんかおもしろコンテンツとともに出そうとおもってたんですけどなかなかできなくって、A虎@さんのブログにちらっと AS3 版の話がでてたんでもーいーやって出しちゃいましたw
    mixi にコミュなんてあったんですねー。チェックしまーす。

    > fladdict さ
    Flex でプロファイリングしてるとラベリングよりはマーカーのパターンマッチングのほうが重いかんじ。まー、いずれにしても Pixel Bender をうまく使えば高速化できるとはおもうねー。3D も Astro 版 Papervision とか出ればかなり使えるもんになるんじゃなかろうか。

    > Shinobu さ
    Applet も使ってみるっていうところでは Flash とさほど変わんないですよね。Processing から使えるようにすればそっちのがいろいろと強力な気も。。

    > れんさっ
    あー、まー、でも、そなにスゴイコトにもなってないw

  6. A虎@ Says:

    こんにちは。

    AS版を開発してること教えてもらえてたら、多分私は作りませんでしたよw
    結果として慌てさせてしまったようで…申し訳ない。

    (でもインパクトのある開発は、こっそりやりたいときもありますよねw)

    表示系の件、blogのコメント欄に参考にする資料載せときました。もしよければ見てみてください。

  7. Saqoosha Says:

    > A虎@ さん
    あはは。ええまあちょっと内部事情もありまして。。w
    資料ありがとうございます。ちょっと試してみますー。

  8. なおき Says:

    こんにちはー Flashへの移植おめでとうございます.
    ブログにて紹介させていただきました.
    これを応用して何か実用的なものが作れるといいなーと
    期待しております.

  9. Saqoosha Says:

    > なおきさん
    こんんんにちわ。紹介ありがとうございます。
    そですねー、こっから何を作るかってのが重要ですよねー。うーむ。

  10. prayone Says:

    Hi !
    Sorry I can’t read nor speak japanese…
    You made a amazing work !

    I just found a bug with the multi marker detector :
    file FLARMultiMarkerDetector.as, line 155
    replace
    var c2:int = match_patt.getConfidence();
    by
    var c2:Number = match_patt.getConfidence();

    Keep up the good work ;)

  11. Saqoosha Says:

    Thanks, prayone!
    I’ve fixed and commited to repository.
    Enjoy!

  12. Raz-L Says:

    kudos ! this is awesome, someone had to write this in flash, you’re genius.

  13. Ori Inbar Says:

    You guys rock! This is as close to Do-it-yourself augmented reality that I have seen.
    See more augmented reality demos, devices and engines at http://www.gamesalfresco.com.
    Many, many thanks for sharing this with the world.

  14. taniss Says:

    Sorry for writing in english.
    I downloaded your FLARToolkit Class, and I can’t make it work properly. I’m loading a specific pattern (patt file), but i’m getting every pattern recognized as the same. Even the example that you post, works the same with any black square drawn in a paper (it’s not necessary to print patt.hiro, it works with any pattern, wich is wrogn). If you could post some directions on this, it would be great! And… Congratulations for your work! Cheers.

  15. Saqoosha Says:

    Hi, tannis.
    Sorry, I can’t understand your problem. please tell me more detail.

  16. taniss Says:

    thanks, I already fixed it. The problem is that when only one marker is on the screen, the SingleMarkerDetector takes it as the correct marker. What I did, is force the script to check the level of confidence, not against another marker on screen (since of course ther isn’t another), but to check against an average value (for example, I set 0.65). I’m getting really good results with that, actually if I point my camera to a marker that is not the one I loaded, nothing is drawn on the screen. Wich is what I needed, of course. Anything you need, please write me an e-mail, i’ll be glad to answer, and once again, congratulations for your work.

  17. Timbo Says:

    hi Taniss, I have the same problem.
    can you contact me : tim_timmers @@@ hotmail dot com ?

    Thanks!

    Sweet work Saqoosha!

  18. Tom Says:

    Hi!

    That’s really great work!
    Unfortunately I only can watch the demo. I tried to checkout (with subversion) the files but I always get an error “XML data was not well-formed”. Did I do a mistake or isn’t the code located at http://www.libspark.org/browser/as3/FLARToolKit/trunk/ anymore?
    I’d really be glad to have a look at it too!
    Thanks a lot!

    Tom

  19. psilos Says:

    Is it possible to detect more than one markers at the moment? I have seen the samples and its using SingleMarkerDetector. Is there any example with more than one markers?

    Thanks in advance!

  20. psilos Says:

    Hey Tom, I had the same problem. The proper svn address would be http://www.libspark.org/svn/as3/FLARToolKit/trunk.

    Good luck

  21. Saqoosha Says:

    to psilos.
    The class org.libspark.flartoolkit.detector.FLARDetectMarker is for multi marker detection. but I have not used this class.
    If you succeed, please report!

  22. Jay Says:

    in response to psilos.

    i’ve had mixed results using the multimarker class. Basically what it does is take an array of markers and loops through them looking for the ar marker.
    but it doesnt work as well as the simple marker and I still havent figure out why. maybe something wrong with my code.

    heres what i’ve done:

    1. load 2 or more markers

    var codes:Array = new Array();
    var widths:Array = new Array();

    _code = new FLARCode(16, 16);
    _code.loadFromURL(“../Data/marker1.pat”);
    codes.push(_code);

    _code = new FLARCode(16, 16);
    _code.loadFromURL(“../Data/marker2.pat”);
    codes.push(_code);

    widths.push(MARKER_SIZE);
    widths.push(MARKER_SIZE);

    this._ctx.mdetector = new FLARMultiMarkerDetector(this._param, codes, widths);

    2. then create a nodes array and push the Flar nodes into it:
    nodes.push(this._scene.addChild(new FLARBaseNode()));

    3. create papervision objects and add them as childs of the nodes created:
    nodes[0].addChild(new Plane(wmat, MARKER_SIZE, MARKER_SIZE));
    nodes[1].addChild(new Plane(wmat, MARKER_SIZE, MARKER_SIZE));

    4. in your application loop check which markers are being detected:

    var i:int = nodes.length;
    while (i– > 0)
    {
    nodes[i].visible = false;
    if (this._ctx.mdetector.detectMarkerLite(this._ctx.raster, 100) && this._ctx.mdetector.getConfidence(i) > 0.5)
    {
    trace(i + ” ” + this._ctx.mdetector.getConfidence(i));
    this._ctx.mdetector.getTranslationMatrix(i,this._ctx.resultMat);
    nodes[i].visible = true;
    nodes[i].setTranslationMatrix(this._ctx.resultMat);
    }
    }

  23. Tom Says:

    Hi, I’ve just looked into this and it stuff is sweet.
    I’ve got a question thou. Is it possible to use a different marker rather than a square? I was thinking using a circle with a dash across it like the London underground logo:
    http://subtitlestocinema.files.wordpress.com/2008/11/london_underground_logo.jpg
    Any ideas how to achieve that?

    Thanks

  24. Saqoosha Says:

    Hi Tom,
    It’s impossible to use other than the square for the marker in FLARToolKit. But you can design inside of square. Please refer http://saqoosha.net/2008/06/05/676/ (currently in Japanese only, sorry.)

  25. Srikanth Says:

    Hi.. i want to work with NyARToolkit..
    Could you please give me some guidelines.

    Thanks

    Srikanth

Leave a Reply



Saqoosha.net は Windows なら Internet Explorer 7, Firefox 3, Safari 3, Mac なら Firefox 3, Safari 3 でいい感じになるように作ってありますのでそれ以外のブラウザでは Saqoosha が意図しない見た目になっている可能性がありますのでよろしくです。
どうやら Flash Player の最新版がインストールされていないようです。こちらから最新版をインストールするともうちょっと素敵な Saqoosha.net を見ることができるかもしれません → Flash Player Download