IrrAR - Irrlicht and Augmented Reality

Announce new projects or updates of Irrlicht Engine related tools, games, and applications.
Also check the Wiki
Post Reply
FreakNigh
Posts: 122
Joined: Thu Oct 19, 2006 7:31 am
Location: Orlando FL, USA
Contact:

IrrAR - Irrlicht and Augmented Reality

Post by FreakNigh »

This library lets you create nodes which are attached to real life markers in the real world (as captured by a camera). After you create the nodes, you simply attach your children nodes so that they look like they are apart of the real world.

If anyone wants to help please let me know!! (this code is already well ready for use)

Image

Watch - http://www.youtube.com/watch?v=6jKCFBVLFxE

Download - http://sourceforge.net/project/showfile ... _id=237582

Project Homepage - http://www.nighsoft.com/index.php?game=libs&page=irrar

This is the code using IrrAR 0.1 for that youtube example:

Code: Select all

#include "irrAR.h"

#define WIN_WIDTH 352
#define WIN_HEIGHT 288

IrrlichtDevice *device;
IVideoDriver* driver;
ISceneManager* smgr;
IARManager* armgr;

class MyEventReceiver : public IEventReceiver
{
	public:
		virtual bool OnEvent(const SEvent &event)
		{ 
			if (event.EventType == EET_KEY_INPUT_EVENT && !event.KeyInput.PressedDown)
			{
				switch(event.KeyInput.Key)
				{
					case KEY_ESCAPE:
						device->closeDevice();
						return true;
				}
			}
			return false;
		}
};

int main()
{
	bool fullscreen = false;
	MyEventReceiver receiver;

	
	device = createDevice( video::EDT_OPENGL, dimension2d<s32>(WIN_WIDTH, WIN_HEIGHT), 16, fullscreen, false, false, &receiver);
	driver = device->getVideoDriver();
	smgr = device->getSceneManager();

	device->setWindowCaption(L"IrrAR Demo by Nighsoft");

	//something for 3d reference
	IAnimatedMesh* mesh = smgr->getMesh("media/sydney.md2");
	IAnimatedMeshSceneNode* node = smgr->addAnimatedMeshSceneNode(mesh);
	if (node)
	{
		node->setMaterialTexture( 0, driver->getTexture("media/sydney.bmp") );
		node->setMaterialFlag(EMF_LIGHTING, false);
		node->setMD2Animation(scene::EMAT_POINT);
		node->setPosition(vector3df(0,50,0));
		node->setScale(vector3df(2,2,2));
	}

	IAnimatedMeshSceneNode* fairy = smgr->addAnimatedMeshSceneNode(smgr->getMesh("media/faerie.md2"));
	if (fairy)
	{
		fairy->setMaterialTexture(0, driver->getTexture("media/faerie2.bmp"));
		fairy->setMaterialFlag(video::EMF_LIGHTING, false);
		fairy->setMD2Animation(scene::EMAT_POINT);
		fairy->setScale(vector3df(2,2,2));
		fairy->setPosition(vector3df(0,45,0));
		fairy->setRotation(vector3df(0,180,0));
	}

	//camera stuff
	vector3df camera_pos = vector3df(0,0,0);
	vector3df camera_target = vector3df(0,0,1);
	ICameraSceneNode* camera = smgr->addCameraSceneNode(0, camera_pos, camera_target);
	
	//AR stuff
	IARManager* armgr = new IARManager(device);
	//init the camera
	armgr->beginCamera("ardata/camera_para.dat","ardata/WDM_camera_flipV.xml");
	//node for the lady, attached the the hiro pattern
	armgr->addARSceneNode("ardata/patt.hiro", node);
	//node for the fairy, attached the the sample1 pattern
	armgr->addARSceneNode("ardata/patt.sample1", fairy);
	//now fix our camera to display right
	armgr->fixCamera(camera);

	while(device->run())
	{
		driver->beginScene(true, true, SColor(255,100,101,140));
		
		armgr->run();
		
		driver->draw2DImage(armgr->getCameraTexture(), position2d<s32>(0,0));

		smgr->drawAll();

		driver->endScene();
	}

	device->drop();

	return 0;
}
Last edited by FreakNigh on Fri Aug 22, 2008 11:46 pm, edited 1 time in total.
Image

CvIrrCamController - 3D head tracking lib to create window effect with webcam
IrrAR - Attach Irrlicht nodes to real life markers
http://www.nighsoft.com/
3DModelerMan
Posts: 1691
Joined: Sun May 18, 2008 9:42 pm

