WorldViz User Forum

WorldViz User Forum (
-   Vizard (
-   -   artoolkit load 3d objects into application (

xcuddlex 03-16-2011 01:03 PM

artoolkit load 3d objects into application
i've found an example code on how to save a marker pattern on the resource directory. it works ! i love it. and i wonder is it possible to create a menu where user can load desired pattern and 3d objects into the application?
let say this is the initial code

#Create marker from pattern file
marker = camera.addMatrixMarker(0, width=1000)
#Add model
model = viz.add('ball.ive')
#Link model to marker sensor,model)

okay now how can i create a GUI menu where i can use to load the saved marker and 3d objects so that the updated code would be

#Create marker from pattern file
marker = camera.addMatrixMarker(0, width=1000)
marker = camera.addMarker('new.patt', width=1000)
#Add model
model = viz.add('ball.ive')
#Link model to marker sensor,model),model2)

is it possible to do so?
i've created the dropdown menu as below
#Create a menu subject
MainMenu = menu.add( 'Main Menu' )
#Main Menu
#Add dropdown list of theme options to Main menu
themeDropDown = MainMenu.add( viz.DROPLIST, 'Model')
themeDropDown.addItems( ['Import','Delete','Edit'] )

i'm a beginner. i never use python before. so i dont know how to put action handling into the menu.

if it can save a pattern. i think it is possible to load a pattern and 3d objects too. please help. i want to add and make the artoolkit more interactive. any suggestion on how to do it ? thanks

Jeff 03-17-2011 04:33 PM

The vizmenu example script found in the example/graphicalUserInterface folder of the Vizard installation shows how to handle events for the different GUIs added to the menu. You can register a callback function for a GUI event where you can load the marker and model associated with the selection.

DamienH 03-29-2011 04:59 AM

xcuddlex, is it possible to tell me where you did find the code on how to save a marker pattern ? Couldn't find any help on it and I'm interested in it for a project.


Jeff 03-29-2011 02:54 PM

That script is called and it can be found in the examples -> artoolkit folder of the Vizard installation.

DamienH 03-30-2011 06:36 AM

Thanks I have it (it was pretty obvious though ...).

But I have trouble when using a pattern I saved on the ressource directory in an other application. I have the message : " **ERROR: Failed to load AR pattern: 'C:\Prog[...]' "

Is it because of the name or the extension of my file (I tried many different names) ?

Thanks for your help

DamienH 03-30-2011 06:48 AM

Problem solved, I was juste trying to load a MultiMarker instead of a Marker ...

Thanks anyway

xcuddlex 04-11-2011 07:08 AM

jeff or anyone who are willing to help,

can you provide a sample code on how i can load a marker that i have saved ? i dont have any idea on how to do it. python is really hard.

Jeff 04-11-2011 05:08 PM

You should be able to load a saved marker using the addMarker command with the name you gave it. Does that work for you?


#Create camera using first available webcam
camera = ar.addWebCamera()

#Create marker from pattern file
marker = camera.addMarker('myPattern',width=1000)

xcuddlex 04-18-2011 02:00 AM

hi jeff, yes it works
but i wanted to do a function where i can load it directly from my application

this is the code i found in the vizard resources

#Update raw pattern every frame

def SavePattern():
"""Displays save dialog for creating pattern from largest raw marker"""
if camera.largestMarker is not None:
parent = win32ui.CreateWindowFromHandle(viz.window.getHandl e())
dlg = win32ui.CreateFileDialog(0,None,None,0,None,parent )
if dlg.DoModal() == win32con.IDOK:
camera.savePattern(dlg.GetPathName(),camera.larges tMarker)

#Save current pattern when spacebar is pressed
vizact.onkeyup(' ',SavePattern)

i want to do the same thing for loading the saved pattern
for example, press ctrl+w to load pattern
but i dont have any idea how to do it because i never used python before
can you provide me any clue on how to do it jeff ? pseudocode is okay too.
i'll try to figure it out, thanks for the reply. really appreciate it

All times are GMT -7. The time now is 01:24 AM.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2021, vBulletin Solutions, Inc.
Copyright 2002-2018 WorldViz LLC