Best way to access web camera in Java

前端 未结 2 1374
南方客
南方客 2020-12-04 08:21

I need to access web camera using Java. This is what I want to do

  1. Access web cam

  2. Now the user can see web cam working because his face is v

相关标签:
2条回答
  • 2020-12-04 09:05

    I think the project you are looking for is: https://github.com/sarxos/webcam-capture (I'm the author)

    There is an example working exactly as you've described - after it's run, the window appear where, after you press "Start" button, you can see live image from webcam device and save it to file after you click on "Snapshot" (source code available, please note that FPS counter in the corner can be disabled):

    snapshot

    The project is portable (WinXP, Win7, Win8, Linux, Mac, Raspberry Pi) and does not require any additional software to be installed on the PC.

    API is really nice and easy to learn. Example how to capture single image and save it to PNG file:

    Webcam webcam = Webcam.getDefault();
    webcam.open();
    ImageIO.write(webcam.getImage(), "PNG", new File("test.png"));
    
    0 讨论(0)
  • 2020-12-04 09:12

    This has been discussed on SO multiple times. Here are a few links to get you started:

    SO: Capturing image from webcam in java?

    SO: What is the best method to capture images from a live video device for use by a Java-based application?

    openCVF applet: http://www.colorfulwolf.com/blog/2011/07/05/accessing-the-webcam-from-inside-a-java-applet/

    config: http://ganeshtiwaridotcomdotnp.blogspot.in/2011/12/opencv-javacv-eclipse-project.html

    0 讨论(0)
提交回复
热议问题