cool!!

Post by 3DModelerMan »

Man that is awesome!!. It's perfect for doing movies, maybe with this experience you would be able to write motion capture software
That would be illogical captain...

My first full game:
http://www.kongregate.com/games/3DModel ... tor#tipjar
freetimecoder
Posts: 226
Joined: Fri Aug 22, 2008 8:50 pm
Contact:

Post by freetimecoder »

Hi, I know it's been a time since you released this, but I think its great!

And now the bad thing: I have a problem ^^
After linking all the libs and downloading the ARToolkit, I finally was able to compile the test.cpp but I got this image http://freetimestudio.net/imageerror.jpg Well nice, but useless ;) So I tried different resolutions, cameras, cameranames and encodingprofiles but nothing worked :(
I still get images like this (different every time the app starts, but then frozen) The Samples of the ARTollkit are working.

Any Ideas please? :)
Greetings
FTC
Last edited by freetimecoder on Mon Jan 06, 2014 7:51 am, edited 1 time in total.
FreakNigh
Posts: 122
Joined: Thu Oct 19, 2006 7:31 am
Location: Orlando FL, USA
Contact:

Post by FreakNigh »

Actually I just came across this myself right now. It seems that ARToolkit is capable of outputing 32bit images (which makes no sense because how could a camera give you an alpha channel?). I'm having alittle trouble understanding how artoolkit goes about letting the coder know what format it's image really is in... right now im looking at AR_PIX_SIZE_DEFAULT and AR_DEFAULT_PIXEL_FORMAT but I can't be sure my method of solving the problem has worked until i try it on a few different machines with different setups.

I did repost IrrAR-0.1 with what should fix the problem, let me know =)

Sorry for the trouble.. it wasn't until now till I could test it on windows. The distribution comes with a better readme.txt and an actual windows compile too. =)
Image

CvIrrCamController - 3D head tracking lib to create window effect with webcam
IrrAR - Attach Irrlicht nodes to real life markers
http://www.nighsoft.com/
freetimecoder
Posts: 226
Joined: Fri Aug 22, 2008 8:50 pm
Contact:

Post by freetimecoder »

Well, I took the new code, but it did not change much. But I noticed something: When I start the app the camera seems to take one image. This image is now like weird transformed an then always shown. I noticed this because I pointed the camera on something well to identify. Most of the times I could guess that the displayed image had something to do with the captured object ^^

greetings
ftc
FreakNigh
Posts: 122
Joined: Thu Oct 19, 2006 7:31 am
Location: Orlando FL, USA
Contact:

Post by FreakNigh »

well... All your errors should be inside of this function if you want to try playing around with it -

Code: Select all

ITexture* IARManager::update_ITexture(ITexture *dest, ARUint8 *ardata)
{
	u8* pixels;
	pixels = (u8*)(dest->lock());
	if( pixels )
	{
		int max_pixels = dest->getSize().Width * dest->getSize().Height;
		
		for(int i=0;i<max_pixels;i++)
		{
			*pixels = *ardata;
			pixels++; ardata++;
			*pixels = *ardata;
			pixels++; ardata++;
			*pixels = *ardata;
			pixels++; ardata++;
#if (AR_PIX_SIZE_DEFAULT == 4) //AR_DEFAULT_PIXEL_FORMAT == AR_PIXEL_FORMAT_BGRA || AR_DEFAULT_PIXEL_FORMAT == AR_PIXEL_FORMAT_RGBA
			*pixels = *ardata;
			pixels++; ardata++;
#elif (AR_PIX_SIZE_DEFAULT == 3) //AR_DEFAULT_PIXEL_FORMAT == AR_PIXEL_FORMAT_BGR || AR_DEFAULT_PIXEL_FORMAT == AR_PIXEL_FORMAT_RGB
	        pixels++;
#endif
		}
		
		dest->unlock();
	}
	else
	{
		printf("some hellish error¥n");
	}

	return dest;
}
Image

CvIrrCamController - 3D head tracking lib to create window effect with webcam
IrrAR - Attach Irrlicht nodes to real life markers
http://www.nighsoft.com/
freetimecoder
Posts: 226
Joined: Fri Aug 22, 2008 8:50 pm
Contact:

Post by freetimecoder »

