atux_null
Posts: 127
Joined: Thu Jun 21, 2012 1:58 pm

rpi camera on python

Mon Jan 07, 2019 11:01 am

Hi. trying to implement rpi camera with Python and i have followed the following https://geek-university.com/raspberry-p ... -detector/ and it stores the images when image detected. So far so good.
I would like to:
-create a folder for each day in /home/pi/camera_images/ and then have one folder for each day.
-send an alert email everytime a new snaphot has been created.
my system has ssmtp and mpack. so it sends emails from the cli already

could someone help me with this script please?

scotty101
Posts: 3500
Joined: Fri Jun 08, 2012 6:03 pm

Re: rpi camera on python

Mon Jan 07, 2019 11:18 am

Which parts are you struggling with? What code are you working with so far?

The python OS module contains os.mkdir to create a new directory. You can use the datetime module to create a string containing the day's date and if a folder of that name doesn't exist, create it.
Electronic and Computer Engineer
Pi Interests: Home Automation, IOT, Python and Tkinter

atux_null
Posts: 127
Joined: Thu Jun 21, 2012 1:58 pm

Re: rpi camera on python

Mon Jan 07, 2019 2:06 pm

being honest with u, i have lost it where to start with. :oops:

scotty101
Posts: 3500
Joined: Fri Jun 08, 2012 6:03 pm

Re: rpi camera on python

Mon Jan 07, 2019 2:16 pm

Well break it down in to simple steps. Forget about the photos for the moment and concentrate on the folder with the day's date.

You need to create the string that contains today's date so that you can create/use a folder with that name. Step 1 is to use datetime.strftime to create that string.
Step 2 will be to check if that folder already exists, os.path.exists might be a good way to do that. os.path.join() should be used to take your main directory (e.g. /home/pi/photos/) and add the date string to it (e.g. 2019_01_07) to make the path that you want (e.g. /home/pi/photos/2019_01_07)
Step 3 will be to create a new folder if one of that name doesn't exist. os.mkdir() will be the solution to that.

Create some code based on that and I'm sure we can help you debug any problems that you encounter. Post the code if you have problems.


https://docs.python.org/3.7/library/os.path.html
https://docs.python.org/3.7/library/datetime.html
https://docs.python.org/3.7/library/os.html#module-os
Electronic and Computer Engineer
Pi Interests: Home Automation, IOT, Python and Tkinter

Return to “Automation, sensing and robotics”