如何使用java-imac网络摄像头获取视频流

如何使用java-imac网络摄像头获取视频流,java,video-streaming,video-capture,jmf,Java,Video Streaming,Video Capture,Jmf,我正在尝试在imac上运行下面的代码。有人能指出应该是哪条线吗 vfw:MicrosoftWDM图像捕获Win32:0 视频流来自imac内置摄像头。CaptureDeviceManager.getDevice中应该包含什么参数 谢谢, PS1 我的jmf.jar位于Library/Java/Extensions中 PS2 我还添加了这行代码:Vector deviceList=CaptureDeviceManager.getDeviceListnew RGBFormat 但是恶魔主义者是空的

我正在尝试在imac上运行下面的代码。有人能指出应该是哪条线吗 vfw:MicrosoftWDM图像捕获Win32:0

视频流来自imac内置摄像头。CaptureDeviceManager.getDevice中应该包含什么参数

谢谢, PS1 我的jmf.jar位于Library/Java/Extensions中

PS2 我还添加了这行代码:Vector deviceList=CaptureDeviceManager.getDeviceListnew RGBFormat

但是恶魔主义者是空的

谢谢你

参考:


我有一种不安的预感,JMF不支持OSX用于视频捕获。或者反之亦然。谷歌给了我一点信息——这似乎是JMF的开源延续——自2007年以来,JMF还没有开发过。它死了,吉姆。@BrianRoach这仍然是一个“可能有效”和“不起作用”的命题。@adhg使用QuickTime,就像大自然的意图一样。
public static void main(String[] args) throws Exception
{ 
    // Create capture device
    CaptureDeviceInfo deviceInfo = CaptureDeviceManager.getDevice("vfw:Microsoft WDM Image Capture (Win32):0");


    Player player = Manager.createRealizedPlayer(deviceInfo.getLocator());
    player.start();

    // Wait a few seconds for camera to initialise (otherwise img==null)
    Thread.sleep(2500);

    // Grab a frame from the capture device
    FrameGrabbingControl frameGrabber = (FrameGrabbingControl)player.getControl("javax.media.control.FrameGrabbingControl");
    Buffer buf = frameGrabber.grabFrame();

    // Convert frame to an buffered image so it can be processed and saved
    Image img = (new BufferToImage((VideoFormat)buf.getFormat()).createImage(buf));
    BufferedImage buffImg = new BufferedImage(img.getWidth(null), img.getHeight(null), BufferedImage.TYPE_INT_RGB);
    Graphics2D g = buffImg.createGraphics();
    g.drawImage(img, null, null);

    // Overlay curent time on image
    g.setColor(Color.RED);
    g.setFont(new Font("Verdana", Font.BOLD, 16));
    g.drawString((new Date()).toString(), 10, 25);

    // Save image to disk as PNG
    ImageIO.write(buffImg, "png", new File("/Users/Dror/Desktop/webcam.png"));

    // Stop using webcam
    player.close();
    player.deallocate();
    System.exit(0);
}