From charlesreid1

Outline: Raspbian

The issue with using Kali was, the use of the camera required onboard video libraries that did not come bundled with Kali. These were also not in the aptitude repositories, and I had no luck installing them. So for the camera project I decided to go with Raspbian and not sink any more time into getting Kali to work with camera hardware.

pi/raspberry

Hardware

  • Raspberry Pi
  • Pi camera
  • Camera case
  • Network cable
  • Power cable

Setting up the Pi

To begin with, I installed a fresh Kali Linux arm image. I wanted to make sure I had installed the operating system correctly and that I could reach the Pi just fine. I connected the Pi directly to my laptop using a crossover cable. After connecting the two, I restarted both machines. They automatically picked link-local addresses at 169.254.X.Y, which I was able to use to SSH directly into the Pi.

This confirmed that I had everything working ok on the Pi.

Connecting to the Pi

I connected the Pi to a router, set a fixed IP address on the boot line of cmdline.txt on the memory card's boot sector, and plugged it into my home router. I then fired up the Pi.

SSH to 192.168.0.111 confirmed I was able to remotely reach the Pi. The Pi was also able to successfully reach the gateway and the outside internet.

Installing stuff

Get busy installing stuff:

apt-get install -y screen
screen

In the new screen window:

apt-get install -y vim aptitude
apt-get install -y python build-essential
apt-get install -y python-pip

This doesn't do much - most everything here is already installed.

Now install the pi camera library (should also be already installed):

pip install picamera

Now one last thing to do before testing the camera is to enable the boot flag that lets you use the camera (disabled by default).

Run raspi-config and pick the camera menu item (number 6). Choose to enable the camera. Save changes, and you'll be asked to reboot the Pi. Reboot the Pi. Now you can try out the camera.

Testing Picamera

Open python and try to import the picamera library:

import picamera

Now try capturing your first photo:

import picamera
camera = picamera.PiCamera()
camera.capture('helloworld.jpg')

Woo hoo! Works perfect!

Problems out of nowhere

Suddenly, out of nowhere, just when I had finished rigging the wireless and the zip ties and the camera box, everything failed. The camera would no longer respond. Hardware connection problem. Tear it all apart.

Resolution of problems out of nowhere

The problems that came out of nowhere turned out to be connection problems with the flat yellow plate on the front of the camera face. I had to re-seat that plate snugly. After that, the camera worked fine.

Testing with crossover cable

Connected Pi and laptop with crossover cable, set Pi IP to 169.254.111.111, tested local ssh to Pi - PASSED

Connected Pi and laptop with crossover cable, same IP, tested capturing photo from Pi camera - PASSED

Testing with Wireless

Wireless, 192.168.0.X, test whether we can connect to the wireless - PASSED

Wireless, 192.168.0.X, test whether we can auto-MAGIC-ally connect to the wireless on boot - PASSED

Wireless, 192.168.0.X, test whether we can plug in on other side of house, SSH in, start/finish photo capture, run HTTP server - PASSED

Wireless, 192.168.0.X, test whether we can capture photos, with everything taped into position - PASSED

Wireless, 192.168.0.X, test whether we can run a time lapse test - PASSED

Final Arrangement for Timelapse 2

The final arrangement of parts for the first timelapse was hacky and definitely would not have held together more than 24 hours. Here are photos of the Pi on the balcony. I used some packing tape (should have used duct tape, but I didn't have a fresh roll) to create a "sheet". I wrapped that around the Pi, the cabling for the camera, and the balcony rail.

PiBalcony3.jpg

PiBalcony2.jpg

PiBalcony1.jpg

This whole arrangement was made super awkward by the camera cable. It was wide, inflexible, hard to twist (and had to be twisted at least once given the way it came out of the case), but the real challenge was that if it was tugged too hard, the yellow plate on the front of the camera would pop off, and the entire assembly would have to be un-taped and disassembled to push the plate back onto the board, reassembled, re-taped, etc.

PiDesk1.jpg

Scripting

Taking photos

To script taking a picture, use the following code, which loops forever, taking photos and marking them with timestamps:

# pic.py

import picamera
from datetime import datetime
import time

camera = picamera.PiCamera()

while True:

    prefix = datetime.strftime(datetime.now(),"photo_%Y%m%d-%H%M%S")
    filename = prefix+".jpg"

    camera.capture(filename)
    print "Saving photo to %s"%(filename)

    time.sleep(2)

Processing photos

While the full details are over at the Timelapse/Processing page, here's a quick taste of what collating a bunch of images together looks like.

Assuming you have all the images you want in a pile in one directory, we want to rename them in order so that they have the same name as before, but with the suffix _0001,0002,0003, etc.

Successful Capture

Notes on what the successful capture looks like, and links to pages/notes on processing timelapse photos.

Notes

Timelapse 2 Notes

Running my first timelapse, I didn't bother doing any calculations to see how long I could run based on available disk space - I just ran at a frequency of 1 photo per 2 seconds and let it run all night. It maxed out the SD card after about 6 hours.

Results and notes from this script/timelapse:

  • Dislike case of Raspberry Pi 3
  • Tape job was very perilously perched after a night of sitting - need mechanical security, not just tape and balance (ZIP TIES and/or LASHING)

What to keep the same:

  • Camera worked ok
  • Mini SD card worked ok
  • Kali operating system worked ok, connected to wireless ok, hosted files ok, transferred data ok
  • Power cable situation worked ok

What to change for next timelapse:

  • More HD space
  • No red light
  • Case for Pi - loose top makes it awkward to do anything with it, forced camera angle is awkward too
  • Need a swiveling plate or platform or boom
  • Up/down angle of camera was difficult to control

For Next Design:

  • Make it reusable across other types of camera and sensor platforms
  • What other kinds of cameras might we be using
  • What other kinds of control systems
  • Generic mounting brackets, mechanical connections, on a platform would be good. Screws/bolts/etc.
  • Way of positioning platform using railing.

What to change eventually:

  • Adjustable frequency and more sophistication in script
  • Motor control of plate or device to control angles and motion
  • Image processing (vivid, contrast, hue, blur, tilt shift)

Processing timelapse photos

For notes on processing timelapse photos, see Timelapse/Processing page.

Notes on time-lapse photography in general at the Timelapse page.

Next timelapse

For planning notes for Timelapse 3, see: RaspberryPi/Timelapse3

Flags