日期:2014-05-20  浏览次数:20712 次

JAVA 中 如何从USB摄像头获得视频输入(来者有分..不够再加..)
说说思路..有源码的帖出来看看..
有这方面的源码程序..共享一下..

联系EMAIL   :luck_529@163.com

------解决方案--------------------
我见过有人做过,
------解决方案--------------------
接分
------解决方案--------------------
没接触过,只能顶下
------解决方案--------------------
mask
------解决方案--------------------
UP
------解决方案--------------------
应该要调用windows中的一些函数吧。
------解决方案--------------------
用 JMF 估计可以。
------解决方案--------------------
//利用这三个类分别获取摄像头驱动,和获取摄像头内的图像流,获取到的图像流是一个Swing的Component组件类

public static Player player = null;
private CaptureDeviceInfo di = null;
private MediaLocator ml = null;

//文档中提供的驱动写法,为何这么写我也不知:)

String str1 = "vfw:Logitech USB Video Camera:0 ";
String str2 = "vfw:Microsoft WDM Image Capture (Win32):0 ";
di = CaptureDeviceManager.getDevice(str2);
ml = di.getLocator();
try
{
 player = Manager.createRealizedPlayer(ml);
 player.start();
 Component comp;
 if ((comp = player.getVisualComponent()) != null)
 {
  add(comp, BorderLayout.NORTH);
 }
}
catch (Exception e)
{
 e.printStackTrace();
}


下面是获取图像
private JButton capture;
private Buffer buf = null;
private BufferToImage btoi = null;
private ImagePanel imgpanel = null;
private Image img = null;
private ImagePanel imgpanel = null;

JComponent c = (JComponent) e.getSource();
if (c == capture)//如果按下的是拍照按钮
{
 FrameGrabbingControl fgc =(FrameGrabbingControl)  player.getControl( "javax.media.control.FrameGrabbingControl ");
 buf = fgc.grabFrame(); // 获取当前祯并存入Buffer类
 btoi = new BufferToImage((VideoFormat) buf.getFormat());
 img = btoi.createImage(buf); // show the image
 imgpanel.setImage(img);
}
------解决方案--------------------
upppppppppppppppppppppppppppppppppp
------解决方案--------------------
接分
------解决方案--------------------
up
------解决方案--------------------
mark!
------解决方案--------------------
学习学习
------解决方案--------------------
楼主有想法!有前途!
------解决方案--------------------
JMF可以的

package jmfsample;

import javax.media.*;
import javax.media.protocol.*;
import javax.media.control.*;
import javax.media.format.*;
import java.awt.*;
import com.sun.media.controls.VFlowLayout; // Lays components one below the other
import java.awt.event.*;
import java.util.*;

public class JVidCap extends Frame implements ItemListener, ActionListener {

// GUI components

Panel jPanel1 = new Panel();
Choice comboFileType = new Choice();
VFlowLayout verticalFlowLayout1 = new VFlowLayout();
Label jLabel1 = new Label();
Checkbox checkVideo = new Checkbox();