Skip to content
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

Quick Time Lapse does not save last image #92

Closed
NelsonPJ opened this issue Mar 20, 2018 · 1 comment
Closed

Quick Time Lapse does not save last image #92

NelsonPJ opened this issue Mar 20, 2018 · 1 comment

Comments

@NelsonPJ
Copy link

When using the "quick time lapse" feature, the very last picture in the burst will not get a title written to it, and will get overwritten by the next motion capture.

Looking at the code, the function takeQuickTimeLapse is taking pictures with the "yield" function, and if the timer is exceeded, the loop is exited - but this happens before the post image processing.

def takeQuickTimeLapse(moPath, imagePrefix, NumOn, motionNumCount,
                       currentDayMode, NumPath):
    """ Take a quick timelapse sequence using yield if motion triggered """
    logging.info("motion Quick Time Lapse for %i sec every %i sec",
                 motionQuickTLTimer, motionQuickTLInterval)
    checkTimeLapseTimer = datetime.datetime.now()
    keepTakingImages = True
    filename = getImageName(moPath, imagePrefix, NumOn, motionNumCount)
    while keepTakingImages:
        yield filename
        rightNow = datetime.datetime.now()
        timelapseDiff = (rightNow - checkTimeLapseTimer).total_seconds()
        if timelapseDiff > motionQuickTLTimer:
            keepTakingImages = False
        else:
            motionNumCount = postImageProcessing(NumOn,
                                                 motionNumStart,
                                                 motionNumMax,
                                                 motionNumCount,
                                                 motionNumRecycle,
                                                 NumPath, filename,
                                                 currentDayMode)
            filename = getImageName(moPath, imagePrefix, NumOn, motionNumCount)
            time.sleep(motionQuickTLInterval)

Moving the "if" statement to the bottom fixes the issue

    while keepTakingImages:
        yield filename
        rightNow = datetime.datetime.now()
        timelapseDiff = (rightNow - checkTimeLapseTimer).total_seconds()
        #Peter moved the if statement below the processing so last image will be saved
        motionNumCount = postImageProcessing(NumOn,
                                             motionNumStart,
                                             motionNumMax,
                                             motionNumCount,
                                             motionNumRecycle,
                                             NumPath, filename,
                                             currentDayMode)
        filename = getImageName(moPath, imagePrefix, NumOn, motionNumCount)
        time.sleep(motionQuickTLInterval)
        if timelapseDiff > motionQuickTLTimer:
            keepTakingImages = False

@pageauc
Copy link
Owner

pageauc commented Mar 20, 2018

Updated GitHub pi-timolo.py ver 10.93 per your suggested fix.
Decided to release based on your testing. Will give it a try when I get a chance
Your work is appreciated.
Thanks Claude ...

@pageauc pageauc closed this as completed Mar 20, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants