java - Java net-beans - 如果用户登录失败,则使用网络摄像头捕获图像
解决方案
该项目的链接是https://github.com/sarxos/webcam-capture
更多参考 -在 java 中从网络摄像头捕获图像?
YouTube 教程:https ://www.youtube.com/watch?v=2BHyL_XK8YQ
示例代码(拍照并保存在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);
}
推荐阅读
- java - 如何在用 Java 编写的多模块播放项目中运行单元测试
- java - Monitoring replicas with Spring Boot Admin on Kubernetes
- java - 高性能的java中的Json转换
- c++ - 读取访问冲突当前为 0xCDCDCDCD,链接列表窗口
- python - 异常处理不适用于开放 python
- android - 缺少android模拟器上的大多数文本
- mysql - MySQL查询中的未知“喜欢”
- javascript - 使用 Vuetify Datatable 对服务器端数据进行排序
- python - 如何调整机器学习模型的img大小
- java - 如何在本地机器上以 IAM 角色运行 docker Image?