# How to change the canvas size of kinect?

**URL:** <https://discourse.processing.org/t/how-to-change-the-canvas-size-of-kinect/13701>\
**Category:** Electronics (Arduino, etc.)\
**Created:** [August 30, 2019, 10:07am UTC](https://discourse.processing.org/t/how-to-change-the-canvas-size-of-kinect/13701 "2019-08-30T10:07:27Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![AbleYudada](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/ableyudada/32/14190_2.png) [@AbleYudada](https://discourse.processing.org/u/AbleYudada)\
**Post date:** [August 30, 2019, 10:07am UTC](https://discourse.processing.org/t/how-to-change-the-canvas-size-of-kinect/13701/1 "2019-08-30T10:07:27Z")

</div>

I am playing with the Kinect and when I enlarge the size of the canvas, the Kinect window stays the same size and does not expand to match the size of the canvas. How can I enlarge it?

---

<div class="post-metadata">

**Author:** ![AbleYudada](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/ableyudada/32/14190_2.png) [@AbleYudada](https://discourse.processing.org/u/AbleYudada)\
**Post date:** [August 30, 2019, 10:08am UTC](https://discourse.processing.org/t/how-to-change-the-canvas-size-of-kinect/13701/2 "2019-08-30T10:08:16Z")

</div>

import processing.serial._;  
import KinectPV2._;

Serial myPort;  
KinectPV2 kinect;

boolean foundUsers = false;  
PImage img;  
int matrixSizeWidth = 14;  
int matrixSizeHeight = 18;

void setup() {  
size(1920, 1080);  
frameRate(200);

//String portName = “COM5”;  
// myPort = new Serial(this, portName, 115200);

kinect = new KinectPV2(this);

[//kinect.enableDepthImg](https://kinect.enableDepthImg)(true);  
kinect.enableBodyTrackImg(true);  
img = createImage(512, 424, RGB);  
kinect.init();

// delay(6000);  
}

void draw() {  
clear();  
background(255);

PImage kinectImg = kinect.getBodyTrackImage();

int [] rawData = kinect.getRawBodyTrack();

foundUsers = false;  
//iterate through 1/5th of the data  
for(int i = 0; i \< rawData.length; i+=5){  
if(rawData[i] != 255){  
//found something  
foundUsers = true;  
break;  
}  
}  
// print(rawData);

int totalPixels = 0;

//if (foundUsers)  
//{  
// myPort.clear();

```
int row = 0;

//color toColor = -(int)random(255*255*255);
color thatColor = -(int)random(255*255*255);

```

img.loadPixels();  
for (int y = 0; y \< 424; y += matrixSizeHeight){  
int col = 0;

```
  for (int x = 20; x < 512; x += matrixSizeWidth) {
    color c = kinectImg.pixels[x + y*kinectImg.width];

    // print(c);

    if(c < -1)
    {
    //c = toColor;
   
    //img.pixels[x + (y)*kinectImg.width] = thatColor;
    
    }
    else{
    c = thatColor;
    //img.pixels[x + (y)*kinectImg.width] = 255;
    }

    

   // print(c);

    fill(c);
    stroke(0);
    strokeWeight(1);
    rect(x, y, matrixSizeWidth, matrixSizeHeight);

    //if (totalPixels < 105)
    //{
      if (c != -1)
      {
        //print(1); 
       // myPort.write("H");
        totalPixels++;
        //myPort.write(totalPixels);
      }
      else
      {
        //print(0);
       // myPort.write("L");
      }
    //}

    col++;
  }

  row++;
}

```

img.updatePixels();  
// myPort.write(“C”);

image(kinect.getDepthImage(), 0,0,1920,1080);  
fill(0);  
textSize(14);  
text(kinect.getNumOfUsers(), 10, 30);  
text("Found User: "+foundUsers, 10, 50);  
text(frameRate, 10, 70);  
text("Total Pixels: " + totalPixels, 10, 90);  
}
