WebCam pixel brightness doesn't update regularly

edited December 2015 in Library Questions

Hi awesome Processing community! Thank you so much for your help already. I kept it brief, but added extra information below in case you're interested :)

MY PROBLEM (if in a hurry, only read this) :

download link to the processing sketch: sehhoer.zip

The brightnesses measured by the "distancer" class updates only about every 10th to every 50th frame, although the sketch runs at 30 fps, and the video picture updates normally. Please turn down the volume a bit if you run the sketch, all the sine-waves generated sound awful at the moment.

download link to the processing sketch: sehhoer.zip

the problem seems to appear in the "distancer" class.

I think this part of the code should cause the problem:

` void update() { loadPixels(); video.loadPixels();

  if (video.available()) {
  for (int x = 0; x < video.width; x +=10 ) {
    for (int y = 0; y < video.height; y +=10 ) {

      int loc = x + y*video.width;            
      color current = video.pixels[loc];      
      distances[x][y] = 255-brightness(current);  

    }
  }
}

println("brightness of a random point: "+ distances[10][10]); ` it doesn't really do anything but scrolling through the image provided by the video stream, and saving the brightness in the distances array.

ABOUT MY PROJECT (skip from here if not interested) : I'm working on an application to let blind people sense a 3D "image" of their surrounding by hearing. The idea is to translate every point in space into a tune, and all the tunes add up to a soundscape representing the space. The X position is set simply by stereo hearing (pan), the Y position by pitch. the distance is recognized by volume. So for example a close object on the bottom left side will be heard as a loud, deep sound on the left, and so on. As I don't have a kinect camera yet, I'm using the normal webcam, and assign brightness to distance. In a dark room, with the laptop screen as the only light source, this kind of works. (objects closer to the screen appear brighter.)

ANY IDEAS ON THESE LESS CONCRETE PROBLEM? there is a problem with the left/right hearing. Two objects, one on the left, one on the right, will create the same sound as one closer object in the middle. I plan to add a "blurring" effect to the sounds at the boarders of the "view", to improve the distinction on the x-axis. But the effects provided by the minim library only cancel out or amplify certain frequencies. this doesn't work for me, because every sound itself is just a single frequency for itself.. Another problem is that the sine-waves interfere or something when layering so many of them, so the sound gets really messed up (as you can hear). Is there a smart way to implement actual instruments (I'm thinking of some midi-like instrument playing?). Do you think that would solve the messed up sound?

Thank you guys again, hope someone will help me. Keep up the amazing work,

Martin

download link to the processing sketch: sehhoer.zip

Sign In or Register to comment.