Hi, its getting closer :)
I now get a undisorted image at the beginning. Just one thing left: The image is still frozen :(
The "dataPtr" from "arVideoGetImage" is not 0 though. Hm, just one last thing is standing between me and the use of this genious thing ^^

Edit: Ok, i checked everything again, the dataPtr IS 0. I just did not see the "return" at first.

greetings
ftc
FreakNigh
Posts: 122
Joined: Thu Oct 19, 2006 7:31 am
Location: Orlando FL, USA
Contact:

Post by FreakNigh »

It's zero!? That's really awkward... means that ARTk isn't bringing in anymore images from the camera.. Can you tell me how you went about solving making the image look right for the first frame?

I just released IrrAR-0.2 btw, and I made a sourceforge project for this lib. It now has some debugging support for the bad image conversions and scales the image to fit the screen correctly (so you don't have to mess around with screen resolutions anymore). Also I am building a little AR Spider Solitaire game to help me understand the needs someone would have with the IrrAR lib.
Image

CvIrrCamController - 3D head tracking lib to create window effect with webcam
IrrAR - Attach Irrlicht nodes to real life markers
http://www.nighsoft.com/
BlindSide
Admin
Posts: 2821
Joined: Thu Dec 08, 2005 9:09 am
Location: NZ!

Post by BlindSide »

Also I am building a little AR Spider Solitaire game to help me understand the needs someone would have with the IrrAR lib.
Fantastic idea, and nice way of putting it. I am always forgetting to do this until 6 months after I release a lib, and always find some shocking flaws/missing features that I overlooked. Good luck.

For your webcam capturing problems, I recall using this lib for webcam capture and passing the texture data onto ARToolKit. It was alot more hassle free than dealing with the ARToolKit methods.

Cheers
ShadowMapping for Irrlicht!: Get it here
Need help? Come on the IRC!: #irrlicht on irc://irc.freenode.net
freetimecoder
Posts: 226
Joined: Fri Aug 22, 2008 8:50 pm
Contact:

Post by freetimecoder »

I finally got it :)
ARUint8 *dataPtr;

//pull our next cam image
dataPtr = (ARUint8 *)arVideoGetImage();
arVideoCapNext();//<-This is important

if(!dataPtr)return 0;
And I solved the bad Image thing with:

Code: Select all

ITexture* IARManager::update_ITexture(ITexture *dest, ARUint8 *ardata)
{
   u8* pixels;
   pixels = (u8*)(dest->lock());
   if( pixels )
   {
      int max_pixels = dest->getSize().Width * dest->getSize().Height;
      
      for(int i=0;i<max_pixels;i++)
      {
         *pixels = *ardata;
         pixels++; ardata++;
         *pixels = *ardata;
         pixels++; ardata++;
         *pixels = *ardata;
         pixels++; ardata++;
//#if (AR_PIX_SIZE_DEFAULT == 4) //AR_DEFAULT_PIXEL_FORMAT == AR_PIXEL_FORMAT_BGRA || AR_DEFAULT_PIXEL_FORMAT == AR_PIXEL_FORMAT_RGBA
         *pixels = *ardata;
         pixels++; ardata++;
//#elif (AR_PIX_SIZE_DEFAULT == 3) //AR_DEFAULT_PIXEL_FORMAT == AR_PIXEL_FORMAT_BGR || AR_DEFAULT_PIXEL_FORMAT == AR_PIXEL_FORMAT_RGB
//           pixels++;
//#endif
      }
      
      dest->unlock();
   }
   else
   {
      printf("some hellish error¥n");
   }
 
   return dest;
} 
:lol: :wink:

Isn't she a true beuty?
http://freetimestudio.net/beauty.jpg
:D

Edit: I downloaded your irrAr 0.2. The test_irrAR.exe runs perfect.

greetings
ftc
Last edited by freetimecoder on Sat Sep 14, 2013 7:06 pm, edited 1 time in total.
grayman
Posts: 69
Joined: Thu May 12, 2005 10:48 am
Location: colombia

Post by grayman »

Dude!!! ive been waiting this for sooooo long! but i cant compile it!!!! i am on ubuntu 8 x64 and my IDE its NetBeans, i have a minidv camera and firewire 1394, when i try to configure to use the IEEE1394 doesnt work and after link all .h still the errors, could you help me to configure it?
System

AMD X2 4200
nvidia 7600gs 256mb
2GB ram DDR2
FreakNigh
Posts: 122
Joined: Thu Oct 19, 2006 7:31 am
Location: Orlando FL, USA
Contact:

Post by FreakNigh »

Are you able to get any of the ARToolkit examples like simpleTest to work?
Image

CvIrrCamController - 3D head tracking lib to create window effect with webcam
IrrAR - Attach Irrlicht nodes to real life markers
http://www.nighsoft.com/
grayman
Posts: 69
Joined: Thu May 12, 2005 10:48 am
Location: colombia

Post by grayman »

dude no!!! i get this message


No video config string supplied, using defaults.
video device (/dev/video0) open failed


and when i go to /dev i see this


/dev/dv1394

but you must know what irrAR its nuts!!! imagine AR games!! ill use it for many thing in my university!!! of course if i could compile it!
System

AMD X2 4200
nvidia 7600gs 256mb
2GB ram DDR2
FreakNigh
Posts: 122
Joined: Thu Oct 19, 2006 7:31 am
Location: Orlando FL, USA
Contact:

Post by FreakNigh »

Hmmmmmm

For you you need to go into irrAR.cpp and look and change

Code: Select all

	if(arVideoOpen("") < 0) return window_dimensions;
.. to this -

Code: Select all

dimension2di IARManager::beginCamera(char* cparam_filename, char* vconf_filename)
{
	dimension2di window_dimensions;
	
	window_dimensions.Width = 0;
	window_dimensions.Height = 0;
	
	/* open the video path */
#ifdef _WIN32
	if(arVideoOpen(vconf_filename) < 0) return window_dimensions;
#else
	if(arVideoOpen("-dev=/dev/dv1394") < 0) return window_dimensions;
#endif
	
	/* load camera param file */
	if(arParamLoad(cparam_filename, 1, &(this->wparam)) < 0) return window_dimensions;
	
You could also make a symlink of /dev/dv1394 to /dev/video0

EDIT: I added native support for this issue in the next release....
Image

CvIrrCamController - 3D head tracking lib to create window effect with webcam
IrrAR - Attach Irrlicht nodes to real life markers
http://www.nighsoft.com/
grayman
Posts: 69
Joined: Thu May 12, 2005 10:48 am
Location: colombia

Post by grayman »

i've downloaded artoolkit but i don't know where should i put it, and how configure it!!!

when i do a "make" it cannot find this .h, how should i set it? sorry i know its a silly question but it doesn't work just doing a "make".

irrAR.h:4:31: error: irrlicht/irrlicht.h: No existe el fichero ó directorio
irrAR.h:5:22: error: AR/video.h: No existe el fichero ó directorio
irrAR.h:6:22: error: AR/param.h: No existe el fichero ó directorio
irrAR.h:7:19: error: AR/ar.h: No existe el fichero ó directorio


this error is shown when i try to configure the ARtoolkit to use the option 3: Digital Video Camcoder through IEEE 1394 (DV Format)


../../../include/AR/sys/videoLinuxDV.h:24:22: error: libdv/dv.h: No existe el fichero ó directorio
In file included from ../../../include/AR/video.h:105,
from gsubUtil.c:19:
../../../include/AR/sys/videoLinuxDV.h:47: error: expected specifier-qualifier-list before ‘dv_decoder_t’
make[2]: *** [../../libARgsubUtil.a(gsubUtil.o)] Error 1
make[2]: se sale del directorio `/home/vladimir/Escritorio/sourcecode/ARToolKit/lib/SRC/Gl'
make[1]: *** [all] Error 2
make[1]: se sale del directorio `/home/vladimir/Escritorio/sourcecode/ARToolKit/lib/SRC'
make: *** [all] Error 2

and i guess what i have installed all dependencies im serious lost...im not a programmer i use blender!!!


dude, do you know if is possible connect the arduino (www.arduino.cc) within irrlicht?


AND the simbolic link mmmm i dont know

vladimir@vladimir-desktop:~/Escritorio/sourcecode/ARToolKit/bin$ sudo ln -S /dev/dv1394 /dev/video0
ln: creando el enlace duro «./video0» => «/dev/video0»: Enlace entre dispositivos inválido
vladimir@vladimir-desktop:~/Escritorio/sourcecode/ARToolKit/bin$ sudo ln -S /dev/video0 /dev/dv1394
ln: «/dev/dv1394»: no se permiten enlaces fuertes para directorios

it doesn't work either
System

AMD X2 4200
nvidia 7600gs 256mb
2GB ram DDR2
Post Reply