CamAutoUpload

Version 1.0 | Last Updated on 2019-07-12

Components

Hint: To obtain the front-end source code (will work on most webpages), right-click anywhere on the target webpage and select "View Page Source" (on Firefox and Chrome/Chromium)

What it Does

  1. Take a photo using the camera connected to the Raspberry Pi.
  2. Upload the photo to the front-end website for showing in the public.
  3. Loop Steps 1 and 2 until the back-end is stopped by the user.

Pre-Requisites

Pi Camera API This controls the Raspberry Pi camera using Python. To install:
pip3 install picamera

Python API for Neocities This enables the upload of files to the Neocities site. To install:
git clone https://github.com/neocities/python-neocities
cd python-neocities
python3 setup.py install

Back-End Code

main This is the entry point for the program. This file enables the Python back-end to be started or stopped using the commandline while keeping the commandline accessible. This is useful for headless Raspberry Pi's, where users would SSH into their Pi's, start the program and leave the SSH session without having to quit the program.

cam.py This is the Python script that contains the code for the back-end functionality. It calls on the camera to take pictures and uploads pictures shot to this Neocities site.

Usage

./main start
  • Triggers the back-end to start running.
  • Shell will be accessible after initialising.
  • PID of the process started is recorded.

./main status
  • Checks if a process is currently running.
  • If running, shows its PID to the user.

./main stop
  • PID of the process started earlier is retreived.
  • Kills the process of the back-end through the PID.

Risks, Future Direction and FAQs

Risk
Wear and tear of memory card overtime due to excessive saving and overwriting of picture file to storage.
What you can do
Write picture file to RAM instead of storage (using tmpfs).

Risk
Privacy risk, of course!
What you can do
Modify "main" or add an extension to it that starts and stops the Python script at certain times without user interaction. If you are really advanced, edit away faces/body parts using a graphics API like OpenCV.

Q
I want this on GitHub so that I can fork/do pull requests to it easily!
A
I honestly feel that the project is too simple to even deserve a GitHub page on its own. But it is on the way, anyway.

Q
Only limited to one camera per Pi.
A
Indeed. And considering the dependency to the Pi Camera API, then the whole "cam.py" will have to be re-written to support USB cameras too/use on non-Pi *nix computers.