Augmented Reality Woes [SOLVED ...sort of]

Alright, I’ve got multiple cameras working with the ARtoolkit which means I can now view life-sized models without having to stare at the ground.

My only issue is that after a minute or two the script crashes to the terminal with assertion errors. I’m using Windows so the fix in “ARtoolKit-sample.py” doesn’t work for me. Here’s a watered down version of what I’m doing (this only has two camera’s instead of the 5 my HMD uses but the principle is the same).

Any suggestions or comments would be greatly appreciated.

from pandac.PandaModules import *
from direct.directbase.DirectStart import *
from time import sleep
loadPrcFileData("", "auto-flip 1")

def update(task):
    if cursor.ready() and cursor2.ready:
     cursor2.fetchIntoTexture(0, videoTexture, 0)
     cam2.analyze(videoTexture, True)
     cursor.fetchIntoTexture(0, videoTexture, 0)
     cam1.analyze(videoTexture, True)
    
    return task.cont

base.camLens.setNear(0.1)
base.camNode.getDisplayRegion(0).setDimensions(0, 1 + 0.3202, 0 - 0.0169, 1 + 0.0169)
base.cam.node().getDisplayRegion(0).setSort(20)

option = WebcamVideo.getOption(0)
cursor = option.open()
option2 = WebcamVideo.getOption(19)
cursor2 = option2.open()
videoTexture = Texture('movie')
cursor2.setupTexture(videoTexture)
videoTextureScale = Vec2(option2.getSizeX()/float(videoTexture.getXSize()), option2.getSizeY()/float(videoTexture.getYSize())) 
cursor.setupTexture(videoTexture)
videoTextureScale = Vec2(option.getSizeX()/float(videoTexture.getXSize()), option.getSizeY()/float(videoTexture.getYSize()))   


assert 1 >= 0, "Unlike pro-rsoft I can't use asserts to fix other asserts but I'm pretty sure it involves a chicken and an altar"






cardMaker = CardMaker('cardMaker')
cardMaker.setFrame(-4/3.0,4/3.0,-1,1)
cardMaker.setUvRange(Point2(videoTextureScale[0],0), Point2(0,videoTextureScale[1]))
card = render.attachNewNode(cardMaker.generate())
card.setTexture(videoTexture)
card.setTwoSided(True)
card.setY(5)
card.setX(-1)
card.setScale(1.72)
card.setSx(-card.getSx())
card.setBin("fixed", -1)
card.setDepthTest(False)
card.setDepthWrite(False)


model = loader.loadModel("ralph")
model.reparentTo(render)
model.setBin("fixed", 1)
model.setScale(1)
model.setDepthTest(True)
model.setDepthWrite(True)

cam1 = ARToolKit.make(base.cam, Filename("camera1.dat"), 1)
cam1.attachPattern(Filename("patt.hiro"), model)
cam2 = ARToolKit.make(base.cam, Filename("camera2.dat"), 1)
cam2.attachPattern(Filename("patt.hiro"), model)
taskMgr.add(update, "update")

sleep(1) 
taskMgr.add(update, "update-patterns",-100)

       
run()

EDIT: I might add that this is the error I get-

AssertionError: !(pos.is_nan() || hpr.is_nan() || scale.is_nan() || shear.is_nan
()) at line 231 of c:\panda3d-1.7.0\panda\src\pgraph\transformState.cxx

I don’t know anything about ARToolkit, but that assertion error generally means someone tried to stuff an invalid value (NaN) in a node position, hpr, or scale. The full stacktrace would tell you more information about who is being bad here, but I suspect you’re getting garbage out of ARToolkit for some reason.

David

Thanks, David

Looks like you’re right about the garbage output. I’m working on a possible fix. Josh Yelon needs to be knighted for gluing all this to Panda (And the factory owner too that makes $3 webcams.)