How to show a webcam image in just part of a window?

edited November 2013 in How To...

I know how to show a webcam feed so that it fills up my entire window, but I want to be able to put other stuff in my window as well. Here is the code that I have:

void drawCamera()

{

  int[] img = m.image(); //get the normal image of the camera

  loadPixels();

  for(int i=0;i<width*height;i++){ //loop through all the pixels

    pixels[i] = img[i]; //draw each pixel to the screen

  }

  updatePixels();

}

I tried changing the "width * height" to "320 * 240" and then set my sketches width, height to 800,800. As expected, this gave me a distorted image that was scrunched up at the top of my window. I also tried leaving the width the same as my webcam capture and just increased the height, and this worked, but I would really like to have some space in my window beside the webcam feed as well if possible. Thanks!

EDIT: sorry about the weird formatting of the code, i messed around with it some but couldn't get it to look nice..

EDIT 2: Got the formatting right now, thanks GOTOLOOP!

Tagged:

Answers

  • Highlight code, then hit CTRL+K. Make sure to break a line before and after the code! <:-P

  • edited November 2013

    have you tried image(camera,0,0,camera.width/4,camera.height/4); :ar! :ar! :ar!

    Create four images/windows with this for each set x,y position as well as width & height.

Sign In or Register to comment.