# getColor() for Kinect

**URL:** <https://discourse.processing.org/t/getcolor-for-kinect/39463>\
**Category:** Libraries\
**Created:** [October 27, 2022, 7:33pm UTC](https://discourse.processing.org/t/getcolor-for-kinect/39463 "2022-10-27T19:33:31Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![lorenlepton](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/lorenlepton/32/17273_2.png) [@lorenlepton](https://discourse.processing.org/u/lorenlepton)\
**Post date:** [October 27, 2022, 7:33pm UTC](https://discourse.processing.org/t/getcolor-for-kinect/39463/1 "2022-10-27T19:33:31Z")

</div>

howdy folks

so ive come back to coding after a long time. I used to do openFrameworks & other things for many moons, & have come to Processing due to wanting to cut out the huge IDE & in some ways, not use C++ 😉  
plus Processing has reached version 4, well done 👍

but im trying to convert some old Kinect code & would like a finger to gently point me in a good direction.  
ive been looking at examples, other code & the such & cant find much on what im looking for.  
but I decided to do another “simple” Kinect example I had done years ago.  
when you are in front of the camera, it turns some Xs around depending on the color of the camera. so light/brightness affects it, basically

here is my code from the old C++

```auto
void ofApp::draw(){
  kinect.draw(0, 0, 640, 480);
  for (int i = 0; i < kinect.getWidth(); i += 16) {
    for (int j = 0; j < kinect.getHeight(); j += 16) {
      ofColor color = kinect.getPixels().getColor(i, j);
      float brightness = color.getBrightness();
      ofPushMatrix();
      ofTranslate(i, j);
      ofRotateZDeg(ofMap(brightness, 0, 255, 0, 360));
      ofDrawLine(0 - 8, 0, 0 + 8, 0);
      ofDrawLine(0, 0 - 8, 0, 0 + 8);
      ofPopMatrix();
    }
  }
}

```

I am using the Open Kinect library.  
the part im having some trouble understanding or trying to find is this line:

```auto
ofColor color = kinect.getPixels().getColor(i, j);

```

everything else im cool with, it works to a point. but grabbing color with the `getColor(I, j);` is getting me hit against a wall & im somewhat lost now. so I figured its worth asking the crowd for help

this is my current Processing code & I got to a point & had to come away from it. so the line im trying to get is incomplete

```auto
void draw(){
  image(kinect.getVideoImage(), 0, 0);
  
  for (int i = 0; i < kinect.width; i += 16){
    for (int j = 0; j < kinect.height; j += 16){
      int col = kinect.getVideoImage().
      float bright = brightness(col);
      pushMatrix();
      translate(i, j);
      rotateZ(map(bright, 0, 255, 0, 360));
      line(0 - 8, 0, 0 + 8, 0);
      line(0, 0 - 8, 0, 0 + 8);
      popMatrix();
    }
  }
}

```

any help or direction to help me understand this change from openFrameworks code to Processing would be absolutely helpful

thanks

LL

---

<div class="post-metadata">

**Author:** ![th75](https://avatars.discourse-cdn.com/v4/letter/t/ebca7d/32.png) [@th75](https://discourse.processing.org/u/th75)\
**Post date:** [October 29, 2022, 9:54pm UTC](https://discourse.processing.org/t/getcolor-for-kinect/39463/2 "2022-10-29T21:54:47Z")

</div>

hi,

i guess it depends on the kinect library you use  
but if you get the image by `image(kinect.getVideoImage(), 0, 0);`  
then, you can read pixels from this image by:  
`color p=kinect.getVideoImage().pixels[i+j*kinect.width];`

( if you have performance issue may be consider to copy kinect.getVideoImage() to a PImage before the loop, i don’t know if getVideoImage trigger some work in the background )

---

<div class="post-metadata">

**Author:** ![lorenlepton](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/lorenlepton/32/17273_2.png) [@lorenlepton](https://discourse.processing.org/u/lorenlepton)\
**Post date:** [October 30, 2022, 12:40pm UTC](https://discourse.processing.org/t/getcolor-for-kinect/39463/3 "2022-10-30T12:40:15Z")

</div>

ok cool. good to know. ill give that a try & see how it goes 👍

I also forgot to put up what library, so thank you you pointing that out, I updated the post. its using the Open Kinect library
