Page 1 of 2

Raspberry dashcam wanted

Posted: Mon Jul 23, 2012 1:05 pm
by Toasted
I would love to use Raspberry pi as a dashcam . I was just involved in a car accident yesterday, the car i was driving is totaled fortunately there were witnesses, i cant imagine how ugly it would have been w/o witnesses.

there are plenty of cheap dashcams on the market, some of which work. I wont more and i think pi is the perfect platform fro a dashcam.

Re: Raspberry dashcam wanted

Posted: Tue Aug 21, 2012 6:42 pm
by Dust
I must say, that I would really welcome this thing too...Luckilly, I did not have any accident yet ;)

Re: Raspberry dashcam wanted

Posted: Thu Aug 23, 2012 7:22 pm
by MotoBlue
Apologies if everyone has seen this

https://www.youtube.com/watch?feature=p ... lxHPJAONpE

Re: Raspberry dashcam wanted

Posted: Tue Aug 28, 2012 5:55 am
by dan3008
The only problem with useing the pi for this is the lack of a clock. But you could add one. And i'm sure there are other ways round that. Maybe have 2 cameras (one on the dash, one on your car clock) and make the software on your pi put the 2 together?

Re: Raspberry dashcam wanted

Posted: Tue Aug 28, 2012 5:13 pm
by gordonendersby
Or incorporate a gps receiver and get the time and location as well from the satellites.

Gordon

Re: Raspberry dashcam wanted

Posted: Tue Aug 28, 2012 8:24 pm
by dan3008
Good thourght. Then you could store the rout (or time staped GPS co-ordinates) along side the video.

Personally, if your adding GPS, I'd consider seeing if you can get any satnav software working, make the pi do the whole lot.

Re: Raspberry dashcam wanted

Posted: Wed Aug 29, 2012 9:33 pm
by Dust
My intention is just to make it as simple as possible and add other less necessary things later.
That means only to plug any webcam (In my case this 640x480px webcam) and when you start the car, power will go on > PI starts > SW automatically stats and then begins recording / making pictures.
Simple thing on the first look, but it took us whole day without any result.

So the main question here is:
Is here anyone, who has the skills, time and will to programme this (simple) thing :?:

I belive it would help alot of people with PI.

Re: Raspberry dashcam wanted

Posted: Wed Oct 03, 2012 5:06 pm
by Dust
Is here anyone? :-)

Re: Raspberry dashcam wanted

Posted: Mon Oct 15, 2012 9:31 pm
by anshul.sood
I had the same idea - a car dashcam using the pi would be a nifty thing to have. I'm waiting for the camera module to be released before i start coding for it but I'll post progress here when i start. [I think I have the necessary coding skills - but famous last words!]

Basic idea is this: RPi plugs into the car (cigarette lighter) power out so it starts/stops automatically when you start/stop the car. It records high def videos and stores them in fixed interval clips (10min or 60min or so). If it starts exceeding a configured amount of storage space, it overwrites the oldest clips (or converts them to lower resolution or frame-rate etc.)

Here are some un-resolved issues (in a somewhat decreasing order of desirability):
1. Audio: The camera module is likely not going to have a microphone. So either that is fed using a separate USB microphone or the clips are mute :-/
2. Clock: I didn't think about the RPi missing a clock till I read this thread - but yeah, a dashcam without a time stamp on the video would definitely be missing something!
3. GPS: There's no GPS chip on the RPi - unless you want the dashcam to be a vehicle-tracker, it's going to be need additional hardware.

Re: Raspberry dashcam wanted

Posted: Thu Oct 18, 2012 3:22 pm
by Dust
What about using just simple USB webcam?
In my opinion it's easier and cheaper and not everyone is willing to buy cam. module when he has a webcam :)

Re: Raspberry dashcam wanted

Posted: Thu Nov 08, 2012 6:40 pm
by psion0027
Maybe this would help: http://sirlagz.net/2012/08/04/how-to-st ... pberry-pi/

I'm not sure how you would implement this to a dashcam but I suppose it could be a good start.

Re: Raspberry dashcam wanted

Posted: Fri Dec 28, 2012 12:53 am
by smccain
I work for a company that does exactly this. We supply dash cams for large delivery services, metropolitan transportation (buses, trains, trolleys), and for end users who want to monitor driving habits (think of a parent who wants to monitor their teenagers driving habits).

The big thing isn't the hardware, though we do spend some time and money on R&D, the real power is in the data. That's where the true value of collision software lies. Videos are a powerful tool and can tell you behaviors (like attention to the road, distractions, eye wandering, etc..) leading up to and subsequent of the incident, but it's the acceleration, braking, side acceleration (impact) and steering that really tell the whole story. This requires accelerometers, compasses, and gps receivers.

