how to change marker.

128 views
Skip to first unread message

lala nidron

unread,
May 7, 2012, 4:59:50 AM5/7/12
to FLARToolKit userz
how can i replace old marker in folder multiple marker given by
flartoolkit with my own marker design? please advise

Hector Armando Vela Santos

unread,
May 7, 2012, 1:09:08 PM5/7/12
to flartool...@googlegroups.com
you must hace a .pat file wich contains the info of your marker, there are a couple of tools that can generate a pattern file for you to switch in your project.
you can upload your pattern image file to convert or you can take a picture, and the download the .patt fille.

hope it helps ;-)

ayune nordin

unread,
May 7, 2012, 10:21:39 PM5/7/12
to flartool...@googlegroups.com
hey,thanks for your reply.. i already save it ..but i dunno where to paste my marker into my code..cz i use multiple marker by flartoolkit.. i can't see any section for .pat marker pattern name to replace the name with a new marker..

Thangaraj

unread,
May 8, 2012, 12:07:22 AM5/8/12
to flartool...@googlegroups.com
hi Nidron,

Paste the newly created .pat files in the below folder

resources\flar\patterns

Also you need to change the path in xml file in the following folder

resources\flar\flarConfig.xml
--
Thanks,
Thangaraj.S

lala nidron

unread,
May 8, 2012, 3:55:00 AM5/8/12
to FLARToolKit userz
from side *resources\flar\flarConfig.xml* i already add on the new
marker but from my source code i still cannot find *resources\flar
\patterns*
this is my source code :


