WorldViz User Forum

WorldViz User Forum (https://forum.worldviz.com/index.php)
-   Vizard (https://forum.worldviz.com/forumdisplay.php?f=17)
-   -   artoolkit load 3d objects into application (https://forum.worldviz.com/showthread.php?t=3636)

xcuddlex 03-16-2011 02:03 PM

artoolkit load 3d objects into application
 
greetings
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
viz.link(marker,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')
model2=viz.add('secondball.ive')
#Link model to marker sensor
viz.link(marker,model)
viz.link(marker2,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 05: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 05: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.

Thanks

Jeff 03-29-2011 03:54 PM

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

DamienH 03-30-2011 07: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 07:48 AM

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

Thanks anyway

xcuddlex 04-11-2011 08: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 06: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?

Code:

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

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


xcuddlex 04-18-2011 03: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
vizact.onupdate(viz.PRIORITY_INPUT-1,UpdateLargestMarker)

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 08:27 PM.

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