こんちわ。さくーしゃです。
えーと、巷では Flash Player 10 beta で騒がしい感じになってきておりますが、そんな中、わたくしは ARToolKit を Flash (AS3) に移植してました。FLARToolKit と命名しておきましょう。まー、移植つっても本家からじゃなくって A虎@nyatla.jp 氏が Java に移植した NyARToolkit を AS3 で書き直したものなんだけど。言語仕様が近いだけあって C 版よりもはるかに移植しやすかったですな。
やっぱでもねー、速度的にはかなり厳しいもんがあるな。ラベリングの部分は Bitmap 師匠のコードをベースにほとんど書き直したんだけど、それでも複数マーカーの認識とかってのはかなり無理がありそう。
3D 表示部分も現状の Flash だとソフトウェアレンダリング(デモでは Papervision3D 使ってる)しか手がないわけで、そのへんもかなり足を引っ張る。(Astro なったらそのへんはある程度解消されるだろけど。)
つーわけで、まだいろいろ制限はあるものの Webcam とプリントされたマーカーさえあればブラウザだけでさくっと体験できちゃう Flash 版てのはお手軽でいーんじゃないかと思います。作るのも簡単だしね。
↓こちらが実際に動いてるデモ。
/a/labs/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.
Comments (25)
blogのコメント欄を見て飛んできました。
ActionScript3版の実装成功おめでとうございます。
私も同じ構成で作ろうとしていたんですが、先を越されちゃいましたねw
JavaよりもFlashの方がユーザーに近いですし、色んな応用が出てくるんじゃないかと、個人的には楽しみにしてます。
開発頑張ってくださいネ
PS.
mixiにNyARToolkitのコミュニティがあります。よければ遊びに来てください。http://mixi.jp/view_community.pl?id=3311281
アストロのPixelBender使って、ラベリングの処理をFlashの外に出しちゃったら、結構スピードアップするんじゃないっすか??
NyarToolkit DemoをAppletにしたりしております。
FLARToolKitサッソク試してみました!さくさく動きますねー!
オモロイもん期待してます☆
今日のteracoはスゴイコトになっている予感。w
> A虎@さん
すいませんすいません。公開したらコメントしにいこうとおもって、ブログ書いてたらそのまま忘れてたす。
AS3 化は実は NyARToolKit 0.7 ぐらいのときにやっちゃってて、なんかおもしろコンテンツとともに出そうとおもってたんですけどなかなかできなくって、A虎@さんのブログにちらっと AS3 版の話がでてたんでもーいーやって出しちゃいましたw
mixi にコミュなんてあったんですねー。チェックしまーす。
> fladdict さ
Flex でプロファイリングしてるとラベリングよりはマーカーのパターンマッチングのほうが重いかんじ。まー、いずれにしても Pixel Bender をうまく使えば高速化できるとはおもうねー。3D も Astro 版 Papervision とか出ればかなり使えるもんになるんじゃなかろうか。
> Shinobu さ
Applet も使ってみるっていうところでは Flash とさほど変わんないですよね。Processing から使えるようにすればそっちのがいろいろと強力な気も。。
> れんさっ
あー、まー、でも、そなにスゴイコトにもなってないw
AS版を開発してること教えてもらえてたら、多分私は作りませんでしたよw
結果として慌てさせてしまったようで…申し訳ない。
(でもインパクトのある開発は、こっそりやりたいときもありますよねw)
表示系の件、blogのコメント欄に参考にする資料載せときました。もしよければ見てみてください。
あはは。ええまあちょっと内部事情もありまして。。w
資料ありがとうございます。ちょっと試してみますー。
ブログにて紹介させていただきました.
これを応用して何か実用的なものが作れるといいなーと
期待しております.
こんんんにちわ。紹介ありがとうございます。
そですねー、こっから何を作るかってのが重要ですよねー。うーむ。
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 ;)
I've fixed and commited to repository.
Enjoy!
See more augmented reality demos, devices and engines at www.gamesalfresco.com.
Many, many thanks for sharing this with the world.
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.
Sorry, I can't understand your problem. please tell me more detail.
can you contact me : tim_timmers @@@ hotmail dot com ?
Thanks!
Sweet work Saqoosha!
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
Thanks in advance!
Good luck
The class org.libspark.flartoolkit.detector.FLARDetectMarker is for multi marker detection. but I have not used this class.
If you succeed, please report!
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);
}
}
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
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/en/2008/06/05/676/ (currently in Japanese only, sorry.)
Could you please give me some guidelines.
Thanks
Srikanth