package {
/* Tweener Class [http://code.google.com/p/tweener/] */
import caurina.transitions.Tweener;

/* FLARManager Framework [http://words.transmote.com/wp/flarmanager/]
*/
import com.transmote.flar.FLARManager;
import com.transmote.flar.marker.FLARMarker;
import com.transmote.flar.marker.FLARMarkerEvent;
import com.transmote.flar.utils.geom.FLARPVGeomUtils;

/* Built-in Flash components */
import flash.display.Shape;
import flash.display.Sprite;
import flash.events.Event;
import flash.filters.GlowFilter;
import flash.geom.Point;
import flash.utils.Dictionary;
import flash.media.Video;
import flash.net.NetConnection;
import flash.net.NetStream;

/* FLARToolkit [http://www.libspark.org/wiki/saqoosha/FLARToolKit/en]
*/
import org.libspark.flartoolkit.support.pv3d.FLARCamera3D;

/* Papervision3D framework [http://blog.papervision3d.org/] */
import org.papervision3d.lights.PointLight3D;
import org.papervision3d.materials.shadematerials.FlatShadeMaterial;
import org.papervision3d.materials.utils.MaterialsList;
import org.papervision3d.objects.DisplayObject3D;
import org.papervision3d.objects.primitives.Cube;
import org.papervision3d.render.LazyRenderEngine;
import org.papervision3d.scenes.Scene3D;
import org.papervision3d.view.Viewport3D;
import org.papervision3d.materials.BitmapFileMaterial;
import org.papervision3d.materials.VideoStreamMaterial;
import flash.media.Sound;
import flash.media.SoundChannel;
import flash.net.URLRequest;

/* Change output settings */
[SWF(width="640", height="480", frameRate="38",
backgroundColor="#000000")]
public class Multiple_Markers extends Sprite {
/* FLARManager pointer */
private var fm:FLARManager;
/* Papervision Scene3D pointer */
private var scene3D:Scene3D;
/* Papervision Viewport3D pointer */
private var viewport3D:Viewport3D;
/* FLARToolkit FLARCamera3D pointer */
private var camera3D:FLARCamera3D;
/* Papervision render engine pointer */
private var lre:LazyRenderEngine;
/* Papervision PointLight3D pointer */
private var pointLight3D:PointLight3D;

/*Video*/
var video;
var nc;
var ns;





/* Initialise glow filter to add a white border around selected
objects in our scene */
private var glow:GlowFilter = new GlowFilter(0xFFFFFF, 1, 7, 7, 30,
1, false, false);

/* Vector storing references to all markers on screen, grouped by
pattern id */
private var markersByPatternId:Vector.<Vector.<FLARMarker>>;
/* Dictionary storing references to marker containers, indexed by
relevant marker object */
private var containersByMarker:Dictionary;

/* Dictionary storing references to the corner nodes for each
marker, indexed by relevant marker object */
private var nodesByMarker:Dictionary;

/* Constructor method */
public function Multiple_Markers() {
/* Run augmented reality initialisation */
this.initFLAR();
}

/* Augmented reality initialisation */
private function initFLAR():void {
/* Initialise FLARManager */
this.fm = new FLARManager("flarConfig.xml");

/* Temporary declaration of how many patterns are being used */
var numPatterns:int = 6;
/* Initialise markerByPatternId vector object */
this.markersByPatternId = new
Vector.<Vector.<FLARMarker>>(numPatterns, true);
/* Loop through each pattern */
while (numPatterns--) {
/* Add empty Vector to each pattern */
this.markersByPatternId[numPatterns] = new Vector.<FLARMarker>();
}

/* Initialise empty containersByMarker dictionary object */
this.containersByMarker = new Dictionary(true);

/* Initialise empty nodesByMarker dictionary object */
this.nodesByMarker = new Dictionary(true);

/* Event listener for when a new marker is recognised */
fm.addEventListener(FLARMarkerEvent.MARKER_ADDED, this.onAdded);
/* Event listener for when a marker is removed */
fm.addEventListener(FLARMarkerEvent.MARKER_REMOVED,
this.onRemoved);
/* Event listener for when the FLARManager object has loaded */
fm.addEventListener(Event.INIT, this.onFlarManagerLoad);

/* Display webcam */
this.addChild(Sprite(fm.flarSource));
}

/* Run if FLARManager object has loaded */
private function onFlarManagerLoad(e:Event):void {
/* Remove event listener so this method doesn't run again */
this.fm.removeEventListener(Event.INIT, this.onFlarManagerLoad);
/* Run Papervision initialisation method */
this.initPaperVision();
}

/* Run when a new marker is recognised */
private function onAdded(e:FLARMarkerEvent):void {
/* Run method to add a new marker */
this.addMarker(e.marker);
}
/* Run when a marker is removed */
private function onRemoved(e:FLARMarkerEvent):void {
/* Run method to remove a marker */
this.removeMarker(e.marker);
}

/* Add a new marker to the system */
private function addMarker(marker:FLARMarker):void {
/* Store reference to list of existing markers with same pattern id
*/
var markerList:Vector.<FLARMarker> =
this.markersByPatternId[marker.patternId];
/* Add new marker to the list */
markerList.push(marker);

/* Initialise the marker container object */
var container:DisplayObject3D = new DisplayObject3D();

/* Prepare material to be used by the Papervision cube based on
pattern id */
var flatShaderMat:FlatShadeMaterial = new
FlatShadeMaterial(pointLight3D, getColorByPatternId(marker.patternId),
getColorByPatternId(marker.patternId, true));
/* Add material to all sides of the cube */
var cubeMaterials:MaterialsList = new MaterialsList({all:
flatShaderMat});

/* Initialise the cube with material and set dimensions of all
sides to 40 */

var fmat : BitmapFileMaterial = new
BitmapFileMaterial("happyface.jpg");

var fmat2 : BitmapFileMaterial = new
BitmapFileMaterial("blue.jpg");
var fmat3 : BitmapFileMaterial = new BitmapFileMaterial("dog.jpg");
var fmat4 : BitmapFileMaterial = new BitmapFileMaterial("bear-
editBK.png");
var fmat5 : BitmapFileMaterial = new
BitmapFileMaterial("means.png");
var fmat6 : BitmapFileMaterial = new
BitmapFileMaterial("xylaphone.png");
var dispObj : DisplayObject3D = new DisplayObject3D();
if(marker.patternId==0)
{
nc = new NetConnection();
nc.connect( null );

ns = new NetStream(nc);


video = new Video(550,400);

video.attachNetStream( ns );
ns.play("abc_0001.flv");
var videoMat : VideoStreamMaterial = new VideoStreamMaterial(video,
ns, true, true);
var cube : Cube = new Cube(new MaterialsList( { front: videoMat } ),
250, 1, 250);
}
else if (marker.patternId==1)
{
nc = new NetConnection();
nc.connect( null );

ns = new NetStream(nc);


video = new Video(550,400);

video.attachNetStream( ns );
ns.play("scooter.flv");
var videoMat : VideoStreamMaterial = new VideoStreamMaterial(video,
ns, true, true);
var cube : Cube = new Cube(new MaterialsList( { front: videoMat } ),
250, 1, 250);
}

else if (marker.patternId==2)
{
var cube : Cube = new Cube( new MaterialsList( {all:fmat3} ) ,
40 , 1 , 40 );
}

else if (marker.patternId==3)
{
var cube : Cube = new Cube( new MaterialsList( {all:fmat4} ) ,
50 , 1 , 50 );
}

else if (marker.patternId==4)
{
var cube : Cube = new Cube( new MaterialsList( {all:fmat5} ) ,
50 , 1 , 50 );
}

else if (marker.patternId==5)
{
var cube : Cube = new Cube( new MaterialsList( {all:fmat6} ) ,
50 , 0 , 50 );
}
/* Shift cube upwards so it sits on top of paper instead of being
cut half-way */
cube.z = 0.5 * 10;

/* Scale cube to 0 so it's invisible */
cube.scale = 0;
/* Add animation which scales cube to full size */
Tweener.addTween(cube, {scale: 1, time:0.5,
transition:"easeInOutExpo"});

/* Set cube to be individually affected by filters */
cube.useOwnContainer = true;
/* Add cellshaded border using glow filter */
cube.filters = [this.glow];

/* Add finished cube object to marker container */
container.addChild(cube);

/* Add marker container to the Papervision scene */
this.scene3D.addChild(container);

/* Add marker container to containersByMarker Dictionary object */
this.containersByMarker[marker] = container;
}

/* Remove a marker from the system */
private function removeMarker(marker:FLARMarker):void {
/* Store reference to list of existing markers with same pattern id
*/
var markerList:Vector.<FLARMarker> =
this.markersByPatternId[marker.patternId];
/* Find index value of marker to be removed */
var markerIndex:uint = markerList.indexOf(marker);
/* If marker exists in markerList */
if (markerIndex != -1) {
/* Remove marker from markersByPatternId */
markerList.splice(markerIndex, 1);
}

/* Store reference to marker container from containersByMarker
Dictionary object */
var container:DisplayObject3D = this.containersByMarker[marker];
/* If a container exists */
if (container) {
/* Remove container from the Papervision scene */
this.scene3D.removeChild(container);
}
/* Remove container reference from containersByMarker Dictionary
object */
delete this.containersByMarker[marker];

/* Clear any corner nodes for this marker from the display */
this.nodesByMarker[marker].graphics.clear();
/* Remove reference to corner nodes for this marker from
nodesByMarker Dictionary object */
delete this.nodesByMarker[marker];
}

/* Papervision initialisation method */
private function initPaperVision():void {
/* Initialise a new Papervision scene */
this.scene3D = new Scene3D();
/* Initialise a new FLARCamera3D object to enable full AR goodness
*/
this.camera3D = new FLARCamera3D(this.fm.cameraParams);

/* Define a new Papervision viewport object */
this.viewport3D = new Viewport3D(640, 480, true);
/* Add viewport to the main scene */
this.addChild(this.viewport3D);

/* Define a new Papervision point light */
this.pointLight3D = new PointLight3D(true, false);
/* Set light position */
this.pointLight3D.x = 1000;
this.pointLight3D.y = 1000;
this.pointLight3D.z = -1000;
/* Add light to the Papervision scene */
this.scene3D.addChild(pointLight3D);

/* Initialise the Papervision render engine */
this.lre = new LazyRenderEngine(this.scene3D, this.camera3D,
this.viewport3D);

/* Create event listner to run a method on each frame */
this.addEventListener(Event.ENTER_FRAME, this.onEnterFrame);
}

/* Method to run on each frame */
private function onEnterFrame(e:Event):void {
/* Loop through corner nodes */
for (var marker:Object in nodesByMarker) {
/* Clear any corner nodes for this marker from the display */
nodesByMarker[marker].graphics.clear();
}

/* Run method to update markers */
this.updateMarkers();

/* Render the Papervision scene */
this.lre.render();
}

/* Update markers method */
private function updateMarkers():void {
/* Store reference to amount of patterns being tracked */
var i:int = this.markersByPatternId.length;
/* Store reference to list of existing markers */
var markerList:Vector.<FLARMarker>;
/* Empty marker variable */
var marker:FLARMarker;
/* Empty container variable */
var container:DisplayObject3D;
/* Empty integer */
var j:int;

/* Loop through all tracked patterns */
while (i--) {
/* Store reference to all markers with this pattern id */
markerList = this.markersByPatternId[i];
/* Amount of markers with this pattern */
j = markerList.length;
/* Loop through markers with this pattern */
while (j--) {
/* Store reference to current marker */
marker = markerList[j];

/* Initialise a new Shape object */
var nodes:Shape = new Shape();
/* Define line style for corner nodes */
nodes.graphics.lineStyle(3,
getColorByPatternId(marker.patternId));
/* Store reference to coordinates for each corner of the marker
*/
var corners:Vector.<Point> = marker.corners;
/* Empty coordinate variable */
var vertex:Point;
/* Loop through rest of corner coordinates */
for (var c:uint=0; c<corners.length; c++) {
/* Store reference to current corner coordinates */
vertex = corners[c];
/* Draw a 2D circle at these coordinates */

}
/* Add reference to corner nodes to nodesByMarker Dictionary
object */
this.nodesByMarker[marker] = nodes;
/* Add corner nodes to the main scene */


/* Find reference to marker container in containersByMarker
Dictionary object */
container = this.containersByMarker[marker];
/* Transform container to new position in 3d space */
container.transform =
FLARPVGeomUtils.convertFLARMatrixToPVMatrix(marker.transformMatrix);
}
}
}

/* Get colour values dependent on pattern id */
private function getColorByPatternId(patternId:int, shaded:Boolean =
false):Number {
switch (patternId) {
case 0:
if (!shaded)
return 0xFF1919;
return 0x730000;
case 1:
if (!shaded)
return 0xFF19E8;
return 0x730067;
case 2:
if (!shaded)
return 0x9E19FF;
return 0x420073;
case 3:
if (!shaded)
return 0x192EFF;
return 0x000A73;
case 4:
if (!shaded)
return 0x1996FF;
return 0x003E73;
case 5:
if (!shaded)
return 0x19FDFF;
return 0x007273;
default:
if (!shaded)
return 0xCCCCCC;
return 0x666666;
}
}
}
}



can u tell me where should i paste the .pat marker name..



On May 8, 12:07 pm, Thangaraj <thangaraj.thangar...@gmail.com> wrote:
> hi Nidron,
>
> Paste the newly created .pat files in the below folder
>
> *resources\flar\patterns*
>
> Also you need to change the path in xml file in the following folder
>
> *resources\flar\flarConfig.xml*

Daniel Ferenc Szak

unread,
May 8, 2012, 4:02:46 AM5/8/12
to flartool...@googlegroups.com

You initialize flarmanager instance passing that config.xml as a constructuor argument - the class should do the rest. Probably once configured well, You don't have to do nothing else with it. That's why it is called a manager.
If You are looking for the "how" part, open up the flarmanager class declaration to see its internals.

By "adding" the new markers You mean of course "changed the old ones for mine", do You?!

Happy coding.

lala nidron

unread,
May 8, 2012, 4:08:59 AM5/8/12
to FLARToolKit userz
yes2,.. thats what i mean,, i know we need to open flarConfig.xml file
1st, to link the marker into .AS file rite.. but how can i link my new
marker with my image..still blur..sorry yaa

On May 8, 4:02 pm, Daniel Ferenc Szak <daniels...@gmail.com> wrote:
> You initialize flarmanager instance passing that config.xml as a
> constructuor argument - the class should do the rest. Probably once
> configured well, You don't have to do nothing else with it. That's why it
> is called a manager.
> If You are looking for the "how" part, open up the flarmanager class
> declaration to see its internals.
>
> By "adding" the new markers You mean of course "changed the old ones for
> mine", do You?!
>
> Happy coding.
> ...
>
> read more »
Reply all
Reply to author
Forward
0 new messages