WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 03-14-2017, 04:08 AM
rajnishv rajnishv is offline
Member
 
Join Date: Jan 2016
Location: Kalina,Sanatcruz(East),Mumbai,Maharashtra,India
Posts: 94
Smile Regarding Vizard Augmented Reality Custom Pattern Creation

Hi Jeff,
I am preparing a demo in which i have to create a pattern and save it , load it using AR modules in Vizard and draw a 3D model on to the pattern saved.

When my program gets executes.
It opens a web cam to get the markers data using
code:raw = camera.getRawMarkers()

I am trying to draw lines on to the edges of the car model using

Code:
viz.startLayer(viz.LINES)
....
...
square = viz.endLayer()

I am using the code from 'artoolkit_createPattern.py' code to save the pattern tracked by the web cam using the vizards artoolkit.

But when i m tracking it draws the layer randomly and sometimes goes off.
I dont want random lined to be drawn.

How can i accurately get all the data points (by considering edges,wheels,etc)using the layers (lines,points,polygons,etc) on the car Model as which can be saved as a marker and can be used to Augment a 3D model on to a car.

Pls assist how to proceed further.
PFA the code and the screen shot of the pattern.
Waiting for ur reply.
Attached Thumbnails
Click image for larger version

Name:	carPattern.png
Views:	890
Size:	820.8 KB
ID:	914  
Attached Files
File Type: zip VizardPatternSaveScript.zip (978 Bytes, 1064 views)

Last edited by rajnishv; 03-14-2017 at 04:11 AM.
Reply With Quote
  #2  
Old 03-14-2017, 09:36 PM
Jeff Jeff is offline
WorldViz Team Member
 
Join Date: Aug 2008
Posts: 2,471
It seems like the solution you are asking for is beyond the scope of what we can help with on the forum. For help with code on the forum it needs to follow the guidelines for posting Vizard code.
Reply With Quote
  #3  
Old 03-14-2017, 10:50 PM
rajnishv rajnishv is offline
Member
 
Join Date: Jan 2016
Location: Kalina,Sanatcruz(East),Mumbai,Maharashtra,India
Posts: 94
H Jeff,
I am using the following code to save the pattern.
Is there any possibility using the code to get all the points and edged perfectly and save it as a pattern and then can be used to augment a 3D Model.
Or is there way to use OpenCv with AR ToolKit of Vizard combined together to get the result?

Code:
"""
Press spacebar to save highlighted pattern to file
Press F12 to display camera debugging controls
"""
import viz
import vizact
import vizinput
viz.go()

#Add ARToolkit extension
ar = viz.add('artoolkit.dle')

#Create camera from texture
camera = ar.addWebCamera()
camera.largestMarker = None



#Example for creating a set of lines: 
viz.startLayer(viz.POINTS) 
viz.vertexColor(0,0,1)
viz.pointSize(5)
viz.vertexColor(0,1,0) 

viz.vertex(-1,1,5) #Vertices are split into pairs. 
viz.vertex(-1,18,5) 

viz.vertex(-1,2,5) #Vertices are split into pairs. 
viz.vertex(-1,17,5)

viz.vertex(-1,3,5) #Vertices are split into pairs. 
viz.vertex(-1,29,5)

viz.vertex(-1,1,5) 
viz.vertex(10,2,-6)

viz.vertex(-1,3,5) 
viz.vertex(10,6,-6)


viz.vertex(-1,5,5) 
viz.vertex(10,9,-6)

viz.vertex(10,2,-6)
viz.vertex(10,18,-6)\


viz.vertex(10,3,-6)
viz.vertex(10,7,-6)

viz.vertex(10,6,-6)
viz.vertex(10,9,-6)

viz.vertex(10,18,-6)
viz.vertex(-1,18,5) 

viz.vertex(10,2,-6)
viz.vertex(40,0,-50)

viz.vertex(40,2,-50)
viz.vertex(40,18,-50)

viz.vertex(40,18,-50)
viz.vertex(10,18,-6)
 
square = viz.endLayer() 


def UpdateLargestMarker():
	"""Finds raw marker with largest pixel area"""
	raw = camera.getRawMarkers()
	if raw:
		raw.sort(key = lambda r: r.area)
		camera.largestMarker = raw[0]
		square.setMatrix( camera.getRawMarkerMatrix(raw[0],width=5000) )
		square.visible(1)
	else:
		camera.largestMarker = None
		square.visible(0)

#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:
		filename = vizinput.fileSave()
		if filename:
			camera.savePattern(filename,camera.largestMarker)

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

#Allow configuring camera
import vizconfig
vizconfig.register(camera)
vizconfig.getConfigWindow().setWindowAlignment(viz.ALIGN_RIGHT_BOTTOM)

Last edited by rajnishv; 03-14-2017 at 10:58 PM.
Reply With Quote
  #4  
Old 03-16-2017, 04:28 AM
rajnishv rajnishv is offline
Member
 
Join Date: Jan 2016
Location: Kalina,Sanatcruz(East),Mumbai,Maharashtra,India
Posts: 94
Hi Jeff,
I have posted my code as instructed,also pls if u can can help me with code to get accurate pattern to get saved.

Also pls suggest me on how to integrate OpenCV with Vizard.

I also followed posts on worldviz on OpenCv and Vizard,but no breakthrough.

Link:
http://forum.worldviz.com/showthread.php?t=3696

http://forum.worldviz.com/showthread.php?t=2536


I have tested individually with Python GUI IDLE by visiting the following link and using the below versions to get applications run with Python GUI IDLE:
Link:
https://opencv-python-tutroals.readt...hon-in-windows

1.1.Python-2.7.x.
1.2.numpy-1.8.0-win32-superpack-python2.7.exe
1.3.matplotlib-1.3.0.win32-py2.7.exe



Some Questions:

a)How can use Vizard 5.1 or latest with the above versions of OpenCV,Python,numpy&matplotlib?

b)I am using Vizard 5.1,which OpenCv Version will be compatible to vizard 5.1 or to latest Vizard?

c)Which necessary files and where to copy fom OpenCV(cv or cv2) to Vizard's folder?


Pls assist me further with code or on how to intergrate Vizard with OpenCv.

Last edited by rajnishv; 03-16-2017 at 04:38 AM.
Reply With Quote
  #5  
Old 03-16-2017, 10:50 PM
Jeff Jeff is offline
WorldViz Team Member
 
Join Date: Aug 2008
Posts: 2,471
We don't have any instructions for using OpenCV with Vizard. Try searching online for OpenCV and Python tutorials.
Reply With Quote
Reply

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
Vizard 4 Beta Testing farshizzo Announcements 0 02-01-2011 10:46 AM
Vizard 4 Beta Testing farshizzo Vizard 0 02-01-2011 10:46 AM
help with augmented reality and physics Darkmax Vizard 1 06-12-2010 03:26 PM
Vizard tech tip: Using the Python Imaging Library (PIL) Jeff Vizard 0 03-23-2009 11:13 AM
Vizard and Augmented Reality realvision Vizard 4 04-04-2008 10:59 AM


All times are GMT -7. The time now is 07:32 PM.


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