Is there a way to programmatically extract still pictures from the
Apple iSight Firewire camera using the Java programming language on
the Mac OS X platform (more specifically PowerBook G4)? If so, how?
Sample Code?
Is it possible for you to share the compiled Java classes with me and
I can test it with my iSight camera before I mark this question as
answered?
My objective is to incorporate the Java code into a larger specialized
system so I will definitely need the source code.
If the compiled Java classes work for me, then I can answer this
question as answered and then you can give me the actual Java source
files.
Is that acceptable?
Sorry I didn't get a chance to get back to you sooner. Yes, the code
worked. There is a configuration window that pops up to let me change
the settings of the camera.
Have you any idea which line of code controls that functionality so I
can optionally display this configuration window? If not, I suppose
my question is answered.
I have another question about capturing sound from an iSight camera.
Not sure if that was convered on the website you referenced.
Thanks,
Eric
Hi Eric,
I found sample code and compiled the Java code.
I ran into a problem.
Problem: No iSight Camera to test code against.
I would like to know if you want the sample code and
if that qualifies as an answer to your question.
Yes, there certainly seems to be a way to extract still pictures from
iSight using Java.
Although which version of Java and OS X you're using might be an issue.
Which version of Java and OS X will you be using this Java program?
Thanks
-googleexpert
Hi GoogleExpert,
My operating system is: 10.3.5
My version of java is 1.4.2
java version "1.4.2_05"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_05-141)
Java HotSpot(TM) Client VM (build 1.4.2-38, mixed mode)
Hope this helps,
Eric
Hi,
Thanks for getting back to me and for informing me of the working code.
About your popup configuration window, I believe commenting or taking
out the following line will not display a popup window:
/**** function for iSight Popup window
channel.settingsDialog();
****/
Reference:
http://developer.apple.com/documentation/Java/Reference/1.4.1/Java141API_QTJ/quicktime/std/sg/SGChannel.html#settingsDialog()
Now, about capturing sound with Java, here's what I found(source code included):
Capturing Audio with Java Sound API:
http://java.sun.com/developer/JDCTechTips/2002/tt0319.html#tip1
Java Sound, Getting Started, Part 2, Capture Using Specified Mixer:
http://www.developer.com/java/other/article.php/1579071
Java Sound Resources: Examples: Audio Playback and Recording:
http://www.jsresources.org/examples/audio_playing_recording.html
I hope that helps you.
If you have anymore questions, please don't hesitate to ask me.
Thanks again.
-googleexpert
Hi ericb01,
I would like to know if the java sources worked for you.
Please let me know if you need any help.
Thanks.
-googleexpert
Here's what I found.
First, copy and unzip /System/Library/Java/Extensions/QTJava.zip to your
testing directory to bypass any classpath issues.
Source code for the VideoCapture class
-----------
import java.awt.Image;
import java.awt.image.BufferedImage;
import java.awt.image.DataBuffer;
import java.awt.image.WritableRaster;
import quicktime.QTRuntimeException;
import quicktime.QTRuntimeHandler;
import quicktime.QTSession;
import quicktime.qd.PixMap;
import quicktime.qd.QDConstants;
import quicktime.qd.QDGraphics;
import quicktime.qd.QDRect;
import quicktime.std.StdQTConstants;
import quicktime.std.sg.SequenceGrabber;
import quicktime.std.sg.SGVideoChannel;
import quicktime.util.RawEncodedImage;
public class VideoCapture {
private SequenceGrabber grabber;
private SGVideoChannel channel;
private RawEncodedImage rowEncodedImage;
private int width;
private int height;
private int videoWidth;
private int pixels;
private BufferedImage image;
private WritableRaster raster;
public VideoCapture(int width, int height) throws Exception {
this.width = width;
this.height = height;
try {
QTSession.open();
QDRect bounds = new QDRect(width, height);
QDGraphics graphics = new QDGraphics(bounds);
grabber = new SequenceGrabber();
grabber.setGWorld(graphics, null);
channel = new SGVideoChannel(grabber);
channel.setBounds(bounds);
channel.setUsage(StdQTConstants.seqGrabPreview);
channel.settingsDialog();
grabber.prepare(true, false);
grabber.startPreview();
PixMap pixMap = graphics.getPixMap();
rowEncodedImage = pixMap.getPixelData();
videoWidth = width + (rowEncodedImage.getRowBytes() - width * 4) / 4;
pixels = new int[videoWidth * height];
image = new BufferedImage(
videoWidth, height, BufferedImage.TYPE_INT_RGB);
raster = WritableRaster.createPackedRaster(DataBuffer.TYPE_INT,
videoWidth, height,
new int { 0x00ff0000, 0x0000ff00, 0x000000ff }, null);
raster.setDataElements(0, 0, videoWidth, height, pixels);
image.setData(raster);
QTRuntimeException.registerHandler(new QTRuntimeHandler() {
public void exceptionOccurred(
QTRuntimeException e, Object eGenerator,
String methodNameIfKnown, boolean unrecoverableFlag) {
System.out.println("what should i do?");
}
});
} catch (Exception e) {
QTSession.close();
throw e;
}
}
public void dispose() {
try {
grabber.stop();
grabber.release();
grabber.disposeChannel(channel);
image.flush();
} catch (Exception e) {
e.printStackTrace();
} finally {
QTSession.close();
}
}
public int getWidth() {
return width;
}
public int getHeight() {
return height;
}
public int getVideoWidth() {
return videoWidth;
}
public int getVideoHeight() {
return height;
}
public void getNextPixels(int pixels) throws Exception {
grabber.idle();
rowEncodedImage.copyToArray(0, pixels, 0, pixels.length);
}
public Image getNextImage() throws Exception {
grabber.idle();
rowEncodedImage.copyToArray(0, pixels, 0, pixels.length);
raster.setDataElements(0, 0, videoWidth, height, pixels);
image.setData(raster);
return image;
}
}
URL: http://gogo.tea-nifty.com/interpot/java/
:
I also found pages that merely serve as possible reference guides:
http://rsb.info.nih.gov/ij/plugins/qt-capture.html
Note: had trouble compiling, probably needed the entire ImageJ package.
http://www.oreillynet.com/pub/wlg/2933
http://www.oreillynet.com/cs/user/view/cs_msg/40741
http://www.onjava.com/lpt/a/4318
http://lists.apple.com/archives/quicktime-java/2003/Dec/15/howtocropanimagecaptured.txt
Login/ archives/archives
Please let me know if you have any problems compiling.
-googleexpert MacCast - For Mac Geeks, by Mac Geeks on ZENcast.com:: Extracting embedded images from Word. Review of Mac Speech Dictate. Written using the latest Apple technology for Mac OS X, Merlins rich feature http://www.zencast.com/channels/showchannel.asp?cid=3235HOME | AlphaJunkie::: Tods software is written in Java and is currently Mac only. still no ban on snakes: Via Gizmodo: Mac OS X Driver for XBox 360 Controller: http://www.alphajunkie.com/2006/05/HOME |
I am doing a final year project and was interested by this technique
of image capture and was wondering if you have had any luck getting it
to work?
I am trying to capture images from iSight convert to binary image then
input the data to an Multi-Layer Perceptron for anaysis and hopefully
it will return a output comparible to the input image. e.g. a picture
of an apple is shown to iSight and the MLP will look at the shape and
say its an apple.
If you managed to capute images from iSight i would be graful if you
could let me know how you did it and if you have any source that would
help me considerably.
Thanks,
Tom Bates
[search strategy]
"import java" isight
Why doesn't the "C" key work on this java calculator?
pages not working in netscape
|