Record the 3d print process.

This is the way I record my 3d printing, using a Raspberry Pi and its camera module. At Thingeverse I found an enclosure for the camera. A quick search reveals a lot of hits: Thingeverse raspberry pi camera.

I printed out housing for both the Pi and the camera, and mounted it nearby the 3d printer.

I'm using a script to contrl the camera to take a picture every second. This is the Python program:

import os
import time
from time import sleep
import picamera
import string

path ='/home/pi/images/'
loop = 1
camera = picamera.PiCamera()

def checkFolder():
    folder = 0
    global newPath
    for _, dirnames, filenames in os.walk(path):
        folder += len(dirnames)
    print 'Folders: %s' % folder
    newPath = '/home/pi/images/' + str(folder)
    os.makedirs(newPath)

def takePicture():
    currentNumber = len([f for f in os.listdir(newPath) if os.path.isfile(os.path.join(newPath,f))])
    print 'Current files : %s' % currentNumber
    newNumber = int (currentNumber)  + 1
    sleep(2)
    completeFileName = 'image-%s' % newNumber
    camera.capture(newPath+'/%s.jpg' % completeFileName)
    sleep(3)
    print 'Current files : %s' % newNumber
    print '******************'


def main():
    checkFolder()
    while loop == 1:
        print 'Open camera.'
        takePicture()
    print 'Close camera.'

main()

This program counts the number of folders in /home/pi/images and adds one to the number, then creates a new folder, with the counted number as the name. All images are stored in the new folder. This is repeated with a one second delay.