<commit_before>// Declare kinectron
var kinectron = null;

// Use two canvases to draw incoming feeds
var canvas; 
var ctx; 
var canvas2; 
var ctx2; 

// set a fixed 2:1 for the images
var CANVW = 512;
var CANVH = 256;

// Three.js variables
var width = window.innerWidth;
var height = window.innerHeight;
var camera, scene, renderer; 
var geometry, texture, mesh;
var geometry2, texture2, mesh2;

function changeCanvas(data) {
  // Image data needs to be draw to img element before canvas
  var img1 = new Image;
  img1.src = data.color; // get color image from kinectron data
  ctx.drawImage(img1,0,0, CANVW, CANVH);
  
  var img2 = new Image;
  img2.src = data.depth; // get depth image from kinectron data
  ctx2.drawImage(img2,0,0, CANVW, CANVH);
}

function init() {
  // Define and create an instance of kinectron
  var kinectronIpAddress = ""; // FILL IN YOUR KINECTRON IP ADDRESS HERE
  kinectron = new Kinectron(kinectronIpAddress);

  // Connect to the microstudio
  //kinectron = new Kinectron("kinectron.itp.tsoa.nyu.edu");

  // Connect remote to application
  kinectron.makeConnection();
  kinectron.startMultiFrame(["color", "depth"], changeCanvas);<commit_msg>Add onload function to draw image on canvas in box example<commit_after>// Declare kinectron
var kinectron = null;

// Use two canvases to draw incoming feeds
var canvas; 
var ctx; 
var canvas2; 
var ctx2; 

// set a fixed 2:1 for the images
var CANVW = 512;
var CANVH = 256;

// Three.js variables
var width = window.innerWidth;
var height = window.innerHeight;
var camera, scene, renderer; 
var geometry, texture, mesh;
var geometry2, texture2, mesh2;

function changeCanvas(data) {
  // Image data needs to be draw to img element before canvas
  var img1 = new Image;
  img1.src = data.color; // get color image from kinectron data

  img1.onload = function () {
    ctx.drawImage(img1,0,0, CANVW, CANVH);  
  };
  
  var img2 = new Image;
  img2.src = data.depth; // get depth image from kinectron data
  
  img2.onload = function () {
    ctx2.drawImage(img2,0,0, CANVW, CANVH);  
  }
  
}

function init() {
  // Define and create an instance of kinectron
  var kinectronIpAddress = ""; // FILL IN YOUR KINECTRON IP ADDRESS HERE
  kinectron = new Kinectron(kinectronIpAddress);

  // Connect to the microstudio
  //kinectron = new Kinectron("kinectron.itp.tsoa.nyu.edu");

  // Connect remote to application
  kinectron.makeConnection();
  kinectron.startMultiFrame(["color", "depth"], changeCanvas);
{'fraction_non_alphanumeric': 0.10430930326218284, 'fraction_numerical': 0.02013693113169553, 'mean_word_length': 3.669172932330827, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1071306', 'n_tokens_mistral': 895, 'n_tokens_neox': 869, 'n_words': 279}