1
A particular programmer is doing a project where the standard webcam takes photos every 1 second using Javacv.
For now ,in this code, at the click of the capture button it captures a photo and saves in the program folder. It is asked that the program save the photos in a certain folder selected by the user and that the webcam capture photos every 1 second.
import com.googlecode.javacv.CanvasFrame;
import com.googlecode.javacv.OpenCVFrameGrabber;
import com.googlecode.javacv.cpp.opencv_core.IplImage;
import com.googlecode.javacv.cpp.opencv_highgui;
import com.googlecode.javacv.cpp.opencv_highgui.CvCapture;
import static com.googlecode.javacv.cpp.opencv_highgui.cvSaveImage;
import java.awt.event.KeyEvent;
import javax.swing.JOptionPane;
OpenCVFrameGrabber grabber = new OpenCVFrameGrabber(0);
JOptionPane.showMessageDialog(null, "Aperte a tecla P para parar a gravação");
while(KeyEvent.VK_P){
try{
grabber.start();
IplImage img = grabber.grab();
if(img!=null){
cvSaveImage("image1.jpg", img);
}
}
catch(Exception e){
e.printStackTrace();
}
setFocusable(true);
setVisible(true);
}