-2

I want to implement a java application, There is a login form and when user login failed then capture the user's image using default webcam and store it in a folder.

How can develop it?

I found some reference related to this topic.

James Z
  • 12,209
  • 10
  • 24
  • 44
Chauhan Ajay
  • 86
  • 1
  • 2
  • 14
  • Can we know what have you tried about the problem? –  Oct 07 '18 at 06:52
  • Thank you so much, finally I made it :) using this reference https://stackoverflow.com/questions/276292/capturing-image-from-webcam-in-java – Chauhan Ajay Oct 07 '18 at 07:48

1 Answers1

1

Link to the project is https://github.com/sarxos/webcam-capture

More Refence - Capturing image from webcam in java?

YouTube Tutorial: https://www.youtube.com/watch?v=2BHyL_XK8YQ

Example code (take picture and save in test.jpg):

import com.github.sarxos.webcam.Webcam;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.imageio.ImageIO;
import javax.swing.JOptionPane;


   //Use try-catch block in the main method OR in any method & call that method in the main method
   try {
        // TODO add your handling code here:

        //infoBox("Hello", "Beta");
        Webcam webcam = Webcam.getDefault();
        webcam.open();
        BufferedImage image = webcam.getImage();
        ImageIO.write(image, "JPG", new File("test.jpg"));
    } catch (IOException ex) {
        Logger.getLogger(LoginPage.class.getName()).log(Level.SEVERE, null, ex);
    }
Chauhan Ajay
  • 86
  • 1
  • 2
  • 14