GoCam is a free, open-source security camera software solution. The intent of GoCam is to provide a more accessible, resilient solution to video surveillance.
I run GoCam on a Raspberry Pi 3 Model B with an attached NO-IR Camera module. For a full shopping list of parts, see below (prices subject to change):
- Raspbery Pi 3 Model B ($37.00)
- NO-IR Camera Module ($25.00)
- Micro SD Card (32 GB) ($9.00)
- Micro USB 5V 2.5A Power Supply ($8.00)
Total Cost: $79.00 (excluding taxes)
Note: I chose to use a No-IR camera simply because they are cheap and operate in both day and night (although daytime colors tend to be a bit washed out), and they do not require any additional filters or special lenses.
Once you have a binary of GoCam to run, you
can start it like any other program,
by simply executing ./gocam
.
Note: GoCam expects a YAML configuration file
at ./config/default.yaml
by default. You may
refer to the configuration file in this repository
for an example.
Currently, this project is an infant and I haven't set up any Docker images, Vagrant files, or anything of the sort.
However, if you have golang installed, compiling is very simple: go build
.
If you would like to build the application for Raspbian (OS), please note you must already be on an ARM architecture to compile it, since this application requires the CGO bindings due to the GoCV dependency. For now, building for raspberry pi is quite tedious as it requires building Go 1.11 and OpenCV from source:
- Install legacy Golang (required to compile Golang 1.11)
apt update -y
apt-get install golang
- Build Golang 1.11 from source
git clone https://go.googlesource.com/go
cd go
git checkout go1.11
cd src
./all.bash
cd ../..
mv go /usr/local/go
- Add Go 1.11 to system
PATH
echo -e export PATH="\$PATH:/usr/local/go/bin" >> /etc/profile
export PATH="$PATH:/usr/local/go/bin"
- Set your
GOPATH
system environment variable
echo -e export GOPATH=$HOME >> ~/.profile
export GOPATH=$HOME
- Build OpenCV from source
go get -u -d gocv.io/x/gocv
cd $GOPATH/src/gocv.io/x/gocv
make install
- Finally...build GoCam!
go install github.com/zcking/gocam
To allow you to access the web server on the GoCam,
you'll need to modify your firewall. You can do
this with traditional iptables
like so:
# This will allow TCP traffic to port 80
# on the PI, from anywhere.
sudo iptables -A INPUT -p tcp --dport 80 -j ACCEPT
If you don't need SSH access to the GoCam, after creating the previous rule, you can restrict access to prevent any unauthorized access with the following:
# This will drop all other input traffic
sudo iptables -A INPUT -j DROP
To make the above iptables
changes
persistent on reboots, you can run the
following:
sudo /sbin/iptables-save