Finally, I don't know about the UK, but that sort of information is not always admissible in court. Especially if it's a DIY device. If you truly want something that you can use in a court of law I suggest using a commercial product. You can always use your PI as an auxiliary, but the data that is admissible probably has to come from a commercial device. We have to pass some stringent regulations in order for our devices to be used in litigation (criminal or civil).

Re: Raspberry dashcam wanted

Posted: Fri Dec 28, 2012 12:59 am
by aTao
smccain wrote: Finally, I don't know about the UK, but that sort of information is not always admissible in court. Especially if it's a DIY device. If you truly want something that you can use in a court of law I suggest using a commercial product. You can always use your PI as an auxiliary, but the data that is admissible probably has to come from a commercial device. We have to pass some stringent regulations in order for our devices to be used in litigation (criminal or civil).
You are right, video evidence in the UK is flimsy at best and needs very careful protection. I saw such evidence being collected, it appeared to be important that the VHS cassette was kept in the recorder and the whole lot taken for forensics. Homebrew digital recordings are not likely to have much sway.

Re: Raspberry dashcam wanted

Posted: Tue Feb 12, 2013 6:31 pm
by silverfox0786
how is this project getting on i'd love to know what happens

being in the UK this interests me too
and not so much for courts but insurance as i had the same happen to me

i had a car reverse into my front

he was refusing out right to exchange details saying that regardless of who is at fault the front damage car (car behind) is at fault and yes thats a B***Sh*** UK law

but with video evidence if not the courts but claiming on insurance would be easy as insurance dont care about that law they just wanna know who was at fault and if the video showed him revering into me then the insuarance comany would have seen that the one in front was at fault and his insurance need pay for damages


this time though i was lucky that UK is the most CCTVed country in the world and there was a council camera pointing right at the incident spot that captured the whole incident including him being a nuecence and not exchanging details and police where dispached

:)

Re: Raspberry dashcam wanted

Posted: Sun May 19, 2013 4:29 pm
by Puce
I'm interessed by that project too.
While using it in court in another story, it will be very useful for insurance.
The RPI cam is a good choice for definition and frame speed. Until you try yourself you don't imagine how difficult it is to have a readable image of a license plate.
A simple capture with rotating files when SD is full should already be a very good start.
I don't care about night performances, even for professional dash cam this is a problem.
RTC and GPS speed/coordinates can be added later.
Some software can maybe be used as base like zone minder, opencv, motion...

Dashcams on the net are between 250 to 500 € for a decent day quality. It must be possible with a RPI for a decent cost ;)

Re: Raspberry dashcam wanted

Posted: Wed Jun 05, 2013 9:55 am
by atnu
I have made myself a car camera recorder, here is the info and code (fast and dirty)

-Raspberry Pi Model A
-Camera module
-Tactile button (to start recording, stop recording and to shutdown the Pi if pressed >5s)
-Wifi optional, Get the date and upload the videos
-Anker 10 000mAh battery or phone charger for car

Image

Logic:
Starts recording video right after Pi has started (record.sh) is started from /etc/rc.local
Button code is started right after Pi has started from /etc/rc.local)
place the scripts to /home/pi/video or change the paths

recording.sh

Code: Select all

#!/bin/sh
#
# Launch of code added to /etc/rc.local on the line before "exit 0" :
# sh /home/pi/video/recording.sh

#go to working directory
cd /home/pi/video/
#3Gb free space limit
limit=3000000

#check the size from disk partition /dev/root
size=$(df -k /dev/root | tail -1 | awk '{print $4}')

#remove oldest files according to the free space limit
while [ $size -le $limit ]
do
   #remove .h264 files starting from the oldest file
   ls -1tr |grep .h264 | head -n -1 | xargs -d '\n' rm -f
   #check free space again
   size=$(df -k /dev/root | tail -1 | awk '{print $4}')
done

date=$(date +"%Y%m%d%H%M")

#start capturing video and exit the script
raspivid -o /home/pi/video/video_$date.h264 -n -w 1280 -h 720 -b 6000000 -t 9000000 &

stop_recording.sh:

Code: Select all

#!/bin/sh
#stops the raspivid process
pid=`pidof raspivid`
`kill -2 $pid`
stop_button.py
Press button to: if recording is on, stop it. if recording is off start it, press >5sec to shutdown Pi

Code: Select all

#!/usr/bin/env python
#
# Launch of code added to /etc/rc.local on the line before "exit 0" :
# python /home/pi/video/stop_button.py &
import RPi.GPIO as GPIO
import time
import os
GPIO.setmode(GPIO.BCM)
GPIO.setup(23, GPIO.IN) 

recording = True;

