Jump to content

showing the newest image

 

I am very much new to python. I have a security system that takes pictures when motion is detected. It is running on a raspberry pi before I take it down to add things to it, I would like to know if this code would work.

import glob
import os
import time

while 1:
     list_of_files = glob.glob ('/home/pi/Desktop/Motion/*.jpg')
     latest_file = max(list_of_files, key=os.path.getctime)
     f = open(latest_file, "r")
     jpgdata = f.read()
     time.sleep(5)
     f.close()
Link to comment
Share on other sites

Link to post
Share on other sites

2 hours ago, Saksham said:

while 1

lmao

i know its horrible but i need the program to loop forever and always open the newest images

Link to comment
Share on other sites

Link to post
Share on other sites

On 9/29/2019 at 2:54 PM, Saksham said:

while 1

lmao

While -1 is even funnier. 

Sudo make me a sandwich 

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×