在我的 Raspberry Pi 上,我可以使用以下 bash 行从 LXTerminal 的 Logitech Pro 9000 USB 网络摄像头成功捕获和保存图像:
fswebcam -d /dev/video0 /home/pi/image.jpg
我想编写一个运行上述 bash 行的 java 程序,因为它是捕获和保存图像的最简单方法。到目前为止,我有:
import java.io.*;
public class GrabNSave {
public static void main(String[] args) throws IOException {
Runtime.getRuntime().exec("/bin/bash -c fswebcam -d /dev/video0 /home/pi/image.jpg");
}
}
它不工作。我没有收到错误消息。请帮忙!