osgart 2.0 example with markers_list.dat ?

Community support forum for users of the GPL-licensed osgART Standard Edition v1.0 and proprietary-licensed osgART Professional Edition v1.1
seggybop
Posts: 2
Joined: Tue Mar 16, 2010 9:31 pm

osgart 2.0 example with markers_list.dat ?

Postby seggybop » Thu Mar 18, 2010 5:26 am

hello,

is there any example code for an osgart 2.0 program using an external markers_list file (as there was with original artoolit / osgart 1.0) ?
it seems like this must exist somewhere, and I've seen some complete programs that work this way.

I'm sure I can figure out how to write this myself eventually, but I'm an incompetent industrial design student rather than a programmer, so it will take me a while... =/

thanks for any help~

xcampos
Posts: 11
Joined: Mon Nov 16, 2009 9:03 am

Re: osgart 2.0 example with markers_list.dat ?

Postby xcampos » Thu Jun 17, 2010 2:28 pm

I think you ask about having a multiple marker like the a, b, c, d, f, g of the example in 1.0. You only have to put that it is a multimarker and the size like:

osg::ref_ptr<osgART::Marker> marker = tracker->addMarker("multi;data/marker_list.dat;40;0;0");

I send you the code I've used to load a model with this pattern.

Good luck!



Javier.

/*************************************************************************/
/* -*-c++-*-
*
* osgART - ARToolKit for OpenSceneGraph
* Copyright (C) 2005-2008 Human Interface Technology Laboratory New Zealand
*
* This file is part of osgART 2.0
*
* osgART 2.0 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 3 of the License, or
* (at your option) any later version.
*
* osgART 2.0 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 osgART 2.0. If not, see <http://www.gnu.org/licenses/>.
*
*/

#include <osgART/Foundation>
#include <osgART/VideoLayer>
#include <osgART/PluginManager>
#include <osgART/VideoGeode>
#include <osgART/Utils>
#include <osgART/GeometryUtils>
#include <osgART/MarkerCallback>
#include <osgART/TransformFilterCallback>

#include <osgViewer/Viewer>
#include <osgViewer/ViewerEventHandlers>

#include <osgDB/FileUtils>
#include <osgDB/ReadFile>

osg::Group* createImageBackground(osg::Image* video) {
osgART::VideoLayer* _layer = new osgART::VideoLayer();
_layer->setSize(*video);
osgART::VideoGeode* _geode = new osgART::VideoGeode(osgART::VideoGeode::USE_TEXTURE_2D, video);
addTexturedQuad(*_geode,video->s(),video->t());
_layer->addChild(_geode);
return _layer;
}


int main(int argc, char* argv[]) {

// create a root node
osg::ref_ptr<osg::Group> root = new osg::Group;

osgViewer::Viewer viewer;

// attach root node to the viewer
viewer.setSceneData(root.get());

// add relevant handlers to the viewer
viewer.addEventHandler(new osgViewer::StatsHandler);
viewer.addEventHandler(new osgViewer::WindowSizeHandler);
viewer.addEventHandler(new osgViewer::ThreadingHandler);
viewer.addEventHandler(new osgViewer::HelpHandler);


// preload the video and tracker
int _video_id = osgART::PluginManager::instance()->load("osgart_video_artoolkit2");
//int _tracker_id = osgART::PluginManager::instance()->load("osgart_tracker_sstt");
int _tracker_id = osgART::PluginManager::instance()->load("osgart_tracker_artoolkit2");

// Load a video plugin.
osg::ref_ptr<osgART::Video> video =
dynamic_cast<osgART::Video*>(osgART::PluginManager::instance()->get(_video_id));

// check if an instance of the video stream could be started
if (!video.valid())
{
// Without video an AR application can not work. Quit if none found.
osg::notify(osg::FATAL) << "Could not initialize video plugin!" << std::endl;
exit(-1);
}

// Open the video. This will not yet start the video stream but will
// get information about the format of the video which is essential
// for the connected tracker
video->open();

osg::ref_ptr<osgART::Tracker> tracker =
dynamic_cast<osgART::Tracker*>(osgART::PluginManager::instance()->get(_tracker_id));

if (!tracker.valid())
{
// Without tracker an AR application can not work. Quit if none found.
osg::notify(osg::FATAL) << "Could not initialize tracker plugin!" << std::endl;
exit(-1);
}

// get the tracker calibration object
osg::ref_ptr<osgART::Calibration> calibration = tracker->getOrCreateCalibration();

// load a calibration file
if (!calibration->load(std::string("data/camera_para.dat")))
{

// the calibration file was non-existing or couldnt be loaded
osg::notify(osg::FATAL) << "Non existing or incompatible calibration file" << std::endl;
exit(-1);
}

// set the image source for the tracker
tracker->setImage(video.get());

osgART::TrackerCallback::addOrSet(root.get(), tracker.get());

osg::ref_ptr<osgART::Marker> marker = tracker->addMarker("multi;data/marker_list.dat;40;0;0");
if (!marker.valid())
{
// Without marker an AR application can not work. Quit if none found.
osg::notify(osg::FATAL) << "Could not add marker!" << std::endl;
exit(-1);
}

marker->setActive(true);

osg::ref_ptr<osg::MatrixTransform> arTransform = new osg::MatrixTransform();

osg::MatrixTransform* scaleTrans = new osg::MatrixTransform(osg::Matrix::scale(100, 100, 100));
scaleTrans->addChild(osgDB::readNodeFile("models/v8.IVE"));
arTransform->addChild(scaleTrans);

// arTransform->addChild(osgDB::readNodeFile("models/v8.IVE"));

osgART::attachDefaultEventCallbacks(arTransform.get(),marker.get());

arTransform->addChild(osgDB::readNodeFile("models/v8.IVE"));

arTransform->getOrCreateStateSet()->setRenderBinDetails(100, "RenderBin");

osg::ref_ptr<osg::Group> videoBackground = createImageBackground(video.get());
videoBackground->getOrCreateStateSet()->setRenderBinDetails(0, "RenderBin");

osg::ref_ptr<osg::Camera> cam = calibration->createCamera();

cam->addChild(arTransform.get());
cam->addChild(videoBackground.get());

root->addChild(cam.get());

video->start();
return viewer.run();

}

theoribeiro
Posts: 4
Joined: Wed Mar 03, 2010 1:25 pm

Re: osgart 2.0 example with markers_list.dat ?

Postby theoribeiro » Tue Nov 30, 2010 8:31 am

What about finding out if one of the markers from the multiple markers is visible like the multiTest example from ARToolKit? Is there any way to do it?

VidaDaPuta
Posts: 2
Joined: Mon May 09, 2011 10:21 pm

Re: osgart 2.0 example with markers_list.dat ?

Postby VidaDaPuta » Sat May 14, 2011 6:47 am

i've try your code... when I compiled, the result is successfull... but there is a message error "Could not add marker"
there is solution ??

retrakker
Posts: 125
Joined: Mon Dec 18, 2006 5:00 pm
Contact:

Re: osgart 2.0 example with markers_list.dat ?

Postby retrakker » Wed May 25, 2011 7:22 am

Basically there is a problem ARToolKit is loading the subsequent markers. We would need to know from which folder you are trying to load the files. Its an outstanding issue and should actually be addressed upstream.


Return to “[ARCHIVED] osgART Standard & Professional Editions”

Who is online

Users browsing this forum: No registered users and 2 guests