Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.



Published on

Published in: Technology
  • Be the first to comment

  • Be the first to like this


  1. 1. Maya tutorial In this tutorial we will augment a real scene with virtual objects. This tutorial assumes that you have downloaded the file from the course web page and extracted it somewhere. 1 Camera calibration The first step is to calibrate our camera, so that we can set the camera parameters in Maya. This is done using Matlab and the camera calibration toolbox. 1. Start Matlab and change the working directory to the location where you extracted the files 2. Add the path to the calibration toolbox (folder TOOLBOX_calib) to the path using File->Set Path 3. Run calib_gui and select ’Standard’ 4. In the calibration GUI click on the button ’Image names’ and enter ’pattern’ for the basename, then enter ’j’ for jpeg 5. In the calibration GUI click on the button ’Extract grid corners’ 6. Answer all questions with the default values by pressing enter 7. Select the corners of the inner 7x5 grid in the first image in the order upper left, upper right, lower right, lower left and answer all question by pressing enter (see figure 1) 8. Select the corners of the inner 7x5 grid in the second image in the order lower left, upper left, upper right, lower right and answer all question by pressing enter (see figure 1) 9. In the calibration GUI click on the button ’Calibration’. The resulting pixel errors should be smaller than one pixel (if you clicked well they should be around 0.18) 1
  2. 2. The second step is to find the external camera parameters of the image which we want to augment. This is also done using the camera calibration toolbox. 1. In the calibration GUI select ’Comp. Extrinsic’ and enter ’scene’ and ’j’ to select the image 2. Answer all questions by pressing enter and click the corners of the inner 7x5 grid in the order upper left, upper right, lower right, lower left (see figure 1) 3. Run createMayaScene(KK,Rc_ext,Tc_ext,’scene.jpg’) to create the MEL- script which sets up the scene in Maya. KK are the internal camera param- eters, Rc_ext and Tc_ext are the external camera parameters of the camera viewing our scene and the last parameter is the name of the image which is to be used as the backgound of the scene. Figure 1: Corner points on pattern1 and pattern2 and the world coordinate system of the scene The next steps will be done in Maya. 1. Start Maya 2. Go to Window->Settings/Preferences->Preferences: Under Settings set the up-axis to z and under Settings->Cameras set the far clip plane to 100000. Save the changes 3. Go to Window->General Editors->Script Editor: Select File->Source Script and open the script you just created (setupScene.mel). Close the script edi- tor 4. Change the active camera to camera 1, by selecting Panels->Perspective- >camera1 in the view panel 5. In the view go to View->Camera Attribute Editor and set the far clip plane to 10000 2
  3. 3. 6. In the view go to View->Image Plane->Image Plane Attributs->imagePlane1 and set the depth to 9000 7. Go to Create->Polygon Primitives and disable Interactive Creation 8. Click somewhere in the view panel and press ’6’ to enable shaded rendering. Now the middle of the calibration grid should be gray. 9. Right click on the plane over the calibration grid and keep the button pressed 10. Select Assign New Material->Lambert 11. On the right in the attribute editor click on the little checkerboard next to color and select Checker. The plane should now show a checkerboard pat- tern. To make it look like the real calibration grid we have to change some settings. In the attribute editor go to the second tab called place2dTexture1. Set Repeat UV to 2.5 and 3.5 respectively and Offset to 0.5 and 0.0 respec- tively and press enter. Now the checkerboard should look correct. 12. Go to Create->Polygon Primitives->Sphere to create a sphere 13. In the attribute editor go to the polySphere1 tab and set the radius to 20. In the pSphere1 tab set the z-value of the translation to 20. The sphere should now be lying on the table. 14. Assign a color to the sphere by right clicking and selecting Assign New Material->Phong. Set the color in the attribute editor to yellow. 15. Go to Create->CV Curve Tool and draw a curve on the table by setting con- trol points. Make sure that the curve also passes behind the book holders. Press enter after you set the last point. 16. In the attribute editor set the translation to 20 units in the z-direction 17. In the lower region of the window set the length of the sequence to 1000 (in the field which contains 24.00) 18. Select animation from the drop-down menu below the menu-bar. Select the sphere and while holding the shift-key select the curve. go to Animate- >Motion Paths->Attach to Motion Path. When you click on the play button in the lower right hand corner of the window you should see the sphere moving on the table. However it is still visible when passing behind the book holders. 3
  4. 4. 19. Create a construction plane (Create->Construction Plane). Go to plane1 in the attribute editor and set the rotation about the x-axis to 90 degrees. Set the translation to -200, 110 and 100 respectively and the scaling to 350, 100 and 1 respectively. Now it should be passing through the middle of the book holders. 20. Make the plane live (Modify->Make Live). The plane should turn green and you cannot see the bookholders anymore. To change this uncheck Planes in the show menu in the view panel. 21. Select Polygons from the drop-down menu below the menu bar. Select Mesh->Create Polygon Tool. Press ’4’ to switch to wireframe mode. Follow the outline of the bookholders starting with the duck. Before closing the polygon we still need to remove the small hole at the back of the duck. To do this click the first vertex of the hole while holding the ctrl button. Release the ctrl button and set the other vertices normally. Once you set the last vertex press enter. Repeat the same procedure for the elephant. Press ’6’ to go to the shaded rendering. 22. Assign the background color material to the polygons (Right click and hold, Assign New Material->Use Background). You will not see a change in the view. 23. Render the scene (Rendering in drop down menu, Render->Render Current Frame) and you should only see the sphere without the polygons. 24. Create a ground plane (Create->Polygon Primitives->Plane), covering the whole table (set it’s size to 1000x2000). Move it by -1 in the z-direction. give it the background material 25. Add an ambient light (Create->Lights->Ambient Light) 26. Add a spot light (Create->Lights->Spot Light). In the attribute editor set the intensity to 0.8 and the cutoff angle to 140. Go to the light settings and enable depth-map shadows. Set the translation to -200 100 400. 27. Go to the render settings. Select image sequence, avi and set the range of the frames to render to 1-1000. Make certain that the render camera is camera1. 28. In the Render menu select Batch Render and wait until the rendering is done. (This can take a while). 4
  5. 5. Figure 2: Screenshots of the scene after working steps 4, 11, 14, 16, 18, 19, 21 and 22 5