Introduction

I’m not paranoid. I just have too many hobbies. I bought an IP security camera to mess with FTP image uploads with ImageMagick “convert” for animations, and to check in on my house whenever I’m on vacation. I started this project with datafication on the mind, which lead me to examine the data feeds in my life that are not being captured.

This is a large .gif. Sorry.

This is a large .gif. Sorry.

Every thirty seconds, a security camera in my house captures a photo of my main level and uploads the .jpg to a Ubuntu cloud server I rent. The FTP procedure on my webcam creates a folder to contain an hour’s worth of .jpg files. These hourly folders are located in a daily folder on my home directory.

As it turns out, if you plot file size of a directory of 120 .jpg files, you can notice incredible trends in your images. Stare in awe at the image below for a minute, and continue reading.

Image 1: A file size plot of every file in 2:00pm’s directory on March 8th, 2016.

Image 1: A file size plot of every file in 2:00pm’s directory on March 8th, 2016.


Hardware

The camera I have installed is a D-Link 930L. This camera can tie into D-Link’s security cloud, or whatever, but I bought this camera because it has the capability to upload pictures to a personal server. I didn’t like the idea of anybody having access to photos of my living space besides my wife and me.


Server

I rent a cloud server from Digital Ocean. It’s a five dollar droplet that has 20GB of storage space and 512MB of RAM. The server houses and serves my website, zfleeman.com, using Nginx. Every hour, I run a script (below) to create new directories in my website’s /security directory for the current day and hour. The script calls an ImageMagick function to convert the entire FTP-uploaded image directory to a poorly-optimized animated image.


Command Line Script

The code below is located in a .sh file. I don’t think I’m great at Linux, but I pretend to be.

#!/bin/bash
currHour=$(date +"%H")"00"
currDay=$(date +"%Y%m%d")
cd ~/security/"$currDay"/"$currHour"
mkdir ~/www/zfleeman.com/security/"$currDay"/
mkdir ~/www/zfleeman.com/security/"$currDay"/"$currHour"/
convert *.jpg -resize 60% -colors 32 ~/www/zfleeman.com/security/"$currDay"/"$currHour"/"$currDay$currHour".gif
cd ~/security/
R CMD BATCH plotdir.R

R Code

The code below uses base R. The idea is to “datafy,” that large directory. The plot above shows my file size on the Y coordinate, and the record series on the X coordinate.

The data frame of a directory is pretty straight forward.

y <- read.csv("securityplot/sizedata.csv")
head(y)
##                               X  size isdir mode               mtime
## 1 mainlevel2016030814002801.jpg 48354 FALSE  644 2016-03-08 14:00:51
## 2 mainlevel2016030814005801.jpg 48174 FALSE  644 2016-03-08 14:01:21
## 3 mainlevel2016030814012801.jpg 48187 FALSE  644 2016-03-08 14:01:51
## 4 mainlevel2016030814015801.jpg 47896 FALSE  644 2016-03-08 14:02:21
## 5 mainlevel2016030814022801.jpg 47673 FALSE  644 2016-03-08 14:02:51
## 6 mainlevel2016030814025801.jpg 47392 FALSE  644 2016-03-08 14:03:21
##                 ctime               atime  uid  gid    uname   grname
## 1 2016-03-08 14:00:51 2016-03-08 14:59:01 1000 1000 zfleeman zfleeman
## 2 2016-03-08 14:01:21 2016-03-08 14:59:01 1000 1000 zfleeman zfleeman
## 3 2016-03-08 14:01:51 2016-03-08 14:59:01 1000 1000 zfleeman zfleeman
## 4 2016-03-08 14:02:21 2016-03-08 14:59:01 1000 1000 zfleeman zfleeman
## 5 2016-03-08 14:02:51 2016-03-08 14:59:01 1000 1000 zfleeman zfleeman
## 6 2016-03-08 14:03:21 2016-03-08 14:59:01 1000 1000 zfleeman zfleeman

The row names are the file names, the file size is in bits, and there are three different time stamps along with file permissions. My X-axis for this project was each observation in the data frame, and the Y-axis was the file size of each image. If a .jpg gets more light/color in the frame, the file size will be larger.

d <- paste(format(Sys.time(),"%Y%m%d"),sep='')
h <- paste(format(Sys.time(),"%H"),"00",sep='')
x <- list.files(pattern = "^(.*)+(\\.csv)")
y <- file.info(x)
write.csv(y,file=paste("/home/zfleeman/www/zfleeman.com/security/",d,"/",h,"/","sizedata.csv",sep=''))
png(paste("/home/zfleeman/www/zfleeman.com/security/",d,"/",h,"/","sizeplot.png",sep=''),width=1280,height=720,units="px")
plot(y$size,ylab="File Size in Bits",xlab="One Hour of Photos")

The Final Result

The final product that I consume is a directory with three files:

I pretty much navigate a small Nginx autoindex directory. I could make a nice website with PHP, or something, but damn.

I pretty much navigate a small Nginx autoindex directory. I could make a nice website with PHP, or something, but damn.

#list.files() gets *everything* in a directory, so I have to ignore the last row. I now have some regular expressions getting only the jpg files, but replicating that in this markdown document sounds like effort.
y <- y[1:118,]

plot(y$size,ylab="File Size in Bits",xlab="One Hour of Photos",type = "l")

I love this plot because it shows the massive cloud passing over my house.

Built with R version 3.3.1 by Zach Fleeman during his free time.