We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpVideo Capture,  Movie Playback,  Vision Libraries › save a webcam image larger than the window size
Page Index Toggle Pages: 1
save a webcam image larger than the window size (Read 864 times)
save a webcam image larger than the window size
Feb 17th, 2008, 3:57pm
 
I'd like to save a jpg image from a high resolution camera.  I'm using JMyron to capture a video stream, but I'm unable to use a small window to capture a high resolution image.  If my camera is capable of 1728 x 1152 resolution (or higher), then how can I capture this resolution without using a window of size(1728,1152)?

For example:

import JMyron.*;
JMyron m;//a camera object

void setup(){
 size(160,120);//set window size lower than camera resolution (testing with Logitech Quickcam)
 
 m = new JMyron();//make a new instance of the object
 m.start(320,240);//start a capture at 320x240.  Used getForcedWidth() & getForcedHeight() to test max resolutions
}

void draw(){
 if ( mousePressed == false )
           {
 m.update();
 m.imageCopy(pixels);
 updatePixels();
 }
}

public void stop(){
 m.stop();//stop the object
 super.stop();
}

void mousePressed(){
 saveFrame("images/test.jpg");
}

thank you!
Re: save a webcam image larger than the window siz
Reply #1 - Feb 17th, 2008, 5:20pm
 
In your example, you are copying the pixels from the camera to the display window ("pixels") you should be able to do the same with a PImage object ("img.pixels"), then you can save the PImage to a file, i.e.

Code:

PImage img;

void setup() {
img = createImage(somewidth,someheight,RGB);
}

void draw() {
m.imageCopy(img.pixels);
}

void mousePressed() {
img.save("file.jpg");
}
Re: save a webcam image larger than the window siz
Reply #2 - Feb 18th, 2008, 5:05am
 
Hmmm.  I updated the code based on Dan's comments.  I'm able to save a higher resolution image, but the image and the window are both blank.  I'm guessing that I'm not passing the pixels properly (or at all), but I don't know how to do that.  

Here's my code.  What am I missing?


import JMyron.*;
JMyron m;//a camera object

PImage img;

void setup() {
 size(160,120);//set window size lower than camera resolution (testing with Logitech Quickcam)
 m = new JMyron();//make a new instance of the object
 m.start(320,240); //the max resolution of the quickcam
 img = createImage(320,240,RGB);
}  

void draw() {
 m.imageCopy(img.pixels);//the window is blank grey.  No image
}

void mousePressed() {
 img.save("file.jpg");//this image is black
}
Re: save a webcam image larger than the window siz
Reply #3 - Feb 18th, 2008, 5:07am
 
you also need img.updatePixels()

Re: save a webcam image larger than the window siz
Reply #4 - Feb 19th, 2008, 6:02am
 
I've made a few updates and can now save a higher resolution image than what the window size is.  However, the image displayed in the window is distorted. I think that the pixels being sent to the window match the higher resolution, so they overlap.  Any ideas on how to send the lower resolution image to the window?  I don't know what to do with the suggestion of using img.updatePixels().  Thanks for your help!


import JMyron.*;
JMyron m;//a camera object
 
PImage img;
 
void setup() {
 size(160,120);//set window size lower than camera resolution (testing with Logitech Quickcam)
 m = new JMyron();//make a new instance of the object
 m.start(320,240); //the max resolution of the quickcam
 img = createImage(320,240,RGB);
}  
 
void draw() {
 m.update();
 m.imageCopy(img.pixels);//the window displays a distorted image

 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();
}
 
void mousePressed() {
 img.save("file.jpg"); //this image is 320x240
}
Re: save a webcam image larger than the window siz
Reply #5 - Feb 23rd, 2008, 4:39am
 
I haven't been able to figure out how to do this, so any help would be appreciated.  In the meantime, I'm going over the tutorials so that I don't need to post so many questions to this forum.

thanks,
Steve
Page Index Toggle Pages: 1