文件名称:java编写的可以打开摄像头程序及说明
文件大小:117KB
文件格式:DOC
更新时间:2016-05-18 02:33:33
java编摄像头
部分代码 public class TextWindow extends JFrame { static TextWindow frame ; private JPanel contentPane,p3,p4; private JPanel panel ; public CaptureDeviceInfo device2; public Player player2; Component comV, comVC, comA; public static Player player = null; private CaptureDeviceInfo device = null; private MediaLocator locator = null; static String str1 = "vfw:Logitech USB Video Camera:0"; static String str = " vfw:Microsoft WDM Image Capture (Win32):0"; static String aa="JavaSound audio capture";//音频 static String bb="DirectSoundCapture"; /** * Launch the application. */ public static void main(String[] args) { EventQueue.invokeLater(new Runnable() { public void run() { try { frame = new TextWindow(); frame.setVisible(true); frame.speaker(); frame.jbInit(); } catch (Exception e) { e.printStackTrace(); } } }); } private void speaker() throws Exception { p3=new JPanel(); p3.setLayout(new BorderLayout(0, 0)); Vector deviceList = CaptureDeviceManager.getDeviceList(new AudioFormat(AudioFormat.LINEAR, 44100, 16, 2)); if (deviceList.size() > 0) { device2 = (CaptureDeviceInfo) deviceList.firstElement(); } else { System.out.println("找不到音频设备!"); } try { player2 = Manager.createRealizedPlayer(device2.getLocator()); player2.start();