while True:
  if(GPIO.input(23) == False ):
    #button pressed down
    if(recording == True):
      recording = False
      os.system("sudo sh /home/pi/video/stop_recording.sh")
    else:
      recording = True
      os.system("sudo sh /home/pi/video/record.sh")
    #press button 5 secs to shutdown raspi
    time.sleep(5)
    if(GPIO.input(23) == False ):
      #os.system("sudo sh stop_recording.sh")
      os.system("sudo shutdown -h now")
      #print('shutdown')
      break
  time.sleep(0.5)
my todo list for the project: startup optimization, video uploading: rsync automatically to server, better casing for camera etc.
I'll put some example videos of the recordings made so far

Update1:
Example video in youtube: http://www.youtube.com/watch?v=hFQeA3epmtI
Original example video: https://dl.dropboxusercontent.com/u/793 ... 601901.mp4

Re: Raspberry dashcam wanted

Posted: Sun Jun 09, 2013 8:35 pm
by niio
@atnu:
great job. I suggest to store video into separate files for example every 5 minutes for one file. Then add an option (button click) to lock the video file, to prevent it from overwriting.

Re: Raspberry dashcam wanted

Posted: Tue Jun 11, 2013 11:49 am
by RaTTuS
Oh I made mine work as a dash cam
Model A + SSD HD [64GB] = powered from usb adpater in car
it starts up starts recording 10 min chunks loops over 6 file names -
I've got to tune the size a bit but I reckon I can get a about 3hrs on a loop
I need to add a soft off circuit so it can shut down properly... and mount it a bit better so it's a bit more user friendly

Re: Raspberry dashcam wanted

Posted: Tue Jun 11, 2013 2:49 pm
by cabe
Side question RaTTus,

Could you let me know large are those 10 minute chunks are, please?

Cheers.

Re: Raspberry dashcam wanted

Posted: Tue Jun 11, 2013 3:45 pm
by RaTTuS
just less than 2GB approx

Re: Raspberry dashcam wanted

Posted: Tue Jun 11, 2013 6:44 pm
by cabe
Really? Sounds quite high for 10 mins, I guess that's almost raw with very little compression.

I was shooting for like 4-6 mbps for 1080p30 H264, is it just your settings or does that level of compression compromise the quality?

Re: Raspberry dashcam wanted

Posted: Tue Jun 11, 2013 7:19 pm
by yves97
Hello,
[Really? Sounds quite high for 10 mins, I guess that's almost raw with very little compression.
I get 122M for 1 minute recording.

[email protected] ~/stills $ ls -lh |head -5
total 9,1G
-rw-r--r-- 1 pi pi 122M juin 11 14:44 00020-10062013_1217-17.h264
-rw-r--r-- 1 pi pi 121M juin 11 14:45 00020-11062013_1444-18.h264
-rw-r--r-- 1 pi pi 121M juin 11 14:46 00020-11062013_1445-18.h264
-rw-r--r-- 1 pi pi 122M juin 11 14:47 00020-11062013_1446-19.h264
[email protected] ~/stills $ du -h
9,4G .
[email protected] ~/stills $ ls |wc -l
83
Here is the capture command:
[email protected] ~ $ cat capturevideo1.sh
ROLL=$(cat /home/pi/series)
SAVEDIR=/home/pi/stills

while true; do
filename=$ROLL-$(date +"%d%m%Y_%H%M-%S").h264
/opt/vc/bin/raspivid -t 60000 -vs -o $SAVEDIR/$filename
done;

Re: Raspberry dashcam wanted

Posted: Wed Jun 12, 2013 6:25 am
by atnu
cabe wrote:Really? Sounds quite high for 10 mins, I guess that's almost raw with very little compression.

I was shooting for like 4-6 mbps for 1080p30 H264, is it just your settings or does that level of compression compromise the quality?
Usually for 720p 4-6Mbps is ok, and for 1080p 6-8Mbps is ok, I used 6Mbps for 720p and I got around 43Mb for 60 sec video

Re: Raspberry dashcam wanted

Posted: Fri Jul 12, 2013 8:44 pm
by moonshoes
Some good projects here! I want to do the same with one of my Pi's, but the end goal is to have the camera integrated so that it is hardly noticeable. After digging through the post here http://www.raspberrypi.org/phpBB3/viewt ... 7&start=75 I have learned you can extend the ribbon cable that is connected to the camera board.

I hope to find a nice spot to stick the camera board and then run the cable, hidden, back to the pi. I'd love to see if anyone has put together a project similar to this idea.

Re: Raspberry dashcam wanted

Posted: Tue Aug 20, 2013 6:00 pm
by ryanistheryan
Hey there,

For anyone that wants to see an interesting project related to a dashcam/blackbox, check out this project with its guide.

http://www.stuffaboutcode.com/2013/07/r ... h-obd.html