I am on a Raspberry Pi, and I am using a program called fswebcam
, which allows you to take pictures with a webcam.
~$ fswebcam image.jpg
That command if entered in terminal takes a picture and saves it to your computer, however I want to build a simple python program that can access the terminal and execute that same command as I have listed above.
I have tried to import os
and use os.system('fswebcam image.jpg')
But it isn't working for me.
How can I have python execute terminal commands?
Use the subprocess module:
import subprocess subprocess.Popen(["fswebcam", "image.jpg"])
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With