WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 03-16-2011, 01:03 PM
xcuddlex xcuddlex is offline
Member
 
Join Date: Feb 2011
Posts: 11
Question 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
Reply With Quote
  #2  
Old 03-17-2011, 04:33 PM
Jeff Jeff is offline
WorldViz Team Member
 
Join Date: Aug 2008
Posts: 2,471
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.
Reply With Quote
  #3  
Old 03-29-2011, 04:59 AM
DamienH DamienH is offline
Member
 
Join Date: Mar 2011
Posts: 3
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
Reply With Quote
  #4  
Old 03-29-2011, 02:54 PM
Jeff Jeff is offline
WorldViz Team Member
 
Join Date: Aug 2008
Posts: 2,471
That script is called artoolkit_createPattern.py and it can be found in the examples -> artoolkit folder of the Vizard installation.
Reply With Quote
  #5  
Old 03-30-2011, 06:36 AM
DamienH DamienH is offline
Member
 
Join Date: Mar 2011
Posts: 3
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
Reply With Quote
  #6  
Old 03-30-2011, 06:48 AM
DamienH DamienH is offline
Member
 
Join Date: Mar 2011
Posts: 3
Problem solved, I was juste trying to load a MultiMarker instead of a Marker ...

Thanks anyway
Reply With Quote
  #7  
Old 04-11-2011, 07:08 AM
xcuddlex xcuddlex is offline
Member
 
Join Date: Feb 2011
Posts: 11
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.
Reply With Quote
  #8  
Old 04-11-2011, 05:08 PM
Jeff Jeff is offline
WorldViz Team Member
 
Join Date: Aug 2008
Posts: 2,471
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)
Reply With Quote
  #9  
Old 04-18-2011, 02:00 AM
xcuddlex xcuddlex is offline
Member
 
Join Date: Feb 2011
Posts: 11
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
Reply With Quote
Reply

Tags
3d model, artoolkit, gui, load, pattern

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Trouble picking text3d objects Salvar Vizard 4 12-01-2010 03:07 PM
Semi-circle array containing target and distractor objects ptjt255 Vizard 3 08-04-2009 03:09 AM
Lightwave objects rotation problem hosier Vizard 6 02-13-2009 12:04 PM
Improve performance with large number of onthefly objects? Fox5 Vizard 7 04-28-2008 05:19 PM
Could not find plugin to load objects... halley Vizard 1 05-30-2006 11:01 AM


All times are GMT -7. The time now is 07:55 AM.


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