View Single Post
  #3  
Old 09-29-2009, 07:32 AM
sircedric4 sircedric4 is offline
Member
 
Join Date: Aug 2009
Posts: 22
I think I am started down a good path towards making a marker file. I just don't know how to finish it up, whether I need to adjust the file back to a zero point between the markers or whether I need to preoffset the 3D model that I attach to the file. Here is the code I used in order to grab the matrixes from my 3 raw markers with my webcam.

Code:
#Add the other IMPORTS
import viz
import math
import vizinfo
import vizconfig
import random
import vizact
import vizinfo

viz.go()

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

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

#Setup origin marker
origincube = viz.add('cube_asm.wrl')
marker = camera.addMatrixMarker(0,width=100000)
#markerpos = camera.setGlobalMarker(marker)
originpos = viz.link(marker,origincube)

#Setup Marker
MarkerNumber = 4		#Change for marker you are looking for
MarkerWidth = 100000	#Change for marker you are looking for

#Calculations and Find marker
cube1 = viz.add('cube_asm.wrl')
marker1 = camera.addMatrixMarker(MarkerNumber,width=MarkerWidth)
cube1pos = viz.link(marker1,cube1)

#Print out marker location relative to origin
def UpdateLargestMarker():
	global MarkerWidth
	## Trying to get multimarker data based on current origin marker

	originmatrix = origincube.getMatrix(viz.ABS_GLOBAL)
	matrix1 = cube1.getMatrix(viz.ABS_GLOBAL)
		
	raw = camera.getRawMarkers()
	if raw:
		print 'Origin Matrix' + str(originmatrix)
		print 'Cube Matrix: ' + str(matrix1)
					
#Update raw pattern every frame
vizact.onupdate(viz.PRIORITY_INPUT-1,UpdateLargestMarker)
I take the print outs and convert them to the format that was outlined in the tutorial you mentioned. I take the first 3 numbers from the first 3 matrix lines for the angular/orientation data, and the first 3 numbers from the last matrix line for the position data for my configuration file. An easier method to describe this is:

-----orientation--------------- pos
line1num1 line1num2 line1num3 line4num1
line2num1 line2num2 line2num3 line4num2
line3num1 line3num2 line3num3 line4num3

I do this several times for the different markers that I am looking at to finally make the configuration file. It could be better coded but I was just using it as a testbed. The matrix answers I get from the printout look like they are accurate numbers in relation to each other. Also each cube is placed right on top of the corresponding matrix like it should be.

It seems that this matrix should be able to go into the configuration file, but when I go to use the matrix marker, the image I am augmenting on top of it acts extremely flakey and doesn't track well at all. I had assumed someone else had conquered this problem, since it would make creating your own multimarker files much easier, if you can just put the markers on what you want and shoot them with the camera.

If someone sees anything obviously wrong with my mentality I will take any help offered. I imagine part of the problem is that I am still having a hard time getting my head around all this 6DOF math with all the different matrixes.

Thanks.
Reply With Quote