Hi, i’m trying to install panda3d with artoolkit support. in ubuntu 12.10 and 11.10 all the libraries running, but in 12.10 after build successful the source, panda not found artoolkit.
In 11.10 i compile all the libraries and install oneiric package, but when i run a example of artoolkit i obtain this error:
self.ar.attachPattern("ar/patt.sample1", self.ralphFlag)
AttributeError: 'NoneType' object has no attribute 'attachPattern'
I run five examples (downloaded, not edited ) with the same error (the second line). Maybe is simple, i have no experience with panda.
import direct.directbase.DirectStart
from pandac.PandaModules import ARToolKit,WebcamVideo,Texture,CardMaker,Vec2,Point2
from direct.task import Task
class EjemploRealidadAumentada:
"""
ejemplo de realidad aumentada
Requerimientos:
- Panda3D (ult. version probada: 1.6.2)
- ARToolkit. (version probada: 2.72.1)
"""
def __init__(self):
"""
Inicia la webcam, importa el modelo y lo vincula al patron
AR a buscar.
"""
# Inicia la webcam
option = WebcamVideo.getOption(0)
self.cursor = option.open()
# Genera una textura que contiene el "feed" de la webcam
self.tex = Texture('movie')
self.tex.setTexturesPower2(0)
self.cursor.setupTexture(self.tex)
videoTextureScale = Vec2(option.getSizeX()/float(self.tex.getXSize()), option.getSizeY()/float(self.tex.getYSize()))
# Crea una card que muestra la imagen capturada por la webcam
cm = CardMaker("background-card")
cm.setFrame(-videoTextureScale[1],videoTextureScale[1],-videoTextureScale[0],videoTextureScale[0])
# Pone las coordenadas uv de la card, y-scale debe estar reversado.
cm.setUvRange(Point2(videoTextureScale[0],0), Point2(0,videoTextureScale[1]))
card = render2d.attachNewNode(cm.generate())
card.setTexture(self.tex)
#Configura el orden de renderizacion manualmente para renderizar la card detras de la escena.
base.cam.node().getDisplayRegion(0).setSort(20)
#Carga el modelo del panda (incluido con Panda3D)
b = loader.loadModel("models/ralph")
b.setScale(0.1)
#Inicia ARToolkit, y vincula el patron dado en el archivo .hiro al modelo cargado.
self.ar = ARToolKit.make(base.cam, "ar/camera_para.dat", 1)
b.reparentTo(self.ar)
self.ar.attachPattern("ar/patt.sample1", b)
# Agrega el task ARTask el cual se encarga de actualizar la AR.
taskMgr.add(self.actualizarAR, "ARTask")
def actualizarAR(self,task):
"""
Revisa la escena y actualiza el AR.
"""
if self.cursor.ready():
self.cursor.fetchIntoTexture(0, self.tex, 0)
self.ar.analyze(self.tex, True)
return Task.cont
ejemplo = EjemploRealidadAumentada()
run()
DirectStart: Starting the game.
Known pipe types:
glxGraphicsPipe
(all display modules loaded.)
:display:glxdisplay(warning): No suitable FBConfig contexts available; using XVisual only.
depth_bits=24 color_bits=24 alpha_bits=8 stencil_bits=8 back_buffers=1 force_hardware=1
:vision(error): Cannot load ARToolKit camera config
Traceback (most recent call last):
File "/home/timbis/arsample/sample.py", line 66, in <module>
ejemplo = EjemploRealidadAumentada()
File "/home/timbis/arsample/sample.py", line 48, in __init__
b.reparentTo(self.ar)
TypeError: NodePath.reparent_to() argument 1 must be NodePath, not NoneType
Ah, you failed to include the actual error in your original post:
:vision(error): Cannot load ARToolKit camera config
This means that it failed to load your camera config file. Does the file ar/camera_para.dat actually exist, and is the path specified relative to the current working directory?
It’s not recommended to use sys.path[0] since it’s not very reliable.
However, relative paths work fine for me in ARToolKit.make. Are you sure you’re running Python in the directory that your paths are relative to?