capture an image

how can capture a single image from a USB connected cam, mine is Logitech. I tried to work with the movieGrabber example but I’m not getting any images, all what i get is white squares instead.
The cam is turned on as I build the project, but I dont get any results.
I’m getting this:

***** VIDEOINPUT LIBRARY - 0.1995 - TFW07 *****

OF: OF_LOG_WARNING: ofBaseVideoGrabber::setPixelFormat not implemented
SETUP: Setting up device 0
SETUP: QuickCam Pro for Notebooks
SETUP: Couldn’t find preview pin using SmartTee
SETUP: Default Format is set to 640 by 480
SETUP: trying format RGB24 @ 640 by 480
SETUP: Capture callback set
SETUP: Device is setup and ready to capture.

SETUP: Disconnecting device 0
SETUP: freeing Grabber Callback
SETUP: freeing Grabber
SETUP: freeing Control
SETUP: freeing Media Type
SETUP: removing filter NullRenderer…
SETUP: filter removed NullRenderer
SETUP: removing filter Sample Grabber…
SETUP: filter removed Sample Grabber
SETUP: removing filter Smart Tee…
SETUP: filter removed Smart Tee
SETUP: removing filter QuickCam Pro for Notebooks…
SETUP: filter removed QuickCam Pro for Notebooks
SETUP: freeing Capture Graph
SETUP: freeing Main Graph
SETUP: Device 0 disconnected and freed

THANKS

Hi

It looks like the camera is actually working.

SETUP: Device is setup and ready to capture.

But with the information you provided it’s hard to tell what’s wrong…

When does this message appear? Does this message appear right after you close the program?

SETUP: Disconnecting device 0

Did you try the original code from the movieGrabber example or did you change something? If so, maybe you want to post some of your code. And what operating system are you on and what camera are you using? (I guess it’s a Quick Cam Pro)

lg.ph

Hi underdoeg, thanks for replying

whatever i posted earlier is what I got when running the moviegrabber example. The first part up to the line:

“SETUP: Device is setup and ready to capture.”

I get when I run the code, with an image with a background from ( ofBackground(100,100,100):wink: and two white rectangles of width=camWidth and height=camHeight which I believe are supposed to be the video and the “videoInverted”.

the rest of the output is what I get when closing the image.

I’m using visual studio 2010 on windows 7, and I’m using a 2MP Autofocus Logitech USB cam

thanks :slight_smile:

void testApp::draw()
{
ofSetHexColor(0xffffff); // this is the white color
vidGrabber.draw(20,20); // this is the first rectangle
videoTexture.draw(20+camWidth,20,camWidth,camHeight); // this is the second rectangle right next to the first one
}

where is the video exactly ?! is the vidGrabber supposed to be a captured image?

where is the video exactly ?! is the vidGrabber supposed to be a captured image?

Basically what you do when you capture video is to instantiate an ofVideoGrabber. Then in setup you call videoGrabber.init(videoSizeX, videoSizeY), then in update: videoGrabber.update() and in draw: videoGrabber.draw(0,0,videoSizeX, videoSizeY);

What the video grabber does, is updating an internal image with the one from the camera whenever you call videoGrabber.update()

hi underdoeg,

i think my graphics card is compatible with up to openGL1.4, and the v007 is using a newer version. anyways i moved to v064 framework and its working fine.

I’m trying to learn how to get a single image from a web cam, this is my code:

  
void testApp::setup(){  
  
	  
	myvid.setDeviceID(0);  
	camHeight= 240; //myvid.height;  
	camWidth= 320; //myvid.width;  
  
	myvid.setVerbose(true);  
	myvid.initGrabber(camWidth,camHeight);  
	  
}  
  
//--------------------------------------------------------------  
void testApp::update(){  
  
	  
	myvid.grabFrame();  
  
	vpixels= myvid.getPixels();  
	testimg.grabScreen(20,20,camWidth,camHeight);  
	testimg.setImageType(OF_IMAGE_COLOR);  
	testimgpix= testimg.getPixels();  
  
	  
	testimg.saveImage("testimg.jpg");  
}  
  
//--------------------------------------------------------------  
void testApp::draw(){  
	  
  
	myvid.draw(20,20);  
	  
	  
}  

  1. is there another way to get an image from a webcam other than (grabscreen()) from a video,
  2. how can i get 1 single image only, in my code the image is saved almost every frame, i tried to use a key in presskey function to use (close()) but its not working.
  3. how is close() function is used and where?

thanks