Run Bash from Java Program to Capture Webcam Image on Raspberry Pi -
on raspberry pi, can capture , save images logitech pro 9000 usb webcam lxterminal following bash line:
fswebcam -d /dev/video0 /home/pi/image.jpg
i want write java program runs bash line above because simplest way capture , save image. far, have:
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"); } }
it's not working. no error messages. please help!
first, need install fswebcam....
sudo apt-get install fswebcam
then, in java program, need run following:
runtime.getruntime().exec("fswebcam -d /dev/video0 /home/username/desktop/test.jpg");
worked me, you! =)
i had same problem @ first, way.. =)
luck!
Comments
Post a Comment