opencv_webcam1.java
import org.opencv.core.Core;
import org.opencv.core.Mat;
import org.opencv.imgcodecs.Imgcodecs;
import org.opencv.videoio.VideoCapture;
public class Opencv_webcam1{
static {
System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
}
public static void main(String[] args) {
VideoCapture camera = new VideoCapture();
camera.open(0);
if(!camera.isOpened()) {
System.out.println("Camera not open");
}else {
Mat frame = new Mat();
try {
System.out.println("Use webcam rhythm");
camera.read(frame);
Imgcodecs.imwrite("D:\\projects\\Java\\OpenCV_Samples\\resource\\imgs\\frame.jpg ",frame);
System.out.println("Completion of clapping");
}catch (Exception e) {
e.printStackTrace();
}
camera.release();
}
}
}
Recommended Posts