GithubHelp home page GithubHelp logo

notchum / dashcam Goto Github PK

View Code? Open in Web Editor NEW
19.0 2.0 4.0 29 KB

A Raspberry Pi Zero W car dashcam with overlayed GPS/GLONASS data and auto-purging of old video.

License: GNU General Public License v3.0

Python 98.84% Shell 1.16%
python3 dashcam gps raspberry-pi recording

dashcam's Introduction

dashcam

A custom and open-souce dashcam using a Raspberry Pi Zero W with a Pi Camera and a bit of Python code. It records video clips in 10 minute segments, while keeping logs of all GPS/GLONASS data recieved during each recording. The GPS data is overlayed on the output video and any video/logs older than 10 days are deleted.

Dependencies

  • python3
  • picamera

Hardware

  • Raspberry Pi Zero W
  • This is the camera module I ended up buying. I was attracted to it because of the wide-angle lens, which is great for dashcam footage.
  • Considering SD cards are awful at read/writing to a lot, I wanted to use an actual USB flash stick. This also has the benefit of being easily removable to plug into my main PC and copy any needed footage over. Considering this, I bought this adapter for the Pi Zero.
  • I had an FPV drone GLONASS + GPS unit laying around, this one in particular. But really any GPS unit would work.

3D Prints

Here are my remixed parts. I printed them out on my Ender 3 and assembled them using some nuts/bolts/screws I had laying around.

Wiring

The only wiring/soldering that I did to the Pi was for the GPS unit. It is a simple UART interface so I used pins 8 & 10 on the Pi for RX/TX from the unit. Then, for power, I used pin 1 (3V3) and pin 6 (GND).

Software

1.) Here is a great tutorial to set up a headless, lite version of Raspbian.

2.) Clone this repo in the /home/pi directory. The tree should look something like this:

/home/pi/
└──dashcam/
   ├── crontab.txt
   ├── README.md
   ├── resources/
   └── src/
       ├── deprecated/
       ├── gps_utils.py
       ├── main.py
       └── purge.sh

3.) Copy the contents of crontab.txt and then run:

$ crontab -e

During the first run of crontab it will ask which text editor to use. After choosing, paste the copied contents of crontab.txt and then save/exit. This will run the bash script that purges old folders containing recordings/logs, then runs main.py which starts recording/logging.

Setting Up the USB Stick

There is a particular way to set up the USB to record footage to it. If it isn't set up this way, nothing will work.

Identify the Devices Unique ID

After plugging the USB stick into the Pi, run the following command:

$ ls -l /dev/disk/by-uuid/

The output should list some storage devices and unique IDs for each. Look for sda1 in the output, this is the USB stick. Copy the ID of the stick, it should look something like "18A9-9943".

Create a Mount Point

Make the mounting directory:

$ sudo mkdir /media/usb

Then, to ensure the ownership is correct, run the following command:

$ sudo chown -R pi:pi /media/usb

Set Up Auto Mount

Usually one could mount the USB and be finished, but since this is a dashcam that will be turning on and off a lot the USB needs to be mounted automatically at each reboot/start-up. To accomplish this, the fstab file needs to be edited (use whatever text editor):

$ sudo vim /etc/fstab

Then add the following line at the end:

UUID=18A9-9943 /media/usb vfat auto,nofail,noatime,users,rw,uid=pi,gid=pi 0 0

Make sure to replace the UUID to match the one from earlier. The “nofail” option allows the boot process to proceed if the drive is not plugged in. The “noatime” option stops the file access time being updated every time a file is read from the USB stick. This helps improve performance. After this is done, simply reboot:

$ sudo reboot

Set Up Hierarchy

Once the USB is mounting automatically, navigate to /media/usb and run:

$ mkdir Dashcam/
$ cd Dashcam/
$ mkdir Recordings/ Logs/

After creating each directory on the USB stick, the tree should look like:

/media/usb/Dashcam/
├── Logs/
└── Recordings/

Last Notes

  • Ignore the deprecated folder, I left those files in there because I have commitment issues.
  • If you use this project's code then you should alter the video length/framerate/resolution to fit your usage. Furthermore, the purging script checks for folders older than 10 days, this can be altered as well to fit your storage constraints.
  • The recordings are initially recording with an .h264 extension and once the designated video length is reached the script convert the video to .mp4. This works pretty well but if the Pi is turned off mid-recording, then the latest file will still have that .h264 extension, so take note of that.
  • The conversion from .h264 to .mp4 takes some time to accomplish, so there could be a couple seconds gap in between video clips. Furthermore, if the video length is very large (like 30 minutes) then the conversion will take even longer causing an even larger gap between clips. This conversion function that I used is purely a convenience factor and can be removed if .h264 video is okay with you. Or if someone wanted to use threads to concurrently convert and start the next recording then that should eliminate these issues.

dashcam's People

Contributors

notchum avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

dashcam's Issues

No staellite/ Invalid fix quality

So i build this dashcam with the pi4 the noir v 2.1 cam and the Beitian BN-180 gps.

This is what i got in the logs:

ERROR: Invalid fix quality
ERROR: No satellite data available
ERROR: Invalid fix quality
ERROR: No satellite data available
ERROR: Invalid fix quality
ERROR: No satellite data available
ERROR: Invalid fix quality
ERROR: No satellite data available
ERROR: Invalid fix quality
ERROR: No satellite data available
ERROR: Invalid fix quality
ERROR: No satellite data available
ERROR: Invalid fix quality
ERROR: No satellite data available
ERROR: Invalid fix quality
ERROR: No satellite data available
ERROR: Invalid fix quality
ERROR: No satellite data available
ERROR: Invalid fix quality

Dont know what the problem is.

USB or SDCard?

Hello, based on the pictures you have posted on imgur it seems there is a slot for a USB stick as well there is a SDCard inserted where the GPS module is. Could you confirm if i am reading it correct from the pictures? I understand like you mentioned about the read write errors on SDCard and hence a USB stick might be better, but just trying to figure out the setup in the pictures first. thanks!

Shutdown Pi/Stop Recording

I realy like the idea to use a Pi Zero as a dashcam, but i think there Is a small Problem.

So if i would use it in my car the Pi Boots up when i start the Engine and starts recording. But how can i stop the recording after i arrived or after a real car accident?
How can i savely power done the Pi to Not dammage the SD Card or USB Drive?
I have already destroyed a sd card by unplugging the Pi (3B+ instead of Zero but does Not matter) without Shutdown…

Mounting with a 3dprinted holder is clear to me and also Power from my cigaret lighter but i See no way to switch it off other then pull the Plug

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.