
A Raspberry Pi dashcam with two cameras and a GPS - aithoughts
http://pidashcam.blogspot.com
======
jakobdabo
Thanks for sharing.

Little bit off-topic question for HN: is there any encrypted Linux filesystem
which can be mounted in write-only mode using only the public key, and read-
write mode using the private/public key-pair?

I think that kind of filesystems would be very useful for dashcams and
security cameras owners for their privacy.

~~~
cnvogel
For the pretty limited usecase of a "record only" dashcam, you might consider
recording in chunks.

Create an ephemeral key for a symmetric encryption in advance, encrypt this
ephemeral key with the public-key method of your choice and store somewhere.
Then encrypt one minute of recording using this ephemeral key. I don't know if
gnupg is performing good enough on all architectures, but in principle it can
handle everything in one go, and it works exactly as described just above.

    
    
          ~ dd if=/dev/zero bs=1M count=50 | gpg -e -r 0x6AC3E4EC >encrypted.dat
        50+0 records in
        50+0 records out
        52428800 bytes (52 MB, 50 MiB) copied, 0.486881 s, 108 MB/s
    
        (Intel(R) Core(TM) i5 CPU M 450  @ 2.40GHz)
    

If you use mpeg transport streams, you can even cut at arbitrary positions (to
make, say, each file exactly 50 MiB large). When you play back, decoders will
catch up as soon as they find the proper markers. So your encryption pipeline
doesn't even have to know much about video...

~~~
cnvogel
Just pondered... there might be everything already be installed in a typical
linux system, "split" does the right thing and can pipe into a command.
Probably not the most efficient (making several copies of the data), but
certainly enough for a proof-of-concept.

    
    
        $ dd if=/dev/urandom bs=1M | \
            split -b5000000 -d -a4  --verbose \
            --filter="gpg -e -r 0x6AC3E4EC >\$FILE" \
            - recording_ 
        executing with FILE=recording_0000
        executing with FILE=recording_0001
        executing with FILE=recording_0002
        (...)
    

• -b500000 split at 50 megabyte input file size.

• -d decimal suffixes (0001, ... else aa..az..zz)

• -a4 : suffixes of length 4 (0000)

• --filter="" : filter through pgp, intended output file is in variable $FILE

• - : read stdin

• recording_ : prefix output files with this string

    
    
        $ file *recor*
        recording_0000: PGP RSA encrypted session key - keyid: 8F74FAFF 29C8C7C2 RSA (Encrypt or Sign) 2048b .
        recording_0001: PGP RSA encrypted session key - keyid: 8F74FAFF 29C8C7C2 RSA (Encrypt or Sign) 2048b .
        recording_0002: PGP RSA encrypted session key - keyid: 8F74FAFF 29C8C7C2 RSA (Encrypt or Sign) 2048b .
        (....)

------
mschuster91
If possible, I'd use _two_ flash drives, mirrored with soft-raid, for storage.
One clearly visible in the dashcam, the other hidden somewhere deeeep inside
the car with an USB extender.

Why? Because if a cop/other driver ever gets mad at you and forces you to hand
over the flash drive, you still have a copy.

Also, I'd add two microphones to the project, one for exterior sound, one for
interior (e.g. to prove what exactly has been said, or in case of a crash if
other drivers have honked, or if an ambulance had its sirens on).

And, I wouldn't use a Pi, but rather something supporting SATA, because USB
flash drives tend to have low lifecycles when constantly overwritten.

------
Animats
If you're going to have multiple cameras, the next step is to combine them
into one spherical image. Fujitsu has been doing this since 2010.[1] With four
cameras, you can get the full vehicle perimeter. Other companies now offer
such a capability.[2]

