we are struggling with getting control over a webcam in java on a raspberry. we try many ways and the one which seems to be the best is to use SarXos Webcam Capture API. So we add this to the project:
then we try a test (the following code) but it send an error message. Please we need your help :)
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;
import com.github.sarxos.webcam.Webcam;
/**
* Example of how to take single picture.
*
* @author Bartosz Firyn (SarXos)
*/
public class webcam {
public static void main(String[] args) throws IOException {
// get default webcam and open it
Webcam webcam1 = Webcam.getDefault();
webcam1.open();
// get image
BufferedImage image = webcam1.getImage();
// save image to PNG file
ImageIO.write(image, "PNG", new File("test.png"));
}
}
our error:
Exception in thread "main" java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory
at com.github.sarxos.webcam.Webcam.<clinit>(Webcam.java:101)
at webcam.main(webcam.java:21)
Caused by: java.lang.ClassNotFoundException: org.slf4j.LoggerFactory
at java.net.URLClassLoader$1.run(URLClassLoader.java:359)
at java.net.URLClassLoader$1.run(URLClassLoader.java:348)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:347)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:312)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
... 2 more
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.