I just tried runing the examples in PYTHON PICAMERA SETUP. The code of CAMERA PROGRAMMING: CAPTURE AN IMAGE worked well but I encountered a problem in the next example: CAMERA PROGRAMMING: CAPTURE WHEN ACTIVATED. The error message is as below:
Traceback (most recent call last):
File "/home/pi/my.py", line 6, in <module>
GPIO.setup(17, GPIO.IN, GPIO.PUD_UP) # new
RuntimeError: No access to /dev/mem. Try running as root!
I just copied the example code and believe there should be no code error.
anyone's help will be highly appreciated!
Code: Select all
import time
import picamera
import RPi.GPIO as GPIO # new
GPIO.setmode(GPIO.BCM) # new
GPIO.setup(17, GPIO.IN, GPIO.PUD_UP) # new
with picamera.PiCamera() as camera:
camera.start_preview()
GPIO.wait_for_edge(17, GPIO.FALLING) # new
camera.capture('/home/pi/Desktop/image.jpg')
camera.stop_preview()