Giter Club home page Giter Club logo

cam-rpi-server-2202's Introduction

Cam flask photo receiver server & raspberry camera client

Build info (auto-generated)

  • Version: 0.0.5
  • Last changes timestamp: 2022.02.24, 00:55
  • Last changes timetag: 220224-0055

API

Basic api structure:

TODO: Describe api (for specific server version)

Server urls

Remote server: http://cam-rpi-server.lilliputten.ru/

Server

Images server runs on python/flask platform.

TODO: Describe basic server functionality.

TODO: Preserve capability to implement public server (with same or like functinal?)

Python venv maintenance

Server command for creating venv:

virtualenv -p python3 ~/.venv-py3-flask
source ~/.venv-py3-flask/bin/activate
pip install -r requirements.txt

Local script for venv creating and initialization:

sh utils/util-venv-init.sh

Local command for activate venv:

call .venv/Scripts/activate
source .venv/Scripts/activate

Python dependencies

pip install PKGNAME
pip freeze > requirements-frozen.txt
pip install -r requirements.txt

Camera interface

Camera shots are taken using the raspistill program using commands like:

# Default:
raspistill -o image.jpg
# Half:
raspistill -w 1296 -h 972 -o image-half.jpg
# Quarter:
raspistill -w 648 -h 486 -o image-quarter.jpg

For commandline reference use raspistill --help.

Raspberry camera client

Use client-make-and-upload-image.sh script to make & upload image to server.

Use crontab to automate image capture.

Sample crontab lines:

  • Every minute: * * * * * /home/pi/projects/cam-rpi-server/client-make-and-upload-image.sh
  • Every 15th minute: */15 * * * * /home/pi/projects/cam-rpi-server/client-make-and-upload-image.sh

Real crontab entry example:

# Test entry...
30 */1 * * * date >> ~/test_crontab
*/5 * * * * date >> ~/test_crontab

# Make & upload shots every 5 minutes (with forced logging)...
*/5 * * * * sh /home/pi/projects/cam-rpi-server/client-make-and-upload-image.sh >> /home/pi/projects/cam-rpi-server/cron-log.txt 2>&1

# Make & upload shots every 20 minutes...
*/20 * * * * sh /home/pi/projects/cam-rpi-server/client-make-and-upload-image.sh

# Reboot every 3 hours (00:55, 03:55, etc...)
55 */3 * * * sudo reboot -f

# Start server on boot
@reboot sh /home/pi/projects/cam-rpi-server/utils/rpi-start-server.sh

Crontab commands:

Edit crontab:

crontab -e

Show crontab:

crontab -l

Automatically add server start command to crontab with:

sh utils/rpi-gunicorn-server-create-crontab-entry.sh

See also:

Crontab logging

Uncomment # cron.* line in /etc/rsyslog.conf (eg. edit with sudo vim /etc/rsyslog.conf).

Show crontab log:

tail -f /var/log/cron.log

Or use output reirect in command:

/home/pi/cam-rpi-server/client-make-and-upload-image.sh >> /home/pi/cam-rpi-server/cron.log 2>&1
python /home/pi/cam-client/client-make-image.py >>  /home/pi/projects/cam-rpi-server/cron.log 2>&1

Run gunicorn service on raspberry (using index.py)

gunicorn -w 1 -b 0.0.0.0:4000 hello:app

Real command (see utils/rpi-start-server.sh, attention for port number, in -b switch):

&& "$GUNICORN" \
  --reload \
  -D \
  -w 1 \
  -b 0.0.0.0:4000 \
  --chdir "$ROOT" \
  --pid="$PIDFILE" \
  --log-file="$LOGFILE" \
  index \
&& echo "Done." \

See log-gunicorn.log and log-gunicorn.pid files in project root folder after start.

For autostart see 'crontab' section above.

cam-rpi-server-2202's People

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.