I want to take a snapshot from a webcam through java. I followed this question and arrived at the this example. But there is a null pointer exception coming from the below line -
Buffer buf = frameGrabber.grabFrame();
Image img = (new BufferToImage((VideoFormat) buf.getFormat())
.createImage(buf));
buffImg = new BufferedImage(img.getWidth(this), img.getHeight(this),
BufferedImage.TYPE_INT_RGB);
Through the debugger I observed that the buffer doesn't actually contain data. So I went the creation of frameGrabber.
frameGrabber = (FrameGrabbingControl) player
.getControl("javax.media.control.FrameGrabbingControl");
Is there a problem with this code. Because JMFStudio works fine in my machine but the code cannot access it. Thank you.