AR in Linux C++


i am trying to convert a sample of a AR into C++

i have created the window and a the card maker into c++ but i don know who to use the openCVtexture

can some one help me please

i put the ar sample in python and my version in c++

python example

from pandac.PandaModules import *
loadPrcFileData("", "auto-flip 1") #usualy the drawn texture lags a bit behind the calculted positions. this is a try to reduce the lag.

from direct.directbase import DirectStart
from direct.task import Task
from time import sleep

#------use OpenCVTexture under linux---------- use WebcamVideo under windows------------

tex = OpenCVTexture()

#if you want to know what assert is doing.. ask pro-rsoft. all i know is, it prevents an assertion error :D

assert tex.fromCamera(0)

#create a card which shows the image captured by the webcam.

cm = CardMaker("background-card")

cm.setFrame(-1, 1, 1, -1)

card = render2d.attachNewNode(cm.generate())


#set the rendering order manually to render the card-with the webcam-image behind the scene.

#load a model to visualize the tracking
axis = loader.loadModel("sofa.egg")

#initialize artoolkit, is our camera ,
#the camera_para.dat is the configuration file for your camera. this one comes with the artoolkit installation.
#last paremeter is the size of the pattern in panda-units.

ar = ARToolKit.make(, "./camera_para.dat", 1)

#attach the model to a pattern so it updates the model's position relative to the camera each time we call analyze()

ar.attachPattern("./patt.kanji", axis)

#updating the models positions each frame.

def updatePatterns(task):
	ar.analyze(tex, False)
  	return Task.cont
sleep(1) #some webcams are quite slow to start up so we add some safety

taskMgr.add(updatePatterns, "update-patterns",-100)


c++ example

// Include all the stuff
#include "pandaFramework.h"
#include "pandaSystem.h"
#include "movieTexture.h"
#include "cardMaker.h"
#include "openCVTexture.h"
PandaFramework framework;

//Global variables
PT(MovieTexture) tex = new MovieTexture("name");
int main(int argc, char *argv[]) {

framework.open_framework(argc, argv);
framework.set_window_title("My Panda3D Window");
WindowFramework *window = framework.open_window();
TextureStage *stage;
LVecBase2f scale;  

//Setup a fullscreen card to set the video texture on.
CardMaker cm = CardMaker::CardMaker("My Fullscreen Card");

NodePath *card = new NodePath(cm.generate());
scale = tex->get_tex_scale();     
card->set_tex_scale(stage->get_default(), scale); 
//do the main loop, equal to run() in python
//close the window framework
return (0);


What exactly is not working?

I do know that OpenCVTexture is broken in Panda3D 1.7.x, sorry.


the problem is how to use openCVtexture

in c++

i am using the 1.6.2 version o panda in ubuntu 9.10

where is the problem?
watch line 72 in the class references of your needed class. that how you declare your thingi. the panda sneeze vid dont have a known pattern inside, although he is black and white.

should not be hard to port this code into c++. :unamused: