FiducialManager

This proto was posted by peter on 2007-10-27.

So far there are 0 comments. Feel free to add one.

Quick links

Description

The FiducialManager makes it possible to use the reacTIVision fiducial tracking framework. It is based on the MIDI mode of the reacTIVision server.

Interface

Field name Value type Field type Default value
fiducials MFNode initializeOnly
No description

Proto code

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE X3D PUBLIC "ISO//Web3D//DTD X3D 3.0//EN" "http://www.web3d.org/specifications/x3d-3.0.dtd">
<X3D xmlns:xsd='http://www.w3.org/2001/XMLSchema-instance' profile='Full' version='3.0' xsd:noNamespaceSchemaLocation='http://www.web3d.org/specifications/x3d-3.0.xsd'>
  <Scene DEF='scene'>    
<ProtoDeclare name='FiducialManager' component='pyjax' documentation='The FiducialManager makes it possible to use the reacTIVision fiducial tracking framework. It is based on the MIDI mode of the reacTIVision server.'>        
      <ProtoInterface>
        <field name='fiducials' type='MFNode' accessType='initializeOnly'>
        </field>
      </ProtoInterface>    
      <ProtoBody>
        
        <IOSensor DEF='midiIn' type='midiin'>
          <field accessType='outputOnly' name='Midi Ctrl 0' type='SFFloat'/>
          <field accessType='outputOnly' name='Midi Ctrl 1' type='SFFloat'/>
          <field accessType='outputOnly' name='Midi Ctrl 2' type='SFFloat'/>
          <field accessType='outputOnly' name='Midi Ctrl 3' type='SFFloat'/>
          <field accessType='outputOnly' name='Midi Ctrl 4' type='SFFloat'/>
          <field accessType='outputOnly' name='Midi Ctrl 5' type='SFFloat'/>
          <field accessType='outputOnly' name='Midi Ctrl 6' type='SFFloat'/>
          <field accessType='outputOnly' name='Midi Ctrl 7' type='SFFloat'/>
          <field accessType='outputOnly' name='Midi Ctrl 8' type='SFFloat'/>
          <field accessType='outputOnly' name='Midi Ctrl 9' type='SFFloat'/>
          <field accessType='outputOnly' name='Midi Ctrl 10' type='SFFloat'/>
          <field accessType='outputOnly' name='Midi Ctrl 11' type='SFFloat'/>
          <field accessType='outputOnly' name='Midi Ctrl 12' type='SFFloat'/>
          <field accessType='outputOnly' name='Midi Ctrl 13' type='SFFloat'/>
          <field accessType='outputOnly' name='Midi Ctrl 14' type='SFFloat'/>
          <field accessType='outputOnly' name='Midi Ctrl 15' type='SFFloat'/>
          <field accessType='outputOnly' name='Midi Ctrl 16' type='SFFloat'/>
          <field accessType='outputOnly' name='Midi Ctrl 17' type='SFFloat'/>
          <field accessType='outputOnly' name='Midi Ctrl 18' type='SFFloat'/>
          <field accessType='outputOnly' name='Midi Ctrl 19' type='SFFloat'/>
          <field accessType='outputOnly' name='Midi Ctrl 20' type='SFFloat'/>
          <field accessType='outputOnly' name='Midi Ctrl 21' type='SFFloat'/>
          <field accessType='outputOnly' name='Midi Ctrl 22' type='SFFloat'/>
          <field accessType='outputOnly' name='Midi Ctrl 23' type='SFFloat'/>
          <field accessType='outputOnly' name='Midi Ctrl 24' type='SFFloat'/>
          <field accessType='outputOnly' name='Midi Ctrl 25' type='SFFloat'/>
          <field accessType='outputOnly' name='Midi Ctrl 26' type='SFFloat'/>
          <field accessType='outputOnly' name='Midi Ctrl 27' type='SFFloat'/>
          <field accessType='outputOnly' name='Midi Ctrl 28' type='SFFloat'/>
          <field accessType='outputOnly' name='Midi Ctrl 29' type='SFFloat'/>
          <field accessType='outputOnly' name='Midi Ctrl 30' type='SFFloat'/>
          <field accessType='outputOnly' name='Midi Ctrl 31' type='SFFloat'/>
          <field accessType='outputOnly' name='Midi Ctrl 32' type='SFFloat'/>
          <field accessType='outputOnly' name='Midi Ctrl 33' type='SFFloat'/>
          <field accessType='outputOnly' name='Midi Ctrl 34' type='SFFloat'/>
          <field accessType='outputOnly' name='Midi Ctrl 35' type='SFFloat'/>
          <field accessType='outputOnly' name='Midi Ctrl 36' type='SFFloat'/>
          <field accessType='outputOnly' name='Midi Ctrl 37' type='SFFloat'/>
          <field accessType='outputOnly' name='Midi Ctrl 38' type='SFFloat'/>
          <field accessType='outputOnly' name='Midi Ctrl 39' type='SFFloat'/>
          <field accessType='outputOnly' name='Midi Ctrl 40' type='SFFloat'/>
          <field accessType='outputOnly' name='Midi Ctrl 41' type='SFFloat'/>
          <field accessType='outputOnly' name='Midi Ctrl 42' type='SFFloat'/>
          <field accessType='outputOnly' name='Midi Ctrl 43' type='SFFloat'/>
          <field accessType='outputOnly' name='Midi Ctrl 44' type='SFFloat'/>
          <field accessType='outputOnly' name='Midi Ctrl 45' type='SFFloat'/>
          <field accessType='outputOnly' name='Midi Ctrl 46' type='SFFloat'/>
          <field accessType='outputOnly' name='Midi Ctrl 47' type='SFFloat'/>
          <field accessType='outputOnly' name='Midi Ctrl 48' type='SFFloat'/>
          <field accessType='outputOnly' name='Midi Ctrl 49' type='SFFloat'/>
          <field accessType='outputOnly' name='Midi Ctrl 50' type='SFFloat'/>       
          <field accessType='outputOnly' name='Midi NoteOn' type='SFInt32'/>
          <field accessType='outputOnly' name='Midi NoteOff' type='SFInt32'/>
        </IOSensor>
      
        <Script DEF='s' directOutput='true' mustEvaluate='true'>              
          <field name='midiIn' type='SFNode' accessType='initializeOnly'>
              <IOSensor USE='midiIn' />
          </field>          
          <field name='fiducials' type='MFNode' accessType='initializeOnly' />                                          
          <field name='set_noteOn' type='SFInt32' accessType='inputOnly' />
          <field name='set_noteOff' type='SFInt32' accessType='inputOnly' />
          
          <IS>
              <connect protoField='fiducials' nodeField='fiducials' />
          </IS>
          <![CDATA[
              ecmascript:
              
              function initialize() {
                  var nrOfFiducials = 0;
                  if (fiducials == null || fiducials.length == 0) 
                      Browser.println("FiducialManager::initalize: No Fiducials in 'fiducials' field. Tracking fiducials will NOT work!");  
                  else if (fiducials != null && fiducials.length > 17) {
                      Browser.println("FiducialManager::initalize: Nr of fiducials requested: " + 
                                      fiducials.length + ". Maxium number of fiducials supported: 17." +
                                      " Trackking will NOT work correctly.");  
                  }
                  else {
                      nrOfFiducials = fiducials.length;
                      Browser.println('FiducialManager::initalize: nrOfFiducials=' + nrOfFiducials);
                      Browser.addRoute(midiIn, "Midi NoteOn", this, "set_noteOn");
                      Browser.addRoute(midiIn, "Midi NoteOff", this, "set_noteOff");
                                      
                      var findex = 0;
                      for(i=0; i<nrOfFiducials; i++) {
                          Browser.addRoute(midiIn, "Midi Ctrl "+ i*3, fiducials[findex], "set_xpos");
                          Browser.addRoute(midiIn, "Midi Ctrl "+ (i*3 +1), fiducials[findex], "set_ypos");
                          Browser.addRoute(midiIn, "Midi Ctrl "+ (i*3 +2), fiducials[findex], "set_angle");
                          findex++;
                      }                                
                  }
              }                    
              
              function set_noteOn(nr, t) { fiducials[nr].add = t; }                  
              function set_noteOff(nr, t) { fiducials[nr].delete_ = t; }            
          ]]>                                  
        </Script>
          
      </ProtoBody>    
    </ProtoDeclare>          
  </Scene>
