Augmented Reality in JavaScript

6,881 views

Published on

Presented at JS.everywhere - San Francisco, 2013.

Published in: Technology, Business

Augmented Reality in JavaScript

  1. 1. augmented reality.js JS.everywhere, 2013 Friday, October 25, 13
  2. 2. @eduardolundgren Friday, October 25, 13
  3. 3. I’m from brazil Friday, October 25, 13
  4. 4. Friday, October 25, 13
  5. 5. I ♥ JavaScript Friday, October 25, 13
  6. 6. jQuery tracking.js AlloyUI jQueryUI YUI3 nodegh Liferay jQuery Simulate Friday, October 25, 13
  7. 7. jQuery tracking.js AlloyUI jQueryUI YUI3 nodegh Liferay jQuery Simulate Friday, October 25, 13
  8. 8. jQuery tracking.js AlloyUI jQueryUI YUI3 nodegh Liferay jQuery Simulate Friday, October 25, 13
  9. 9. jQuery tracking.js AlloyUI jQueryUI YUI3 nodegh Liferay jQuery Simulate Friday, October 25, 13
  10. 10. jQuery tracking.js AlloyUI jQueryUI YUI3 nodegh Liferay jQuery Simulate Friday, October 25, 13
  11. 11. jQuery tracking.js AlloyUI jQueryUI YUI3 nodegh Liferay jQuery Simulate Friday, October 25, 13
  12. 12. jQuery tracking.js AlloyUI jQueryUI YUI3 nodegh Liferay jQuery Simulate Friday, October 25, 13
  13. 13. jQuery tracking.js AlloyUI jQueryUI YUI3 nodegh Liferay jQuery Simulate Friday, October 25, 13
  14. 14. jQuery tracking.js AlloyUI jQueryUI YUI3 nodegh Liferay jQuery Simulate Friday, October 25, 13
  15. 15. today we’re going to talk about augmented reality... Friday, October 25, 13
  16. 16. Friday, October 25, 13
  17. 17. ...and how to integrate different HTML5 APIs Friday, October 25, 13
  18. 18. augmented reality is everywhere Friday, October 25, 13
  19. 19. first head-mounted display Friday, October 25, 13
  20. 20. google glass Friday, October 25, 13
  21. 21. what is augmented reality? Friday, October 25, 13
  22. 22. terminator Friday, October 25, 13
  23. 23. terminator Friday, October 25, 13
  24. 24. what is visual tracking? Friday, October 25, 13
  25. 25. visual tracking Friday, October 25, 13
  26. 26. how can you do it using JavaScript? Friday, October 25, 13
  27. 27. 1. capture webcam Friday, October 25, 13
  28. 28. Friday, October 25, 13
  29. 29. dev.w3.org/2011/webrtc/editor/webrtc.html Friday, October 25, 13
  30. 30. Friday, October 25, 13
  31. 31. STEP 1 Access user's camera navigator.getUserMedia({ video: true, audio: true }, onSuccess, onFail); Friday, October 25, 13
  32. 32. 2. play the captured video Friday, October 25, 13
  33. 33. Friday, October 25, 13
  34. 34. STEP 2 Play webcam's content into a video element function onSuccess(stream) { var video = document.querySelector('video'); video.src = window.URL.createObjectURL(stream); video.onloadedmetadata = function(e) { // Ready }; } Friday, October 25, 13
  35. 35. 3. track a pattern of pixels Friday, October 25, 13
  36. 36. Friday, October 25, 13
  37. 37. Friday, October 25, 13
  38. 38. Friday, October 25, 13
  39. 39. javascript typed arrays Friday, October 25, 13
  40. 40. “Study the past if you would define the future” - Confucius Friday, October 25, 13
  41. 41. fiducial markers Friday, October 25, 13
  42. 42. hitl.washington.edu/artoolkit Friday, October 25, 13
  43. 43. github.com/kig/JSARToolKit Friday, October 25, 13
  44. 44. soundstep.com/blog/experiments/jstracking/ Friday, October 25, 13
  45. 45. soundstep.com/blog/experiments/jstracking/ Friday, October 25, 13
  46. 46. bit.ly/XR0aGH Friday, October 25, 13
  47. 47. bit.ly/XR0aGH Friday, October 25, 13
  48. 48. what was the problem? Friday, October 25, 13
  49. 49. trackingjs.com Friday, October 25, 13
  50. 50. eduardo.io/3F0d360z2q1P Friday, October 25, 13
  51. 51. tracking.js features Friday, October 25, 13
  52. 52. Friday, October 25, 13
  53. 53. Friday, October 25, 13
  54. 54. eduardo.io/23033L0Q1i3z Friday, October 25, 13
  55. 55. eduardo.io/23033L0Q1i3z Friday, October 25, 13
  56. 56. STEP 1 COLOR TRACKING Import tracking.js core <script src="tracking.js"></script> Import tracking.js color module <script src="tracker/color.js"></script> Friday, October 25, 13
  57. 57. STEP 2 COLOR TRACKING Gets user's camera and renders it var videoCamera = new tracking .VideoCamera() .render(); Friday, October 25, 13
  58. 58. STEP 3 COLOR TRACKING Register tracking for yellow color videoCamera.track({ type: 'color', color: 'yellow', onFound: function() {}, onNotFound: function() {} }); Friday, October 25, 13
  59. 59. STEP 4 COLOR TRACKING Paint all detected pixels onFound: function(track) { var pixels = track.pixels, ctx = videoCamera.canvas.context; for (var i = 0, len = pixels.length; i < len; i += 2) { ctx.fillStyle = "rgb(255,0,255)"; ctx.fillRect(pixels[i], pixels[i+1], 2, 2); } ctx.fillStyle = "rgb(0,0,0)"; ctx.fillRect(track.x, track.y, 5, 5); } Friday, October 25, 13
  60. 60. Friday, October 25, 13
  61. 61. eduardo.io/233C2J0Q3z0U Friday, October 25, 13
  62. 62. eduardo.io/233C2J0Q3z0U Friday, October 25, 13
  63. 63. STEP 1 FACE DETECTION Register human tracking for frontal face videoCamera.track({ type: 'human', data: 'frontal_face', onFound: function() {}, onNotFound: function() {} }); Friday, October 25, 13
  64. 64. STEP 2 FACE DETECTION Paint all detected faces rectangles onFound: function(track) { for (var i = 0, len = track.length; i < len; i++) { var rect = track[i]; ctx.strokeStyle = "rgb(0,255,0)"; ctx.strokeRect( rect.x, rect.y, rect.size, rect.size); } } Friday, October 25, 13
  65. 65. real world examples Friday, October 25, 13
  66. 66. github.com/auduno/headtrackr Friday, October 25, 13
  67. 67. webdesign.maratz.com/lab/responsivetypography Friday, October 25, 13
  68. 68. webdesign.maratz.com/lab/responsivetypography Friday, October 25, 13
  69. 69. auduno.github.io/headtrackr/examples/targets.html Friday, October 25, 13
  70. 70. auduno.github.io/headtrackr/examples/targets.html Friday, October 25, 13
  71. 71. alexhancock.github.io/street-facing Friday, October 25, 13
  72. 72. alexhancock.github.io/street-facing Friday, October 25, 13
  73. 73. markerless tracking Friday, October 25, 13
  74. 74. unifeye viewer Friday, October 25, 13
  75. 75. github.com/eduardolundgren/tracking.js Friday, October 25, 13
  76. 76. let’s see in action? Friday, October 25, 13
  77. 77. popularity Friday, October 25, 13
  78. 78. 638 cities Friday, October 25, 13
  79. 79. 445 tweets Friday, October 25, 13
  80. 80. thank you :) @eduardolundgren Friday, October 25, 13

×