How to create a Buffer for applyToTexture (Vision /ARToolkit

Dear,
It’s been a long long time i’ve not made any development.
I’m trully impressed by Panda3D evolution in the meantime. Trully wish the tool i use at work would evolve as fast as P3D.

I’m investigating the Augmented Reality and i try to adapt one example from the forum.
However i have an issue with feeding the texture that the ARTToolkit must analyze.
At the line “self.cursor.applyToTexture(aBuffer, self.tex, 0)” , i don’t know how to create the buffer.
If i create it from “self.aBuffer=base.win.makeTextureBuffer(“hello”, 256, 256)” i get a TextureBuffer not a Buffer.

I would be grateful for a hint.

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(1)
          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/4x4_1.patt", 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.applyToTexture(aBuffer, self.tex, 0)
             self.ar.analyze(self.tex, True)
          return Task.cont



ejemplo = EjemploRealidadAumentada()
run()

You should be able to use a MovieTexture to wrap the WebcamVideo object, instead of messing with cursors yourself.

The Buffer object can only be accessed in C++.