FLARCodeImage:Utility for FLARToolKit

Source of FLARCodeImage

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
/* 
 * PROJECT: FLARToolKit
 * --------------------------------------------------------------------------------
 * This work is based on the NyARToolKit developed by
 *   R.Iizuka (nyatla)
 * http://nyatla.jp/nyatoolkit/
 *
 * The FLARToolKit is ActionScript 3.0 version ARToolkit class library.
 * Copyright (C)2008 Saqoosha
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this framework; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 * 
 * For further information please contact.
 *    http://www.libspark.org/wiki/saqoosha/FLARToolKit
 *    <saq(at)saqoosha.net>
 * 
 * For further information of this Class please contact.
 *    http://www.libspark.org/wiki/saqoosha/FLARToolKit
 *    <taro(at)tarotaro.org>
 *
 */
package org.tarotaro.flash.ar 
{
    import flash.display.Bitmap;
    import flash.display.BitmapData;
    import flash.display.Shape;
    import flash.display.Sprite;
    import org.libspark.flartoolkit.core.FLARCode;
 
    /**
     * ...
     * @author tarotarorg
     */
    public class FLARCodeImage extends Sprite
    {
        private var _image:Bitmap;
        private var _code:FLARCode;
 
        public function FLARCodeImage(code:FLARCode,width:uint = 320,height:uint = 320) 
        {
            this._code = code;
            var patBW:Array = this._code.getPatBW()[0];
            var pWidth:int = this._code.getWidth();
            var pHeight:int =this._code.getHeight();
 
            var bmp:BitmapData = new BitmapData(pWidth, pHeight);
            var bw:uint;
            var color:uint;
            for (var x:uint = 0; x < pWidth; x++) {
                for (var y:uint = 0; y < pHeight; y++) {//(0:R/1:G/2:B)
                    bw = (255-((patBW[y][x] & 0xFF) + this._code.averageOfPattern))&0xFF;
                    color = (bw << 16) | (bw << 8) | bw;
                    bmp.setPixel(x, y, color);
                }
            }
 
            var shape:Shape = new Shape();
            var image:Bitmap = new Bitmap(bmp);
            image.scaleX = image.scaleY = height / image.height;
 
 
            shape.graphics.lineStyle(1);
            shape.graphics.drawRect(0,0,image.width,image.height);
            this.addChild(image);
            this.addChild(shape);
        }
 
    }
 
}
Ads

Ad

Ad

Share

  • Add this article to hatena bookmark
  • 0

Follow

Ads

Ad

Comments

  1. oruchreis says:

    Hi,
    I’m trying to calculate 3D position of a mouse click position by detected marker’s plane. Is there any easy way to find 3D postion on the marker’s plane? I’ve tried to intersect 2D position with marker’s plane. I can get the ray vector fo the mouse click position by flarCamera3D’s unproject method. I also can get the marker’s 3D position. But I need to find the normal vector of the marker’s plane. So I can build a plane3D with setNormalAndPoint method. Then I can intersect the ray with this plane and the result will be the 3D position of the 2D mouse position. My codes are here:
    var ray:Number3D = flarCamera3D.unproject(mouse.x,mouse.y);
    var p:Plane3D = new Plane3D();
    var normal: Number3D = I DONT KNOW HOW TO FIND??
    p.setNormalAndPoint(normal, markerPosition);
    var intersect:Number3D = p.getIntersectionLineNumbers(flarCamera3D.position, ray);

    I will appreciated if you can help, I didn’t any solutions for days.

  2. tarotarorg says:

    Hi, oruchreis.

    Sorry. I could not find a solution for you.

    Thank you.

Leave a Comment

Your email address will not be published. Required fields are marked *