I am attempting to build a program that will automatically post the photos taken by motion from my usb webcam to a rest API, and have ran into some problems. My livestream works correctly, and it takes photos at the desired time.
I have my script to post the photo here:

on_picture_save home/pi/Documents/on_picture_save.py (yes the semicolon is deleted)

How can I make the script use the file that has just been saved, or do it do it automatically so I would just have to do something like this?:

import requests url = "https://api.emotuit.com/upload"

r = requests.post(url)


The target directory all motion is saved in is home/pi/Monitor, and the photos are saved in their own directory based on the time of event like this:

picture_filename %v_%Y-%m-%d-%H:%M/%q

Any ideas would be appreciated, thanks!

  • 1
    Hello and welcome – All you have done is true. What's exactly your problem? Check it out.
    – M. Rostami
    Feb 11 '20 at 16:34
  • 1
    Thank you - I have seen that, I'm just not sure if I need to specify the file name in the code for on picture save, as it is supposed to do it for each picture as it is saved(multiple are saved for each). If I do need to specify the filename I am unsure how I would be able to do that, as they are named by the date and time which are produced outside the python script. This could lead to some time discrepencies and more issues.
    – jakeant2
    Feb 11 '20 at 16:44
  • 1
    Alright. Please ask your question on SO. You would get the answer there.
    – M. Rostami
    Feb 11 '20 at 17:10
  • Ah, let me try to simplify your question: (1) You have multiple directories (rest API url known), each of which stores MotionEyes pictures, (2) The directories are named by time, eg. y20m02dt12h10m07s33.motion. (3) Now you need to use Rpi4B python 3.7.3 to get the pictures. Do I understand your problem correctly?
    – tlfong01
    Feb 12 '20 at 2:11
  • @tlfong01 correct. I have been able to tell to capture only the first picture, but now i need the program to wait about 15 seconds(450 frames in my case) after motion is detected to take the photo so a countdown can be given, then the single photo will be posted to the api using a curl command in on_picture_save as i updated here[stackoverflow.com/questions/60175123/….
    – jakeant2
    Feb 12 '20 at 22:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.