[1]
[http://www.fujitsu.com/us/products/devices/semiconductor/gdc...](http://www.fujitsu.com/us/products/devices/semiconductor/gdc/products/omni.html)
[2]
[http://www.fujitsu.com/us/products/devices/semiconductor/gdc...](http://www.fujitsu.com/us/products/devices/semiconductor/gdc/products/omni.html)

------
cr3ative
This is neat, but I would worry that something which is intended to be "set
and forget", without the usual screen, would fail silently - especially with
such a custom build. How are you assuring that it is functional and recording?

~~~
pearjuice
By verifying the contents of the hard drive once in a while?

~~~
ghaff
If it's not done automatically it won't routinely happen though. I wonder
about this with some sensors at home. Some of them routinely ping me with
status but other commercial ones are pretty much fire and forget. I can
certainly set calendar entries to run tests but you're better off with things
are self-testing in some manner.

------
blisterpeanuts
Maybe I missed it in the instructions, but how does the system handle the
shutdowns? Does he manually shut it off each time, before USB power is turned
off, or does it just handle the power cut-off gracefully? I worry that the
file system will get corrupted after a while.

There was some discussion about this on a pi board a while back; it seems that
the only safe way to handle power-off is to (1) have a battery on the pi, and
(2) catch the USB power-off signal and then shutdown gracefully.

At least, that's how the Chinese dash cams seem to work. They all have
rudimentary batteries that last about one minute unplugged from the power
outlet.

~~~
caffinatedmonk
He wrote about handling shutdowns in another post on his blog.[1]

> For the automatic shutdown I have used a 12V programmable timer in
> combination with an optocoupler.

> When the car is powered the the timer gets triggered and is starting the
> power supply for the Raspberry pi, Dashcam pi will get started and will do
> its job. When the car is turned off the optocoupler triggers the GPIO pin of
> the raspberry and starts a shutdown. After 15 seconds the timer is shutting
> down and the raspberry pi is powerless.

1: [http://pidashcam.blogspot.com/2016/03/cheap-solution-for-
aut...](http://pidashcam.blogspot.com/2016/03/cheap-solution-for-automatic-
shutdown.html)

------
teekert
Very nice! Love it that he uses Arch, I also used to use Arch for everything,
and I also run a RPi tutorials website.

I switched though, because the only questions I'd get was of people using my
commands on Raspbian and getting confused. I think the RPi audience is full of
beginners that don't understand the difference between distro's and the
kernel. Of course one should do as one pleases and Arch is the nicest distro
if you known what you are doing, imho.

~~~
undersuit
I'm a solid Debian user but I still keep the Arch wiki around since so much of
the information is completely transferable.

>I switched though, because the only questions I'd get was of people using my
commands on Raspbian and getting confused.

Not to attack your blog but was everything that Arch specific?

~~~
teekert
Well, there's Pacman, Yaourt, no sudo by default, no Python-GPIO package by
default, no Gui by default, no raspi-config... etc.

~~~
undersuit
No sudo by default! I forgot that was even a difference between Debian and
Raspbian.

I'm probably just not the beginner I used to be anymore, I can look at a
Pacman package name and figure out if it's going to work for Apt, and I'm used
to my GUI breaking every few months because I like to run proprietary Nvidia
drivers.

------
otterpro
This is a really cool project, and I'm always thinking about doing something
similar with RPi or other small computer. In the past, I had built my own
x86-based CarPC for music/media/GPS/automation/etc.

However, the rise of dash cams are better solution for video as they are much
cheaper, easier to install and run, and video is much higher quality. The
cheap $45 dashcam has 1080p with 30fps, no need to buy 12v relay timer and
deal with other power issues. Also the video on dashcams outperform the webcam
attached to the RPi due to RPi's slow USB2 (we're talking 15fps at best).

For more complete and capable product, I'd suggest using something with USB
3.0 port, or possibly a used laptop, which provides enough processing power to
record multiple videos at higher quality, and at the same time, has built-in
battery, provide power management (using serial port/other hack to handle
automatic shutdown and WOL for reboot).

Note: A lot of the functionality of CarPC has been deprecated due to mobile
device/phone/tablets, but it's still fun to have a PC running in a car.

~~~
otterpro
Actually, I think if you have all the parts already (i.e. RPi, webcams), this
makes a lot of sense. Creating a Frankenstein system out of existing
components would be interesting, and cost would be zero.

------
0942v8653
Link to "original" video if you have Flash disabled:
[https://www.youtube.com/watch?v=hCbZsu68zZU](https://www.youtube.com/watch?v=hCbZsu68zZU)

------
johnflan
I have played around with this a little, using the camera pi module gives good
results, but means you must mount the pi close to the camera. I wanted to use
USB cameras but the USB bus on the pi is too slow. From a single USB webcam I
was getting around 15fps. The newer pi's may have a faster USB bus.

------
codeulike
My raspberry pi is great fun but a bit prone to failing randomly and very
sensitive to input power levels, not sure I'd trust it if it was hooked up to
car electrics.

~~~
Grishnakh
That's not a problem. It isn't that hard to design (or buy) a circuit to
provide clean power from an automotive power source. The "carPC" community has
been doing this for ages.

------
marincounty
This is a good idea. The costs from getting a pulled over for no reason is a
big deal. I gave been pulled over for no reason, so many times, you'd think I
wasn't in America.

I bought two $15 Chinese dash cams. The same ones that are being peddled for
40 bucks plus S&H on t.v.

I bought the second one just in case the first one goes down.

I haven't been pulled over since.

~~~
fapjacks
So you intentionally mount these things front/rear and plainly visible to
police? Interesting. Also, what model camera did you buy?

~~~
nommm-nommm
Not GP but I own this camera
[http://ebay.com/itm/310752336819?_mwBanner=1](http://ebay.com/itm/310752336819?_mwBanner=1)

------
tajen
Side question: Is it customary to drive across the dotted lane?

~~~
ars
Yes, you can change lanes across a dotted line as you like. You do have to
signal first though.

What does a dotted line mean in your country?

~~~
arthulia
Did you watch the video in the article? He is driving with the middle of the
car over the dotted line. If I had to guess, I'd say it's a two-way one-lane
road with bike-lanes on either side that you can enter when cars are coming
towards you.

~~~
ars
No, I did not watch the video. Driving over the dotted line is not customary,
I thought he meant crossing it.

------
ps4fanboy
I would love to see a camera like the Dyson 360, that you mount on the top of
your car.

[http://o.aolcdn.com/hss/storage/midas/93697564cc7197a3e35979...](http://o.aolcdn.com/hss/storage/midas/93697564cc7197a3e35979bfa0133153/200691826/ysondyson3.jpg)

I guess it probably wouldnt work though as close objects would be obstructed.

------
dogma1138
Cool project, although I would not advise using dashcams if you are involved
in an accident the police can subpoena the footage which could potentially be
used against you (in both criminal and civil suits).

If you do run a dashcam I would suggest having one that does not record audio
and only keeps the last 5-10min of footage on record because GL explaining to
the cops why you have been driving like a jackass just before the accident
even if it had nothing to do with it.

~~~
swsieber
Conversely, if you're a responsible driver then it prove that you are in the
right.

~~~
dogma1138
I haven't met a single person who doesn't go above the speed limit (to a
reasonable amount) or misses a give way or stop sign once in a while.

~~~
nerdy
Speed, okay... and sometimes it's safer going faster than the posted limit (IE
with the flow of traffic). However, if you're missing stop signs, you're
definitely doing something wrong - either driving too fast or not paying
attention.

~~~
gherkin0
> However, if you're missing stop signs, you're definitely doing something
> wrong - either driving too fast or not paying attention.

Lots of people will slow down significantly (say to <10mph), but not stop
completely, if no one seems to be there.

~~~
nerdy
Sounds different from "missing" stop signs. Sadly, I see people come to
rolling stops at _most_ stop signs... so much so that it makes me feel like
I'm the only one wasting my time doing it right.

It's one of the many things that make me wild about the idea of letting
computers do the driving. Zipper-merging, slowing to time lights instead of
stopping, and no rubbernecking are wonders of the future I can't wait to
enjoy.

~~~
pravda
You might not be doing it 'right'. Most stop signs just mean _slow down_. If
there is no traffic, you should not come to a full stop.

~~~
mentat
In what country or state? In California they definitely mean you must make a
full stop. Also people seem to have forgotten any of the rules of priority at
stop lights. (Straight and right always come before left. Right on red is
below everything else.)

~~~
jdmichal
> In California they definitely mean you must make a full stop.

I guess they couldn't call it a "California stop" / "California roll" if that
wasn't the law.

