1.今天看公司在调用人脸识别接口,需要对接摄像头接口,于是处于好奇,百度了一下,java 代码调用本地相机的摄像头
调用摄像头需要两个jar,添加pom文件
<!-- https://mvnrepository.com/artifact/org.slf4j/slf4j-api --> <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-api</artifactId> <version>1.7.25</version> </dependency> <!-- https://mvnrepository.com/artifact/com.github.sarxos/webcam-capture --> <dependency> <groupId>com.github.sarxos</groupId> <artifactId>webcam-capture</artifactId> <version>0.3.12</version> </dependency>
调用摄像头代码
import com.github.sarxos.webcam.Webcam; import com.github.sarxos.webcam.WebcamPanel; import com.github.sarxos.webcam.WebcamResolution; import com.github.sarxos.webcam.WebcamUtils; import com.github.sarxos.webcam.util.ImageUtils; import javax.swing.*; import ja