In case Flash no longer exists; a copy of this site is included in the Flashpoint archive's "ultimate" collection.

Dead Code Preservation :: Archived AS3 works from wonderfl.net

FLARToolkit 2値化された解析画像を表示確認(thresholded BitmapData of source image)

FLARToolkit multi maker
* [2値化された解析画像を表示確認(thresholded BitmapData of source image)] 
*  
* 
* 単純に FLARMultiMarkerDetector.thresholdedBitmapData
* をBitmapにしてaddChildeしただけ。
*
* クリックで「表示/非表示」切り替え。
*  change Visible thresholdeImage
* 
* マルチマーカーデテクターにはthresholdedBitmapDataがあるけど
* シングルマーカーデテクターには無いのはなぜだろう??( ´д`; )
*
*
* TODO : しきい値の値は動的にかえられるのだろうか?調べてみる
*
/**
 * Copyright romatica ( http://wonderfl.net/user/romatica )
 * GNU General Public License, v3 ( http://www.gnu.org/licenses/quick-guide-gplv3.html )
 * Downloaded from: http://wonderfl.net/c/4kW6
 */

// forked from tarotarorg's FLARToolKit Multi Marker Sample(FLAR, Hiro)
/*
* FLARToolkit multi maker
* [2値化された解析画像を表示確認(thresholded BitmapData of source image)] 
*  
* 
* 単純に FLARMultiMarkerDetector.thresholdedBitmapData
* をBitmapにしてaddChildeしただけ。
*
* クリックで「表示/非表示」切り替え。
*  change Visible thresholdeImage
* 
* マルチマーカーデテクターにはthresholdedBitmapDataがあるけど
* シングルマーカーデテクターには無いのはなぜだろう??( ´д`; )
*
*
* TODO : しきい値の値は動的にかえられるのだろうか?調べてみる
*
*/

