Octolapse with DSLR

Last updated 5 months ago

Octolapse is a cool little program to let you capture stabilized time lapses of your 3D print. It does this by moving the print head to a fixed position after each layer and captures an image.

This is a hacky way to improve your time-lapse quality by using a DSLR camera. The way it works is that it uses the MQTT extension of Octolapse and waits for the MQTT event: "octoprint/event/PositionUpdate". The script then uses gphoto2 to capture a image from a camera, which is connected to the Raspberry Pi via USB. The final time lapse is rendered on a PC. To keep Octolapse happy, a normal webcam is connected too.

What you will need:

  • A Raspberry Pi with Octoprint and Octolapse installed

  • A dummy webcam to keep Octolapse happy

  • A DSLR camera

  • Fixed power supply for your DSLR (Optional)

  • A big SD card for the Raspberry Pi

Step1:

Install gphoto2 on the Raspberry Pi

sudo apt-get install gphoto2

Step 2:

Check if your DSLR camera can be connected over USB to the Raspberry Pi. You can try to take a test image:

gphoto2 --auto-detect
Model Port
----------------------------------------------------------
Nikon DSC D3300 usb:001,016
gphoto2 --camera 'Nikon DSC D3300' --capture-image-and-download --filename '%Y%m%d%H%M%S.jpg'

Step 3 (Optional):

Check if you can power your DSLR camera from an external supply. Long prints take a toll on your battery an it's quite tedious to wait for hours to change the battery and maby miss it. Also its hard to change the battery without moving the camera.

Step 4

Install the MQTT extension for Octolapse

Configure it like seen in the images

Step 4

Download the trigger script

wget https://gist.githubusercontent.com/yodakohl/d0c4025b5f91aa215ab99910a4dec45f/raw/44ac4e5e39c457851093fb27b2d0908dbe803e3f/main.py

Modify the main.py file to use your camera instead of Nikon DSC D3300:

os.system("gphoto2 --camera 'Nikon DSC D3300' --capture-image-and-download --filename '%Y%m%d%H%M%S.jpg'")

Install some libraries on the Raspberry Pi:

sudo apt-get install python-pip
sudo pip install paho-mqtt
sudo apt-get install -y mosquitto mosquitto-clients

Step 5

You will need a normal webcam running the time-lapse while your DSLR is taking photos.

Configure your Octolapse like when using a normal webcam. Go into the camera settings and increase the Snapshot Delay as necessary (I used 2 seconds).

Step 6

Start the python script

python main.py

To keep the script running when you are connected over ssh use nohup instead

nohup python main.py &

Step 7

Start the print. Begin with a small test print to configure the Snapshot Delay of the camera. You want this to be as short as possible to reduce stringing artefacts in your print. Try to find some settings for your DSLR which take the shortest time to capture images (manual focus..).

Step 8

When the print is finished copy the images to your computer and render the time-lapse. I use ffmpeg on Ubuntu to do this. This might work on the Raspberry too but could take some time.

ffmpeg -r 25 -pattern_type glob -i '*.jpg' -c:v copy output.avi
ffmpeg -i output.avi -c:v libvpx-vp9 -s 1920x1080 -crf 30 -b:v 0 -c:a libopus -b:a 96k output.webm