Coder Social home page Coder Social logo

mosnfar / raspberrypi4-camera-to-cloud Goto Github PK

View Code? Open in Web Editor NEW
3.0 1.0 0.0 10.76 MB

Camera connected to Raspberry Pi enables direct cloud streaming. Repository offers seamless online sharing solution.

Home Page: https://forge.mosn.me/stream-raspberry-pi-camera-feed-to-cloud

License: GNU General Public License v3.0

Shell 100.00%
raspberry-pi raspberry-pi-4 webcam-capture webcam-streaming

raspberrypi4-camera-to-cloud's Introduction

Raspberry Pi Feed to Cloud

Connecting a camera to a Raspberry Pi through the on-board camera port or USB port can assist in capturing images or videos. This setup can serve various purposes. In this repository, you can find a prebuilt shell script designed to facilitate continuous image streaming to online cloud services such as Google Drive for Linux-operated Raspberry Pi.

๐Ÿ“‹ Use cases

  • Online Stream of Camera
  • Frame Capture for Time-lapse
  • Object Tracking using Cloud

๐Ÿ”ง How to use

First, you should install dependencies like 'ffmpeg', 'rclone'. To do it use the command below:

sudo apt update && sudo apt install ffmpeg rclone

After that, you should configure your cloud service, which here we continue with the Google Drive option. I suggest to use this two complete tutorials for proper configuration:

But simply to do that start with rclone, you should use the command below and follow the given instructions:

rclone config

Now, You should have a directory on your local device to sync Google Drive with it. Here we create a directory named /home/user/path/to/, to do this you can use this command:

mkdir /home/user/path/to

So, Time to configure a webcam or camera. Here I'm using a USB webcam but if you want to use the on-board Raspberry Pi camera follow this link.

USB webcam connected to Raspberry Pi 4

Connect the USB webcam to Raspberry Pi and find the hardware directory which in this example is /dev/video0.

Awesome, All essential parts are configured. Now the script is ready for use.
Download the script file to your local machine:

curl -L https://raw.githubusercontent.com/mosnfar/raspberrypi4-camera-to-cloud/main/run.sh -o ./run.sh

Before using the script you should change some variables in the script to work correctly. Use nano run.sh to open text editor then go to 'Configure global variables' section and change the variable.

...

# Configure global variables

DRIVE_ADD="drive:/parentfolder/subfolder" #rclone given address for drive main folder and subfolder

STORE_DIR="/home/user/path/to/" #Local directory which will link to drive
LOG_DIR="/home/user/path/for/log/" #Directory to store log for command

CAMERA_ADD="/dev/video0" #Hardware directory for Video Input

DAY_OF_STORAGE=2 #Maximum date for storage - e.g. 2 days
MAX_STORAGE_SIZE=200000000 #Maximum size for storage - e.g. 200000000 Byte -> 200 MB

INTERVAL_DELAY=10 #Interval between taking frames - e.g. 10 seconds

MAX_RETRIES=10 #Times to rclone try

...

You should change these variables:

Essential Variables

Should change this before running this script according to your configuration.

  • DRIVE_ADD: The address to which you configure Google Drive with rclone command.
  • STORE_DIR: This directory will be connected to Drive and sync with it.
  • LOG_DIR: Where you want to store your system script logs and errors.
  • CAMERA_ADD: Hardware address of video input (webcam|camera) to use.
  • DAY_OF_STORAGE: By this variable, you can configure how many days should store the content.
  • MAX_STORAGE_SIZE: This variable manages Drive capacity and prevents extending from Google storage limit.
  • INTERVAL_DELAY: This is the gap time between taking frames.

Additional Variables

If you customize the script more, you can change this too.

  • MAX_RETRIES: This variable defines how many times should rclone try.

Now everything is done and you should add run.sh command to system jobs to be run on every reboot. To do that use this command:

sudo chmod +x run.sh && (crontab -l ; echo "@reboot /real/path/to/run.sh") | crontab - && crontab -l

And its better to reboot your system.

๐ŸŽ‰ It's Done. All is ready.


Find More

I hope this can help you. You can subscribe to my yotube channel or support my blog to find out more stuff which help you.

Youtube

RESOURCES: Using USB Webcam, Use rclone for Google Drive, rclone, Google Drive

raspberrypi4-camera-to-cloud's People

Contributors

mosnfar avatar

Stargazers

Yadollah Abbasnia avatar  avatar Hamidreza Behzadi avatar

Watchers

 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.