package 
{
	import flash.display.*;
	import flash.events.*;
	import flash.geom.Rectangle;
	import flash.media.*;
	import org.libspark.flartoolkit.core.FLARCode;
	import org.libspark.flartoolkit.core.param.FLARParam;
	import org.libspark.flartoolkit.core.raster.rgb.FLARRgbRaster_BitmapData;
	import org.libspark.flartoolkit.core.transmat.FLARTransMatResult;
	import org.libspark.flartoolkit.detector.FLARMultiMarkerDetector;
	import org.libspark.flartoolkit.support.pv3d.*;
	import org.papervision3d.lights.PointLight3D;
	import org.papervision3d.materials.*;
	import org.papervision3d.materials.shadematerials.FlatShadeMaterial;
	import org.papervision3d.materials.utils.MaterialsList;
	import org.papervision3d.objects.primitives.*;
	import org.papervision3d.render.LazyRenderEngine;
	import org.papervision3d.scenes.Scene3D;
	import org.papervision3d.view.Viewport3D;

	public class MultiMarkerTest extends Sprite
	{
		protected var _param:FLARParam;
		protected var _code:FLARCode;
		protected var _raster:FLARRgbRaster_BitmapData;
		protected var _detector:FLARMultiMarkerDetector;
		
		protected var _webcam:Camera;
		protected var _video:Video;
		protected var _capture:Bitmap;
		protected var _base:Sprite;
		protected var _viewport:Viewport3D;
		protected var _camera3d:FLARCamera3D;
		protected var _scene:Scene3D;
		protected var _renderer:LazyRenderEngine;
		protected var _markerNodes:Array;
		
		protected var _resultMat:FLARTransMatResult = new FLARTransMatResult();
		protected var _detectedResults:Array;
		protected var therBMD:Bitmap;
		public function MultiMarkerTest() 
		{
			_param = new FLARParam();
			_param.changeScreenSize(320, 240);
			var flarCode:FLARCode = new FLARCode(16, 16);
			flarCode.loadARPatt(" 255 255 255 255 255 255 191   0   0 159 255 255   0   0   0   0\r\n" + 
								" 255 255 255 255  87  63  47   0   0 159 255 255   0   0   0   0\r\n" + 
								" 255 255 255 255  31   0   0   0   0 159 255 255   0   0   0   0\r\n" + 
								" 255 255 255 255  31   0   0   0   0 159 255 255   0   0   0   0\r\n" + 
								" 255  95   0   0   0   0   0   0   0 159 255 255 239 239 239 239\r\n" + 
								" 255  95   0   0   0   0   0   0   0 159 255 255 255 255 255 255\r\n" + 
								" 175  65   0   0   0   0   0   0   0 109 175 175 175 175 175 175\r\n" + 
								"   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0\r\n" + 
								"   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0\r\n" + 
								"   0  71 127 127  15   0   0   0   0  79 127 127 127 127 127 127\r\n" + 
								"   0 143 255 255  31   0   0   0   0 159 255 255 255 255 255 255\r\n" + 
								"   0 143 255 255  31   0   0   0   0 159 255 255 255 255 255 255\r\n" + 
								" 191 227 255 255 199 191 143   0   0 159 255 255 255 255 207  63\r\n" + 
								" 255 255 255 255 255 255 191   0   0 159 255 255 255 255 191   0\r\n" + 
								" 255 235 223 223 249 255 191   0   0 159 255 255 223 223 171  15\r\n" + 
								" 255  95   0   0 207 255 191   0   0 159 255 255   0   0  63 255\r\n" + 
								" 255 255 255 255 255 255 191   0   0 159 255 255   0   0   0   0\r\n" + 
								" 255 255 255 255  87  63  47   0   0 159 255 255   0   0   0   0\r\n" + 
								" 255 255 255 255  31   0   0   0   0 159 255 255   0   0   0   0\r\n" + 
								" 255 255 255 255  31   0   0   0   0 159 255 255   0   0   0   0\r\n" + 
								" 255  95   0   0   0   0   0   0   0 159 255 255 239 239 239 239\r\n" + 
								" 255  95   0   0   0   0   0   0   0 159 255 255 255 255 255 255\r\n" + 
								" 175  65   0   0   0   0   0   0   0 109 175 175 175 175 175 175\r\n" + 
								"   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0\r\n" + 
								"   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0\r\n" + 
								"   0  71 127 127  15   0   0   0   0  79 127 127 127 127 127 127\r\n" + 
								"   0 143 255 255  31   0   0   0   0 159 255 255 255 255 255 255\r\n" + 
								"   0 143 255 255  31   0   0   0   0 159 255 255 255 255 255 255\r\n" + 
								" 191 227 255 255 199 191 143   0   0 159 255 255 255 255 207  63\r\n" + 
								" 255 255 255 255 255 255 191   0   0 159 255 255 255 255 191   0\r\n" + 
								" 255 235 223 223 249 255 191   0   0 159 255 255 223 223 171  15\r\n" + 
								" 255  95   0   0 207 255 191   0   0 159 255 255   0   0  63 255\r\n" + 
								" 255 255 255 255 255 255 191   0   0 159 255 255   0   0   0   0\r\n" + 
								" 255 255 255 255  87  63  47   0   0 159 255 255   0   0   0   0\r\n" + 
								" 255 255 255 255  31   0   0   0   0 159 255 255   0   0   0   0\r\n" + 
								" 255 255 255 255  31   0   0   0   0 159 255 255   0   0   0   0\r\n" + 
								" 255  95   0   0   0   0   0   0   0 159 255 255 239 239 239 239\r\n" + 
								" 255  95   0   0   0   0   0   0   0 159 255 255 255 255 255 255\r\n" + 
								" 175  65   0   0   0   0   0   0   0 109 175 175 175 175 175 175\r\n" + 
								"   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0\r\n" + 
								"   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0\r\n" + 
								"   0  71 127 127  15   0   0   0   0  79 127 127 127 127 127 127\r\n" + 
								"   0 143 255 255  31   0   0   0   0 159 255 255 255 255 255 255\r\n" + 
								"   0 143 255 255  31   0   0   0   0 159 255 255 255 255 255 255\r\n" + 
								" 191 227 255 255 199 191 143   0   0 159 255 255 255 255 207  63\r\n" + 
								" 255 255 255 255 255 255 191   0   0 159 255 255 255 255 191   0\r\n" + 
								" 255 235 223 223 249 255 191   0   0 159 255 255 223 223 171  15\r\n" + 
								" 255  95   0   0 207 255 191   0   0 159 255 255   0   0  63 255\r\n" + 
								"\r\n" + 
								"   0   0   0   0 239 255 175   0   0 127 255 255  63   0  15 255\r\n" + 
								"   0   0   0   0 239 255 175   0   0 127 255 255 207 191 171  63\r\n" + 
								"   0   0   0   0 239 255 175   0   0 127 255 255 255 255 223   0\r\n" + 
								"   0   0   0   0 239 255 175   0   0 127 255 255 255 255 223   0\r\n" + 
								" 255 255 255 255 255 255 175   0   0 127 255 255 255 255 255 255\r\n" + 
								" 255 255 255 255 255 255 175   0   0 127 255 255 255 255 255 255\r\n" + 
								" 159 159 159 159 159 159 109   0   0  79 159 159 159 159 159 159\r\n" + 
								"   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0\r\n" + 
								"   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0\r\n" + 
								" 191  47   0   0   0   0   0   0   0   0   0   0 143 191 191 191\r\n" + 
								" 255  63   0   0   0   0   0   0   0   0   0   0 191 255 255 255\r\n" + 
								" 255  87  31  31   0   0   0   0   0  15  31  31 199 255 249 207\r\n" + 
								" 255 255 255 255   0   0   0   0   0 127 255 255 255 255 223   0\r\n" + 
								" 255 255 255 255   0   0   0   0   0 127 255 255 255 255 223   0\r\n" + 
								" 255 255 255 255  95  95  65   0   0  71 143 143 227 255 235  95\r\n" + 
								" 255 255 255 255 255 255 175   0   0   0   0   0 191 255 255 255\r\n" + 
								"   0   0   0   0 239 255 175   0   0 127 255 255  63   0  15 255\r\n" + 
								"   0   0   0   0 239 255 175   0   0 127 255 255 207 191 171  63\r\n" + 
								"   0   0   0   0 239 255 175   0   0 127 255 255 255 255 223   0\r\n" + 
								"   0   0   0   0 239 255 175   0   0 127 255 255 255 255 223   0\r\n" + 
								" 255 255 255 255 255 255 175   0   0 127 255 255 255 255 255 255\r\n" + 
								" 255 255 255 255 255 255 175   0   0 127 255 255 255 255 255 255\r\n" + 
								" 159 159 159 159 159 159 109   0   0  79 159 159 159 159 159 159\r\n" + 
								"   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0\r\n" + 
								"   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0\r\n" + 
								" 191  47   0   0   0   0   0   0   0   0   0   0 143 191 191 191\r\n" + 
								" 255  63   0   0   0   0   0   0   0   0   0   0 191 255 255 255\r\n" + 
								" 255  87  31  31   0   0   0   0   0  15  31  31 199 255 249 207\r\n" + 
								" 255 255 255 255   0   0   0   0   0 127 255 255 255 255 223   0\r\n" + 
								" 255 255 255 255   0   0   0   0   0 127 255 255 255 255 223   0\r\n" + 
								" 255 255 255 255  95  95  65   0   0  71 143 143 227 255 235  95\r\n" + 
								" 255 255 255 255 255 255 175   0   0   0   0   0 191 255 255 255\r\n" + 
								"   0   0   0   0 239 255 175   0   0 127 255 255  63   0  15 255\r\n" + 
								"   0   0   0   0 239 255 175   0   0 127 255 255 207 191 171  63\r\n" + 
								"   0   0   0   0 239 255 175   0   0 127 255 255 255 255 223   0\r\n" + 
								"   0   0   0   0 239 255 175   0   0 127 255 255 255 255 223   0\r\n" + 
								" 255 255 255 255 255 255 175   0   0 127 255 255 255 255 255 255\r\n" + 
								" 255 255 255 255 255 255 175   0   0 127 255 255 255 255 255 255\r\n" + 
								" 159 159 159 159 159 159 109   0   0  79 159 159 159 159 159 159\r\n" + 
								"   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0\r\n" + 
								"   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0\r\n" + 
								" 191  47   0   0   0   0   0   0   0   0   0   0 143 191 191 191\r\n" + 
								" 255  63   0   0   0   0   0   0   0   0   0   0 191 255 255 255\r\n" + 
								" 255  87  31  31   0   0   0   0   0  15  31  31 199 255 249 207\r\n" + 
								" 255 255 255 255   0   0   0   0   0 127 255 255 255 255 223   0\r\n" + 
								" 255 255 255 255   0   0   0   0   0 127 255 255 255 255 223   0\r\n" + 
								" 255 255 255 255  95  95  65   0   0  71 143 143 227 255 235  95\r\n" + 
								" 255 255 255 255 255 255 175   0   0   0   0   0 191 255 255 255\r\n" + 
								"\r\n" + 
								" 255  63   0   0 255 255 159   0   0 191 255 207   0   0  95 255\r\n" + 
								"  15 171 223 223 255 255 159   0   0 191 255 249 223 223 235 255\r\n" + 
								"   0 191 255 255 255 255 159   0   0 191 255 255 255 255 255 255\r\n" + 
								"  63 207 255 255 255 255 159   0   0 143 191 199 255 255 227 191\r\n" + 
								" 255 255 255 255 255 255 159   0   0   0   0  31 255 255 143   0\r\n" + 
								" 255 255 255 255 255 255 159   0   0   0   0  31 255 255 143   0\r\n" + 
								" 127 127 127 127 127 127  79   0   0   0   0  15 127 127  71   0\r\n" + 
								"   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0\r\n" + 
								"   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0\r\n" + 
								" 175 175 175 175 175 175 109   0   0   0   0   0   0   0  65 175\r\n" + 
								" 255 255 255 255 255 255 159   0   0   0   0   0   0   0  95 255\r\n" + 
								" 239 239 239 239 255 255 159   0   0   0   0   0   0   0  95 255\r\n" + 
								"   0   0   0   0 255 255 159   0   0   0   0  31 255 255 255 255\r\n" + 
								"   0   0   0   0 255 255 159   0   0   0   0  31 255 255 255 255\r\n" + 
								"   0   0   0   0 255 255 159   0   0  47  63  87 255 255 255 255\r\n" + 
								"   0   0   0   0 255 255 159   0   0 191 255 255 255 255 255 255\r\n" + 
								" 255  63   0   0 255 255 159   0   0 191 255 207   0   0  95 255\r\n" + 
								"  15 171 223 223 255 255 159   0   0 191 255 249 223 223 235 255\r\n" + 
								"   0 191 255 255 255 255 159   0   0 191 255 255 255 255 255 255\r\n" + 
								"  63 207 255 255 255 255 159   0   0 143 191 199 255 255 227 191\r\n" + 
								" 255 255 255 255 255 255 159   0   0   0   0  31 255 255 143   0\r\n" + 
								" 255 255 255 255 255 255 159   0   0   0   0  31 255 255 143   0\r\n" + 
								" 127 127 127 127 127 127  79   0   0   0   0  15 127 127  71   0\r\n" + 
								"   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0\r\n" + 
								"   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0\r\n" + 
								" 175 175 175 175 175 175 109   0   0   0   0   0   0   0  65 175\r\n" + 
								" 255 255 255 255 255 255 159   0   0   0   0   0   0   0  95 255\r\n" + 
								" 239 239 239 239 255 255 159   0   0   0   0   0   0   0  95 255\r\n" + 
								"   0   0   0   0 255 255 159   0   0   0   0  31 255 255 255 255\r\n" + 
								"   0   0   0   0 255 255 159   0   0   0   0  31 255 255 255 255\r\n" + 
								"   0   0   0   0 255 255 159   0   0  47  63  87 255 255 255 255\r\n" + 
								"   0   0   0   0 255 255 159   0   0 191 255 255 255 255 255 255\r\n" + 
								" 255  63   0   0 255 255 159   0   0 191 255 207   0   0  95 255\r\n" + 
								"  15 171 223 223 255 255 159   0   0 191 255 249 223 223 235 255\r\n" + 
								"   0 191 255 255 255 255 159   0   0 191 255 255 255 255 255 255\r\n" + 
								"  63 207 255 255 255 255 159   0   0 143 191 199 255 255 227 191\r\n" + 
								" 255 255 255 255 255 255 159   0   0   0   0  31 255 255 143   0\r\n" + 
								" 255 255 255 255 255 255 159   0   0   0   0  31 255 255 143   0\r\n" + 
								" 127 127 127 127 127 127  79   0   0   0   0  15 127 127  71   0\r\n" + 
								"   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0\r\n" + 
								"   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0\r\n" + 
								" 175 175 175 175 175 175 109   0   0   0   0   0   0   0  65 175\r\n" + 
								" 255 255 255 255 255 255 159   0   0   0   0   0   0   0  95 255\r\n" + 
								" 239 239 239 239 255 255 159   0   0   0   0   0   0   0  95 255\r\n" + 
								"   0   0   0   0 255 255 159   0   0   0   0  31 255 255 255 255\r\n" + 
								"   0   0   0   0 255 255 159   0   0   0   0  31 255 255 255 255\r\n" + 
								"   0   0   0   0 255 255 159   0   0  47  63  87 255 255 255 255\r\n" + 
								"   0   0   0   0 255 255 159   0   0 191 255 255 255 255 255 255\r\n" + 
								"\r\n" + 
								" 255 255 255 191   0   0   0   0   0 175 255 255 255 255 255 255\r\n" + 
								"  95 235 255 227 143 143  71   0   0  65  95  95 255 255 255 255\r\n" + 
								"   0 223 255 255 255 255 127   0   0   0   0   0 255 255 255 255\r\n" + 
								"   0 223 255 255 255 255 127   0   0   0   0   0 255 255 255 255\r\n" + 
								" 207 249 255 199  31  31  15   0   0   0   0   0  31  31  87 255\r\n" + 
								" 255 255 255 191   0   0   0   0   0   0   0   0   0   0  63 255\r\n" + 
								" 191 191 191 143   0   0   0   0   0   0   0   0   0   0  47 191\r\n" + 
								"   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0\r\n" + 
								"   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0\r\n" + 
								" 159 159 159 159 159 159  79   0   0 109 159 159 159 159 159 159\r\n" + 
								" 255 255 255 255 255 255 127   0   0 175 255 255 255 255 255 255\r\n" + 
								" 255 255 255 255 255 255 127   0   0 175 255 255 255 255 255 255\r\n" + 
								"   0 223 255 255 255 255 127   0   0 175 255 239   0   0   0   0\r\n" + 
								"   0 223 255 255 255 255 127   0   0 175 255 239   0   0   0   0\r\n" + 
								"  63 171 191 207 255 255 127   0   0 175 255 239   0   0   0   0\r\n" + 
								" 255  15   0  63 255 255 127   0   0 175 255 239   0   0   0   0\r\n" + 
								" 255 255 255 191   0   0   0   0   0 175 255 255 255 255 255 255\r\n" + 
								"  95 235 255 227 143 143  71   0   0  65  95  95 255 255 255 255\r\n" + 
								"   0 223 255 255 255 255 127   0   0   0   0   0 255 255 255 255\r\n" + 
								"   0 223 255 255 255 255 127   0   0   0   0   0 255 255 255 255\r\n" + 
								" 207 249 255 199  31  31  15   0   0   0   0   0  31  31  87 255\r\n" + 
								" 255 255 255 191   0   0   0   0   0   0   0   0   0   0  63 255\r\n" + 
								" 191 191 191 143   0   0   0   0   0   0   0   0   0   0  47 191\r\n" + 
								"   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0\r\n" + 
								"   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0\r\n" + 
								" 159 159 159 159 159 159  79   0   0 109 159 159 159 159 159 159\r\n" + 
								" 255 255 255 255 255 255 127   0   0 175 255 255 255 255 255 255\r\n" + 
								" 255 255 255 255 255 255 127   0   0 175 255 255 255 255 255 255\r\n" + 
								"   0 223 255 255 255 255 127   0   0 175 255 239   0   0   0   0\r\n" + 
								"   0 223 255 255 255 255 127   0   0 175 255 239   0   0   0   0\r\n" + 
								"  63 171 191 207 255 255 127   0   0 175 255 239   0   0   0   0\r\n" + 
								" 255  15   0  63 255 255 127   0   0 175 255 239   0   0   0   0\r\n" + 
								" 255 255 255 191   0   0   0   0   0 175 255 255 255 255 255 255\r\n" + 
								"  95 235 255 227 143 143  71   0   0  65  95  95 255 255 255 255\r\n" + 
								"   0 223 255 255 255 255 127   0   0   0   0   0 255 255 255 255\r\n" + 
								"   0 223 255 255 255 255 127   0   0   0   0   0 255 255 255 255\r\n" + 
								" 207 249 255 199  31  31  15   0   0   0   0   0  31  31  87 255\r\n" + 
								" 255 255 255 191   0   0   0   0   0   0   0   0   0   0  63 255\r\n" + 
								" 191 191 191 143   0   0   0   0   0   0   0   0   0   0  47 191\r\n" + 
								"   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0\r\n" + 
								"   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0\r\n" + 
								" 159 159 159 159 159 159  79   0   0 109 159 159 159 159 159 159\r\n" + 
								" 255 255 255 255 255 255 127   0   0 175 255 255 255 255 255 255\r\n" + 
								" 255 255 255 255 255 255 127   0   0 175 255 255 255 255 255 255\r\n" + 
								"   0 223 255 255 255 255 127   0   0 175 255 239   0   0   0   0\r\n" + 
								"   0 223 255 255 255 255 127   0   0 175 255 239   0   0   0   0\r\n" + 
								"  63 171 191 207 255 255 127   0   0 175 255 239   0   0   0   0\r\n" + 
								" 255  15   0  63 255 255 127   0   0 175 255 239   0   0   0   0\r\n");
			var hiroCode:FLARCode = new FLARCode(16, 16);
			hiroCode.loadARPatt(" 234 235 240 233 240 234 240 235 240 237 240 238 240 240 240 232\r\n" + 
								" 229 240 240 240 240 240 240 240 240 240 240 240 240 240 240 228\r\n" + 
								" 227 240 240 240 240 240 240 240 240 240 240 240 240 240 240 239\r\n" + 
								" 240 240 240 240 240 240 240 240 240 240 240 240 240 240 240 240\r\n" + 
								" 236 240 240 240 240 240 240 240 240 240 240 240 240 240 240 240\r\n" + 
								" 234 240 240 240 240 240 240 240 240 240 240 240 240 240 240 240\r\n" + 
								" 236 240 240 240 240 240 240 240 240 240 240 240 240 240 240 240\r\n" + 
								" 231 240 240 240 240 240 240 240 240 240 240 240 240 240 240 240\r\n" + 
								" 229 240 240 240 240 240 240 240 240 240 240 240 240 240 240 240\r\n" + 
								" 225 149 240 240 186 216 225 174 240 240 240 237 238 240 240 240\r\n" + 
								" 150 107 238 231  75 208 115 147 238 228 223 226 237 180 226 240\r\n" + 
								" 150  62 181 213  62 187 113 169 197  72  29 237 120  50  53 207\r\n" + 
								" 149  63  47  78  53 184 113 101 142   5 150 150  45 217 186  83\r\n" + 
								" 121  84 220 222  58 180 121  92 128 109 237 124 155 232 161  64\r\n" + 
								" 149  71 240 240  76 210  98 109 122 108 240 129  51 119 161 155\r\n" + 
								" 149 186 240 240  98 219 135 152 207 191 236 227 152  77 175 209\r\n" + 
								" 235 235 240 233 240 234 240 235 240 236 240 238 240 240 240 240\r\n" + 
								" 229 240 240 240 240 240 240 240 240 240 240 240 240 240 240 240\r\n" + 
								" 227 240 240 240 240 240 240 240 240 240 240 240 240 240 240 240\r\n" + 
								" 240 240 240 240 240 240 240 240 240 240 240 240 240 240 240 240\r\n" + 
								" 236 240 240 240 240 240 240 240 240 240 240 240 240 240 240 240\r\n" + 
								" 234 240 240 240 240 240 240 240 240 240 240 240 240 240 240 240\r\n" + 
								" 236 240 240 240 240 240 240 240 240 240 240 240 240 240 240 240\r\n" + 
								" 232 240 240 240 240 240 240 240 240 240 240 240 240 240 240 240\r\n" + 
								" 229 240 240 240 240 240 240 240 240 240 240 240 240 240 240 240\r\n" + 
								" 225 156 240 240 186 216 225 186 240 240 240 240 240 240 240 240\r\n" + 
								" 150 117 240 231  72 206 115 162 240 232 223 237 240 180 226 240\r\n" + 
								" 150  74 187 213  51 184 103 168 197  78  29 237 120  50  53 216\r\n" + 
								" 144  77  51  74  61 184 106 101 142   5 150 152  52 217 186  85\r\n" + 
								" 117  89 219 219  65 184 121  92 128 100 236 125 156 240 170  73\r\n" + 
								" 148  71 240 240  76 210 109 109 121  99 240 137  51 120 166 164\r\n" + 
								" 140 186 240 240  98 220 150 156 207 192 236 230 152  77 176 212\r\n" + 
								" 234 235 240 233 240 234 240 235 240 236 240 238 240 240 240 233\r\n" + 
								" 229 240 240 240 240 240 240 240 240 240 240 240 240 240 240 239\r\n" + 
								" 227 240 240 240 240 240 240 240 240 240 240 240 240 240 240 240\r\n" + 
								" 240 240 240 240 240 240 240 240 240 240 240 240 240 240 240 240\r\n" + 
								" 234 240 240 240 240 240 240 240 240 240 240 240 240 240 240 240\r\n" + 
								" 232 240 240 240 240 240 240 240 240 240 240 240 240 240 240 240\r\n" + 
								" 235 240 240 240 240 240 240 240 240 240 240 240 240 240 240 240\r\n" + 
								" 232 240 240 240 240 240 240 240 240 240 240 240 240 240 240 240\r\n" + 
								" 228 240 240 240 240 240 240 240 240 240 240 240 240 240 240 240\r\n" + 
								" 225 156 240 240 182 212 225 180 240 240 240 240 240 240 240 240\r\n" + 
								" 150 116 238 228  66 205 115 151 238 236 225 240 240 180 226 240\r\n" + 
								" 156  84 186 211  47 184 109 170 200  92  30 240 120  50  53 216\r\n" + 
								" 147  83  51  73  50 184 106 110 148  17 151 150  45 217 186  85\r\n" + 
								" 127  98 219 219  58 179 109 101 128 107 237 125 155 240 163  72\r\n" + 
								" 155  86 240 240  76 201  85 108 121  95 232 137  51 118 153 155\r\n" + 
								" 149 189 240 240  98 220 141 154 206 178 235 230 152  77 175 209\r\n" + 
								"\r\n" + 
								" 232 228 239 240 240 240 240 240 240 240 240 207  83  64 155 209\r\n" + 
								" 240 240 240 240 240 240 240 240 240 240 226  53 186 161 161 175\r\n" + 
								" 240 240 240 240 240 240 240 240 240 240 180  50 217 232 119  77\r\n" + 
								" 240 240 240 240 240 240 240 240 240 238 237 120  45 155  51 152\r\n" + 
								" 238 240 240 240 240 240 240 240 240 237 226 237 150 124 129 227\r\n" + 
								" 240 240 240 240 240 240 240 240 240 240 223  29 150 237 240 236\r\n" + 
								" 237 240 240 240 240 240 240 240 240 240 228  72   5 109 108 191\r\n" + 
								" 240 240 240 240 240 240 240 240 240 240 238 197 142 128 122 207\r\n" + 
								" 235 240 240 240 240 240 240 240 240 174 147 169 101  92 109 152\r\n" + 
								" 240 240 240 240 240 240 240 240 240 225 115 113 113 121  98 135\r\n" + 
								" 234 240 240 240 240 240 240 240 240 216 208 187 184 180 210 219\r\n" + 
								" 240 240 240 240 240 240 240 240 240 186  75  62  53  58  76  98\r\n" + 
								" 233 240 240 240 240 240 240 240 240 240 231 213  78 222 240 240\r\n" + 
								" 240 240 240 240 240 240 240 240 240 240 238 181  47 220 240 240\r\n" + 
								" 235 240 240 240 240 240 240 240 240 149 107  62  63  84  71 186\r\n" + 
								" 234 229 227 240 236 234 236 231 229 225 150 150 149 121 149 149\r\n" + 
								" 240 240 240 240 240 240 240 240 240 240 240 216  85  73 164 212\r\n" + 
								" 240 240 240 240 240 240 240 240 240 240 226  53 186 170 166 176\r\n" + 
								" 240 240 240 240 240 240 240 240 240 240 180  50 217 240 120  77\r\n" + 
								" 240 240 240 240 240 240 240 240 240 240 240 120  52 156  51 152\r\n" + 
								" 238 240 240 240 240 240 240 240 240 240 237 237 152 125 137 230\r\n" + 
								" 240 240 240 240 240 240 240 240 240 240 223  29 150 236 240 236\r\n" + 
								" 236 240 240 240 240 240 240 240 240 240 232  78   5 100  99 192\r\n" + 
								" 240 240 240 240 240 240 240 240 240 240 240 197 142 128 121 207\r\n" + 
								" 235 240 240 240 240 240 240 240 240 186 162 168 101  92 109 156\r\n" + 
								" 240 240 240 240 240 240 240 240 240 225 115 103 106 121 109 150\r\n" + 
								" 234 240 240 240 240 240 240 240 240 216 206 184 184 184 210 220\r\n" + 
								" 240 240 240 240 240 240 240 240 240 186  72  51  61  65  76  98\r\n" + 
								" 233 240 240 240 240 240 240 240 240 240 231 213  74 219 240 240\r\n" + 
								" 240 240 240 240 240 240 240 240 240 240 240 187  51 219 240 240\r\n" + 
								" 235 240 240 240 240 240 240 240 240 156 117  74  77  89  71 186\r\n" + 
								" 235 229 227 240 236 234 236 232 229 225 150 150 144 117 148 140\r\n" + 
								" 233 239 240 240 240 240 240 240 240 240 240 216  85  72 155 209\r\n" + 
								" 240 240 240 240 240 240 240 240 240 240 226  53 186 163 153 175\r\n" + 
								" 240 240 240 240 240 240 240 240 240 240 180  50 217 240 118  77\r\n" + 
								" 240 240 240 240 240 240 240 240 240 240 240 120  45 155  51 152\r\n" + 
								" 238 240 240 240 240 240 240 240 240 240 240 240 150 125 137 230\r\n" + 
								" 240 240 240 240 240 240 240 240 240 240 225  30 151 237 232 235\r\n" + 
								" 236 240 240 240 240 240 240 240 240 240 236  92  17 107  95 178\r\n" + 
								" 240 240 240 240 240 240 240 240 240 240 238 200 148 128 121 206\r\n" + 
								" 235 240 240 240 240 240 240 240 240 180 151 170 110 101 108 154\r\n" + 
								" 240 240 240 240 240 240 240 240 240 225 115 109 106 109  85 141\r\n" + 
								" 234 240 240 240 240 240 240 240 240 212 205 184 184 179 201 220\r\n" + 
								" 240 240 240 240 240 240 240 240 240 182  66  47  50  58  76  98\r\n" + 
								" 233 240 240 240 240 240 240 240 240 240 228 211  73 219 240 240\r\n" + 
								" 240 240 240 240 240 240 240 240 240 240 238 186  51 219 240 240\r\n" + 
								" 235 240 240 240 240 240 240 240 240 156 116  84  83  98  86 189\r\n" + 
								" 234 229 227 240 234 232 235 232 228 225 150 156 147 127 155 149\r\n" + 
								"\r\n" + 
								" 209 175  77 152 227 236 191 207 152 135 219  98 240 240 186 149\r\n" + 
								" 155 161 119  51 129 240 108 122 109  98 210  76 240 240  71 149\r\n" + 
								"  64 161 232 155 124 237 109 128  92 121 180  58 222 220  84 121\r\n" + 
								"  83 186 217  45 150 150   5 142 101 113 184  53  78  47  63 149\r\n" + 
								" 207  53  50 120 237  29  72 197 169 113 187  62 213 181  62 150\r\n" + 
								" 240 226 180 237 226 223 228 238 147 115 208  75 231 238 107 150\r\n" + 
								" 240 240 240 238 237 240 240 240 174 225 216 186 240 240 149 225\r\n" + 
								" 240 240 240 240 240 240 240 240 240 240 240 240 240 240 240 229\r\n" + 
								" 240 240 240 240 240 240 240 240 240 240 240 240 240 240 240 231\r\n" + 
								" 240 240 240 240 240 240 240 240 240 240 240 240 240 240 240 236\r\n" + 
								" 240 240 240 240 240 240 240 240 240 240 240 240 240 240 240 234\r\n" + 
								" 240 240 240 240 240 240 240 240 240 240 240 240 240 240 240 236\r\n" + 
								" 240 240 240 240 240 240 240 240 240 240 240 240 240 240 240 240\r\n" + 
								" 239 240 240 240 240 240 240 240 240 240 240 240 240 240 240 227\r\n" + 
								" 228 240 240 240 240 240 240 240 240 240 240 240 240 240 240 229\r\n" + 
								" 232 240 240 240 238 240 237 240 235 240 234 240 233 240 235 234\r\n" + 
								" 212 176  77 152 230 236 192 207 156 150 220  98 240 240 186 140\r\n" + 
								" 164 166 120  51 137 240  99 121 109 109 210  76 240 240  71 148\r\n" + 
								"  73 170 240 156 125 236 100 128  92 121 184  65 219 219  89 117\r\n" + 
								"  85 186 217  52 152 150   5 142 101 106 184  61  74  51  77 144\r\n" + 
								" 216  53  50 120 237  29  78 197 168 103 184  51 213 187  74 150\r\n" + 
								" 240 226 180 240 237 223 232 240 162 115 206  72 231 240 117 150\r\n" + 
								" 240 240 240 240 240 240 240 240 186 225 216 186 240 240 156 225\r\n" + 
								" 240 240 240 240 240 240 240 240 240 240 240 240 240 240 240 229\r\n" + 
								" 240 240 240 240 240 240 240 240 240 240 240 240 240 240 240 232\r\n" + 
								" 240 240 240 240 240 240 240 240 240 240 240 240 240 240 240 236\r\n" + 
								" 240 240 240 240 240 240 240 240 240 240 240 240 240 240 240 234\r\n" + 
								" 240 240 240 240 240 240 240 240 240 240 240 240 240 240 240 236\r\n" + 
								" 240 240 240 240 240 240 240 240 240 240 240 240 240 240 240 240\r\n" + 
								" 240 240 240 240 240 240 240 240 240 240 240 240 240 240 240 227\r\n" + 
								" 240 240 240 240 240 240 240 240 240 240 240 240 240 240 240 229\r\n" + 
								" 240 240 240 240 238 240 236 240 235 240 234 240 233 240 235 235\r\n" + 
								" 209 175  77 152 230 235 178 206 154 141 220  98 240 240 189 149\r\n" + 
								" 155 153 118  51 137 232  95 121 108  85 201  76 240 240  86 155\r\n" + 
								"  72 163 240 155 125 237 107 128 101 109 179  58 219 219  98 127\r\n" + 
								"  85 186 217  45 150 151  17 148 110 106 184  50  73  51  83 147\r\n" + 
								" 216  53  50 120 240  30  92 200 170 109 184  47 211 186  84 156\r\n" + 
								" 240 226 180 240 240 225 236 238 151 115 205  66 228 238 116 150\r\n" + 
								" 240 240 240 240 240 240 240 240 180 225 212 182 240 240 156 225\r\n" + 
								" 240 240 240 240 240 240 240 240 240 240 240 240 240 240 240 228\r\n" + 
								" 240 240 240 240 240 240 240 240 240 240 240 240 240 240 240 232\r\n" + 
								" 240 240 240 240 240 240 240 240 240 240 240 240 240 240 240 235\r\n" + 
								" 240 240 240 240 240 240 240 240 240 240 240 240 240 240 240 232\r\n" + 
								" 240 240 240 240 240 240 240 240 240 240 240 240 240 240 240 234\r\n" + 
								" 240 240 240 240 240 240 240 240 240 240 240 240 240 240 240 240\r\n" + 
								" 240 240 240 240 240 240 240 240 240 240 240 240 240 240 240 227\r\n" + 
								" 239 240 240 240 240 240 240 240 240 240 240 240 240 240 240 229\r\n" + 
								" 233 240 240 240 238 240 236 240 235 240 234 240 233 240 235 234\r\n" + 
								"\r\n" + 
								" 149 149 121 149 150 150 225 229 231 236 234 236 240 227 229 234\r\n" + 
								" 186  71  84  63  62 107 149 240 240 240 240 240 240 240 240 235\r\n" + 
								" 240 240 220  47 181 238 240 240 240 240 240 240 240 240 240 240\r\n" + 
								" 240 240 222  78 213 231 240 240 240 240 240 240 240 240 240 233\r\n" + 
								"  98  76  58  53  62  75 186 240 240 240 240 240 240 240 240 240\r\n" + 
								" 219 210 180 184 187 208 216 240 240 240 240 240 240 240 240 234\r\n" + 
								" 135  98 121 113 113 115 225 240 240 240 240 240 240 240 240 240\r\n" + 
								" 152 109  92 101 169 147 174 240 240 240 240 240 240 240 240 235\r\n" + 
								" 207 122 128 142 197 238 240 240 240 240 240 240 240 240 240 240\r\n" + 
								" 191 108 109   5  72 228 240 240 240 240 240 240 240 240 240 237\r\n" + 
								" 236 240 237 150  29 223 240 240 240 240 240 240 240 240 240 240\r\n" + 
								" 227 129 124 150 237 226 237 240 240 240 240 240 240 240 240 238\r\n" + 
								" 152  51 155  45 120 237 238 240 240 240 240 240 240 240 240 240\r\n" + 
								"  77 119 232 217  50 180 240 240 240 240 240 240 240 240 240 240\r\n" + 
								" 175 161 161 186  53 226 240 240 240 240 240 240 240 240 240 240\r\n" + 
								" 209 155  64  83 207 240 240 240 240 240 240 240 240 239 228 232\r\n" + 
								" 140 148 117 144 150 150 225 229 232 236 234 236 240 227 229 235\r\n" + 
								" 186  71  89  77  74 117 156 240 240 240 240 240 240 240 240 235\r\n" + 
								" 240 240 219  51 187 240 240 240 240 240 240 240 240 240 240 240\r\n" + 
								" 240 240 219  74 213 231 240 240 240 240 240 240 240 240 240 233\r\n" + 
								"  98  76  65  61  51  72 186 240 240 240 240 240 240 240 240 240\r\n" + 
								" 220 210 184 184 184 206 216 240 240 240 240 240 240 240 240 234\r\n" + 
								" 150 109 121 106 103 115 225 240 240 240 240 240 240 240 240 240\r\n" + 
								" 156 109  92 101 168 162 186 240 240 240 240 240 240 240 240 235\r\n" + 
								" 207 121 128 142 197 240 240 240 240 240 240 240 240 240 240 240\r\n" + 
								" 192  99 100   5  78 232 240 240 240 240 240 240 240 240 240 236\r\n" + 
								" 236 240 236 150  29 223 240 240 240 240 240 240 240 240 240 240\r\n" + 
								" 230 137 125 152 237 237 240 240 240 240 240 240 240 240 240 238\r\n" + 
								" 152  51 156  52 120 240 240 240 240 240 240 240 240 240 240 240\r\n" + 
								"  77 120 240 217  50 180 240 240 240 240 240 240 240 240 240 240\r\n" + 
								" 176 166 170 186  53 226 240 240 240 240 240 240 240 240 240 240\r\n" + 
								" 212 164  73  85 216 240 240 240 240 240 240 240 240 240 240 240\r\n" + 
								" 149 155 127 147 156 150 225 228 232 235 232 234 240 227 229 234\r\n" + 
								" 189  86  98  83  84 116 156 240 240 240 240 240 240 240 240 235\r\n" + 
								" 240 240 219  51 186 238 240 240 240 240 240 240 240 240 240 240\r\n" + 
								" 240 240 219  73 211 228 240 240 240 240 240 240 240 240 240 233\r\n" + 
								"  98  76  58  50  47  66 182 240 240 240 240 240 240 240 240 240\r\n" + 
								" 220 201 179 184 184 205 212 240 240 240 240 240 240 240 240 234\r\n" + 
								" 141  85 109 106 109 115 225 240 240 240 240 240 240 240 240 240\r\n" + 
								" 154 108 101 110 170 151 180 240 240 240 240 240 240 240 240 235\r\n" + 
								" 206 121 128 148 200 238 240 240 240 240 240 240 240 240 240 240\r\n" + 
								" 178  95 107  17  92 236 240 240 240 240 240 240 240 240 240 236\r\n" + 
								" 235 232 237 151  30 225 240 240 240 240 240 240 240 240 240 240\r\n" + 
								" 230 137 125 150 240 240 240 240 240 240 240 240 240 240 240 238\r\n" + 
								" 152  51 155  45 120 240 240 240 240 240 240 240 240 240 240 240\r\n" + 
								"  77 118 240 217  50 180 240 240 240 240 240 240 240 240 240 240\r\n" + 
								" 175 153 163 186  53 226 240 240 240 240 240 240 240 240 240 240\r\n" + 
								" 209 155  72  85 216 240 240 240 240 240 240 240 240 240 239 233\r\n");
			
			// setup webcam
			_webcam = Camera.getCamera();
			if (!_webcam) {
				throw new Error('No webcam!!!!');
			}
			_webcam.setMode(320, 240, 30);
			_video = new Video(320, 240);
			_video.attachCamera(_webcam);
			_capture = new Bitmap(new BitmapData(320, 240, false, 0), PixelSnapping.AUTO, true);
			
			// setup ARToolkit
			_raster = new FLARRgbRaster_BitmapData(_capture.bitmapData);
			_detector = new FLARMultiMarkerDetector(_param, [flarCode, hiroCode], [80, 80], 2);
			_detector.setContinueMode(true);
			
			_base = addChild(new Sprite()) as Sprite;
			
			_capture.width = 640;
			_capture.height = 480;
			_base.addChild(_capture);
			
			_viewport = _base.addChild(new Viewport3D(320, 240)) as Viewport3D;
			_viewport.scaleX = 2;
			_viewport.scaleY = 2;
			_viewport.x = -4; // 4pix ???
			
			_camera3d = new FLARCamera3D(_param);
			
			_scene = new Scene3D();
			
			_markerNodes = new Array();
			_markerNodes[0] = _scene.addChild(new FLARBaseNode()) as FLARBaseNode;
			_markerNodes[1] = _scene.addChild(new FLARBaseNode()) as FLARBaseNode;

			// マーカー上に表示するものを定義
			var light:PointLight3D = new PointLight3D();
			light.x = 0;
			light.y = 1000;
			light.z = -1000;

			var flarFmat:FlatShadeMaterial = new FlatShadeMaterial(light, 0xFF0000, 0x660000);
			var flarCube:Cube = new Cube(new MaterialsList( { all:flarFmat } ), 40, 40, 40);
			flarCube.z = 20;
			_markerNodes[0].addChild(flarCube);

			var hiroFmat:FlatShadeMaterial = new FlatShadeMaterial(light, 0x00FF00, 0x006600);
			var hiroCube:Cube = new Cube(new MaterialsList( { all:hiroFmat } ), 40, 40, 40);
			hiroCube.z = 20;
			_markerNodes[1].addChild(hiroCube);
			
			_renderer = new LazyRenderEngine(_scene, _camera3d, _viewport);
			
			this._detectedResults = new Array();
			for (var j:int = 0; j < _markerNodes.length; j++) {
				this._detectedResults[j] = { confidence:0, index:0 };
			}

 therBMD = addChild(new Bitmap(_detector.thresholdedBitmapData)) as Bitmap;
setVisibleThersholdeImage();

//Wonderfl.capture_delay(15);

			addEventListener(Event.ENTER_FRAME, _onEnterFrame);
			//this.addChild(new Bitmap(((_detector._bin_raster) as FLARRaster_BitmapData).bitmapData));

		}
private function setVisibleThersholdeImage():void{
                       addEventListener(MouseEvent.CLICK,onChangeThreshodVisible)
                }
    
                private function onChangeThreshodVisible(e:MouseEvent):void{
        
                    therBMD.visible=!therBMD.visible
                }
		private function _onEnterFrame(e:Event = null):void {
			_capture.bitmapData.draw(_video);
			
			var detectedMarkers:int;
			
			try {
				detectedMarkers = _detector.detectMarkerLite(_raster, 80);
			} catch (e:Error) {}
			for (var i:int = 0; i < detectedMarkers; i++) {
				var confidence:Number = _detector.getConfidence(i);
				var codeIndex:int = _detector.getARCodeIndex(i);
				if (this._detectedResults[codeIndex].confidence < confidence) {
					this._detectedResults[codeIndex].confidence = confidence;
					this._detectedResults[codeIndex].index = i;
				}
			}
			for (var k:int = 0; k < this._detectedResults.length; k++) {
				var node:FLARBaseNode = _markerNodes[k] as FLARBaseNode;
				if (this._detectedResults[k].confidence > 0.5) {
					_detector.getTransmationMatrix(this._detectedResults[k].index, _resultMat);
					node.setTransformMatrix(_resultMat);
					node.visible = true;
				} else {
					node.visible = false;
				}
				this._detectedResults[k].index = 0;
				this._detectedResults[k].confidence = 0;
			}
			_renderer.render();
		}

	}
}