Results 1 to 1 of 1
Thread: java project
- 01-16-2012, 08:27 AM #1
Member
- Join Date
- Jan 2012
- Posts
- 1
- Rep Power
- 0
java project
i am having my java project on eye blinking software in which eye blinks are traced in order to work as a mouse. so i need to make use of JMF to connect my webcam to the program. So could anyone please help me to configure this JMF thing...thanks in advance...
the code for device finder is along given....
import javax.media.*;
import javax.media.protocol.*;
import javax.media.control.FormatControl;
import javax.media.format.VideoFormat;
import java.awt.*;
import java.util.Vector;
import javax.swing.JOptionPane;
/*
This class opens a video capture device and reads frames in the given format.
*/
public class DevicesFinder implements BufferTransferHandler
{
public DevicesFinder(){}
public PushBufferDataSource findDevices(Frame frame)
{
PushBufferDataSource pbds = null;
// Preferred capture format parameters
String prefEncoding = "RGB";
float prefFPS = 30.0f;
Dimension prefSize = new Dimension(320, 240);
VideoFormat prefFormat = new VideoFormat(prefEncoding,prefSize,Format.NOT_SPECI FIED,null,prefFPS);
Vector devices = CaptureDeviceManager.getDeviceList(prefFormat);
if (devices.size() < 1)
{
JOptionPane.showMessageDialog(frame,
"No capture devices found, or devices does not support given format\n" +
prefFormat.toString(), null,
JOptionPane.ERROR_MESSAGE);
System.exit(-1);
}
CaptureDeviceInfo cdi = (CaptureDeviceInfo)devices.elementAt(0);
frame.cdi = cdi;
try
{
DataSource ds = Manager.createDataSource(cdi.getLocator());
if (ds instanceof CaptureDevice)
{
FormatControl[] fcs = ( (CaptureDevice) ds).getFormatControls();
for (int i = 0; i < cdi.getFormats().length; i++)
{
VideoFormat vf = (VideoFormat) cdi.getFormats()[i];
if (vf.matches(prefFormat))
{
prefFormat = (VideoFormat) vf.intersects(prefFormat);
fcs[0].setFormat(prefFormat);
break;
}
}
}
ds.connect();
pbds = (PushBufferDataSource) ds;
pbds.getStreams()[0].setTransferHandler(this);
pbds.start();
return pbds;
}
catch (Exception e)
{
JOptionPane.showMessageDialog(frame,"Could not connect to capture device, please check your webcam",null,JOptionPane.ERROR_MESSAGE);
System.exit(-1);
return null;
}
}
public void transferData(PushBufferStream pbs) {
}
}
Similar Threads
-
Creating a project in eclipse from existing project
By Suraiya in forum New To JavaReplies: 1Last Post: 10-08-2011, 09:14 AM -
Java Project
By larry_d1990 in forum New To JavaReplies: 2Last Post: 02-21-2011, 07:22 PM -
need help with java project
By doxycycline in forum New To JavaReplies: 11Last Post: 02-07-2011, 04:05 PM -
how to get the project in java.....
By thirumurugan.sethu in forum New To JavaReplies: 2Last Post: 10-07-2008, 07:37 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks