title: 16u Channel to 8u Channel for OpenCV Blob tracking
body: <p>Can anyone tell my why this doesnt work?</p>
  
  <pre><code>void CVBlobTrack::updateKinect(ImageSourceRef kdepth, ImageSourceRef kcolor) {
  cv::Mat input;
  cv::Mat output;
  
  channel16 = Channel16u(kdepth);
  
  
  
  // Conversion from 16 bit int to 8 bit int for blob track
  
  //uint16_t *largeImage = (uint16_t *)channel16.getData();
  //uint8_t *smallImage = (uint8_t *)channel8.getData();
  
  for (int y = 0; y &lt; 480; y++)
  {
      for (int x = 0; x &lt; 640; x++)
      {
          uint8_t c = floor(float(channel16.getValue(Vec2i(x,y))) / 65545.0f * 255.0f );                         
  
          // This needs to change as its slooooooooooow
          channel8.setValue(Vec2i(x,y), c);
  
      }
  }
  
  
  writeImage("test", channel8, "png");
  
  cvSetData(mKinectDepthImage8, channel8.getData(), mKinectDepthImage8-&gt;widthStep);
  </code></pre>
  
  <p>Writing the image out to disk works fine. Trying to use the channel as data OR AS A CINDER GL_TEXTURE does NOT work. Simply put, the values are being written into the channel (i believe) and yet for whatever reason, only 1 contour is found when i blob track and the texture comes out totally black.</p>
  
  <p>I've tried bit shifting and also printing out the values as opposed to converting to float and many other methods and it always results in a black texture on the screen and only 1 contour found. </p>
  
  <pre><code>void CVBlobTrack::draw() {
  if(channel8) {
      gl::Texture ttex = gl::Texture(channel8);
      glEnable(GL_TEXTURE_2D);
      ttex.bind();
      glBegin(GL_QUADS);
      gl::color(Color::white());
  
      glTexCoord2f(0.0f, 0.0f);
      glVertex3f(0.0f, 0.0f,0.0f);
  
      glTexCoord2f(1.0f, 0.0f);
      glVertex3f(640.0f, 0.0f,0.0f);
  
      glTexCoord2f(1.0f, 1.0f);
      glVertex3f(640.0f, 480.0f ,0.0f);
  
      glTexCoord2f(0.0f, 1.0f);
      glVertex3f(0.0f, 480.0f,0.0f);
      glEnd();
  
      ttex.unbind();
      glDisable(GL_TEXTURE_2D);
  }
  </code></pre>
  
  <p>}</p>