Skip to content

Instantly share code, notes, and snippets.

@bavensky
Created May 27, 2019 09:49
Show Gist options
  • Save bavensky/f17197f65a1a232ee18d710f6937ac52 to your computer and use it in GitHub Desktop.
Save bavensky/f17197f65a1a232ee18d710f6937ac52 to your computer and use it in GitHub Desktop.
RPI USB Camera
import os
import RPi.GPIO as GPIO
import time
import threading
count = 1
def worker():
print('Worker')
os.system('display test%s.jpg &' %count)
GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False)
button = 18
led = 23
GPIO.setup(button, GPIO.IN, pull_up_down=GPIO.PUD_UP)
GPIO.output(led, 0)
time.sleep(3)
print("Ready!")
while True :
buttonState = GPIO.input(button)
if buttonState == False :
time.sleep(0.2)
print("Capture!")
os.system('fswebcam -p YUYV /home/pi/Pictures/buttonForImage/test%s.jpg' %c$
os.system('killall -9 display')
t = threading.Thread(target=worker)
t.start()
time.sleep(1)
count += 1   
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment