I wrote a program which work but without using self and now i try to rewrite it with "self". I put some self pretty much everywhere but i have a problem of given argument. First i create a class:
class photo():
def _init_cam(self,x,y):
self.camera = PiCamera()
self.camera.resolution = (x,y)
self.camera.start_preview()
sleep(2)
print("camera init")
return self.camera
The method which give me problems :
def capture_image(self):
global wait # Empeche le if de ce déclencher avant la fin de la fonction
wait = False
# Get the current date as the timestamp to generate unique file names.
self.date = datetime.datetime.now().strftime('%m-%d-%Y_%H.%M.%S')
# Add date as timestamp on the generated files.
#camera.annotate_text = date
# Capture an image as the thumbnail.
self.camera.capture('/home/pi/Pictures/' + self.date + '.jpg')
print("\r\nImage Captured! \r\n")
wait = True
In my main I create my object :
camera =photo()
camera._init_cam(3280,2464)
Then I call my method :
GPIO.add_event_detect(23,GPIO.FALLING,callback = camera.capture_image, bouncetime = 300)
The error : TypeError: capture_image() takes 1 positional argument but 2 were given
I have no idea why it gives a second argument and if there is any way to see what is this argument.
Thanks.