</X3D>

Test code

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE X3D PUBLIC "ISO//Web3D//DTD X3D 3.0//EN" "http://www.web3d.org/specifications/x3d-3.0.dtd">
<X3D xmlns:xsd='http://www.w3.org/2001/XMLSchema-instance' profile='Full' version='3.0' xsd:noNamespaceSchemaLocation='http://www.web3d.org/specifications/x3d-3.0.xsd'>
  
  <Engine desiredFrameRate='60' > 
    <RenderJob>
      <WindowGroup>
        <Window size='960 440' />
      </WindowGroup>
    </RenderJob>
  </Engine>

  <Scene DEF='scene'>
    
    <ExternProtoDeclare name='Fiducial' url='FiducialManager_PROTO.x3d#Fiducial' />  
    <ExternProtoDeclare name='FiducialManager' url='FiducialManager_PROTO.x3d#FiducialManager' />         
    
    <DirectionalLight DEF='light' />
    <NavigationInfo type='none' headlight='false' />
    <OrthoViewpoint position='0 0 20' fieldOfView='-4.5 -4.5 4.5 4.5' />
    <GradientBackground color='0 0 0, 0.2 0.2 0.2 ' position='0.7 1'/>    
    
    <FiducialManager DEF='fiducialManager' >
        <Fiducial DEF='fiducial0' index='0' posScale='10 8' containerField='fiducials' />
        <Fiducial DEF='fiducial1' index='1' posScale='10 8' containerField='fiducials' />
        <Fiducial DEF='fiducial2' index='2' containerField='fiducials' />
        <Fiducial DEF='fiducial3' index='3' containerField='fiducials' />      
    </FiducialManager>   
    
    <Transform translation='0 -0.5 0' >
      <Transform translation='-7.7 4 0' scale='0.8 0.8 0.8' >
        <Shape>
          <Text string='reacTIVision in InstantPlayer'>
            <FontStyle family='"Arial" "SANS"' style='bold' />
          </Text>
        </Shape>
      </Transform>        
      
      <Anchor url='http://www.pyjax.net/'>
        <Transform DEF='pyjaxTrans' translation='3.2 4 0' >
          <Shape>
            <Text DEF='pyjaxText' solid='false' string='"Find more X3D tutorials on pyjax.net"'>
              <FontStyle family='"Arial" "SANS"' style='plain' size='0.3' />
            </Text>
            <Appearance><Material /></Appearance>
          </Shape>
        </Transform>
      </Anchor>
          
    </Transform>      
      
    <Transform DEF='tr' translation='-4 -4 0' >
      <Transform DEF='transObj0' translation='-4.5 0 0' >
          <Shape containerField='children'>
            <Appearance>
              <Material diffuseColor='0 1 0' />
              <TextTexture string='F1' />
            </Appearance>
            <Plane solid='false' />
          </Shape>
      </Transform>
      <Transform DEF='transObj1'>        
        <Shape containerField='children'>
          <Appearance>
            <Material diffuseColor='0 0 1' transparency='0' />
            <TextTexture string='F2' />
          </Appearance>
          <Plane solid='false' />
        </Shape>  
      </Transform >      
    </Transform>
    
    <TimeSensor DEF='ts' cycleInterval='10' loop='true'/>
        
    <Logger DEF='logger' level='3' />
    <ROUTE fromNode='fiducial0' fromField='visible' toNode='transObj0' toField='render'/>
        
    <PositionChaser DEF='posChaser0' duration='0.5' />
    <ROUTE fromNode='fiducial0' fromField='pos' toNode='posChaser0' toField='set_destination'/>    
    <ROUTE fromNode='posChaser0' fromField='value_changed' toNode='transObj0' toField='translation'/>    
    
    <OrientationInterpolator DEF='oi2' key='0 0.25 0.5 0.75 1' keyValue='0 0 1 0  0 0 1 1.57  0 0 1 3.14  0 0 1 4.71  0 0 1 6.28'/>
    <OrientationChaser DEF='oc2' duration='0.5' />
    <ROUTE fromNode='fiducial0' fromField='angle' toNode='oi2' toField='set_fraction'/>    
    <ROUTE fromNode='oi2' fromField='value_changed' toNode='oc2' toField='set_destination'/>
    <ROUTE fromNode='oc2' fromField='value_changed' toNode='transObj0' toField='set_rotation'/>
    
    <ROUTE fromNode='fiducial1' fromField='visible' toNode='transObj1' toField='render'/>
    <PositionChaser DEF='posChaser1' duration='0.5' />
    <ROUTE fromNode='fiducial1' fromField='pos' toNode='posChaser1' toField='set_destination'/>    
    <ROUTE fromNode='posChaser1' fromField='value_changed' toNode='transObj1' toField='translation'/>    
            
  </Scene>
</X3D>

Comments

There are no comments yet.

Add a comment