New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Timing is not precise due to use of sleep
#3
Comments
Looks like the simplest way would be to use import threading
# Interval between tasks, in seconds.
interval = 5.0
def capture():
threading.Timer(interval, capture).start()
# Do stuff...
capture() Documentation here: https://docs.python.org/2/library/threading.html#timer-objects This might not be the most efficient/perfect way of doing it... it seems that |
It's more complicated than that, though... will need some thinking to make sure I'm not resetting all the camera settings over and over and also causing the image interval counter to be more annoying than it has to be. |
Much more complicated. I remember how much I hate multithreaded computing :D |
With the branch in #4, I got the following after a few hundred pictures last night:
Might need to to handle that exception (in any case). Not sure what caused it, though. |
Maybe waveform80/picamera#242 (comment) ?
|
See: http://stackoverflow.com/a/344292 But if threading is going to be a pretty annoying thing to deal with, maybe we go back to the old-fashioned |
Happened again, on 369/370. |
Trying removing the daemonization... might make ctrl-c stuff more difficult. |
Another test now, without the daemonization and |
Fixes #3: More precise intervalometer via threading.Timer.
For future searchers... why not calculate the time for the next picture BEFORE you start taking the first one. E.g.:
|
Something that's totally logical now, but wasn't when I was originally writing the code: If you want to calculate more-or-less precise timings (e.g. 1 picture every 1 second, or 1 picture every 10 seconds), and try to do so to make a specific frame rate, etc... then that's not going to happen if the logic goes:
...because
take_and_store_picture_with_picamera()
takes a non-zero amount of time.On the Pi Zero W, it actually takes .5s - 1s, and that significantly impacts the time delay in the timelapse.
So I'd like to find a way to more precisely hit the time interval defined in
config.yml
. Maybe set a timer and have it hit a capture on each interval? Is there a way to thread the actual picture taking in Python? I could whip it up more easily in Node.js or Go, but maybe there's an easy way to tackle this in Python too.The text was updated successfully, but these errors were encountered: