How to Capture and Store Images From a Webcam in Java

Written by brad malloy
  • Share
  • Tweet
  • Share
  • Pin
  • Email
How to Capture and Store Images From a Webcam in Java
Capturing images from a webcam allows you to monitor the area around the webcam. (Jupiterimages/ Images)

"Capturing Images and Video in a Library," otherwise known as LTI-CIVIL, allows Java to capture images and video from a capture device such as a USB webcam or virtual screencast of a desktop. Finding and implementing CIVIL is essential to using a webcam through Java.

Skill level:


  1. 1

    Download and install the LTI-CIVIL package from its website. For Windows computers, use the latest "ZIP" archives. For Mac and Linux, use the latest "TAR.GZ" archives.

  2. 2

    Create a new stream by assigning "system.openCaptureDeviceStream(info.getDecideID());" to a variable. Within that stream, use the "set Observer(new CaptureObserver())" code to create an observer which will watch the stream. Within the code block you've created for the observer, make sure to add a "public void onNewImage(CaptureStream stream Source, Image image)" line to actually do the capturing. This will capture a basic image from the webcam. The resulting code will look like this:

    your Stream = system.openCaptureDeviceStream(info.getDeviceID());

    captureStream.setObserver(new CaptureObserver())
        public void onNewImage(CaptureStream stream Source, Image image)


  3. 3

    Invoke the start function of your stream by typing "streamName.start();" where stream Name is the variable that you created earlier.

Don't Miss


  • All types
  • Articles
  • Slideshows
  • Videos
  • Most relevant
  • Most popular
  • Most recent

No articles available

No slideshows available

No videos available

By using the site, you consent to the use of cookies. For more information, please see our Cookie policy.