-
Notifications
You must be signed in to change notification settings - Fork 101
V0.4 Configuring a DSLR
This guide has changed since V0.3.4. I will continue to update this guide to bring it in line with V0.4 ASAP.
I do not recommend that you use a DSLR if you have not gotten Octolapse to work with a webcam. There are several reasons for this:
- It is much more difficult to configure a DSLR, and every DSLR is slightly different. Solving DSLR issues requires a lot of technical knowledge. If you are new to the game, this is not a good starting point
- If you are uncomfortable or unfamiliar with Octolapse, you may have issues unrelated to the DSLR configuration that are confusing. Ironing out all of the kinks with Octolapse before attempting to use a DSLR is extremely important.
- If you are having quality issues, using a DSLR will make them worse. Capturing images with a DSLR can take many times longer than a webcam, which will increase artifacts and print time. Make sure you are getting acceptable quality when using a webcam will reduce the chances of having problems when using a DSLR.
- It is very difficult for me to provide help with DSLR issues. Every camera is different, and I only have access to a single camera: A Nikon D5200. This limits my ability to replicate, and thus debug your issues.
- Rendering an ultra high resolution video may be beyond the capability of a Raspberry Pi. They are cheap and convenient, but they don't have a lot of memory. You might need to render the timelapse manually, depending on your rendering settings, and some people find this intimidating.
- Newer cameras might not work properly. It takes time to update the capture software (GPhoto2 in this case) for use with newer cameras. If you have a brand new model, you may have to wait until support is added, if it is even possible.
Despite all of the above, the image quality of a good DSLR is second to none.
Octolapse supports external cameras by calling an external script. The script is responsible for acquiring an image. Optionally the script can put the resulting image in the proper place so that Octolapse can render the resulting timelapse.
You will need to create a script that can trigger your camera. This guide uses GPhoto2, which is an extremely sophisticated program for remotely controlling supported cameras using a USB cable.
Important Note: I am NOT the creator or maintainer of gphoto2, nor am I an expert in its operation. I cannot provide support for this software, because each camera is different, and it's very likely that I won't be able to replicate your issue on my camera.
These instructions assume that you are running OctoPi v0.15.1. The steps will be similar for other flavors of Linux, though some modifications may be necessary.
Watch a video version of this guild here. I must point out that this video was made for Octolapse v0.3.4, so it is a bit out of date. I will try to update this ASAP.
It is extremely important that you have the latest firmware and packages before attempting to use a DSLR. Follow this guide on the raspberrypi.org site for instructions on how to update your packages and distribution.
You must install the newest version of OctoPrint (1.4.0 currently) for full DSLR support. This is very important, so don't skip it!
Make sure that you have the latest version of Octolapse (v0.4.0) installed. If you do not, be sure to read the getting started guide to learn how to install, configure, and use Octolapse. Follow the guide completely, and get to know the new features in V0.4. A LOT has changed, and you'll save yourself a lot of time and grief if you get Octolapse configured properly before you attempt to configure a DSLR.
Similar steps would be needed for a non/raspberry pi Linux setup. This example install uses GPhoto2 to acquire the images from your DSLR. I had some trouble with installation on my pi, so let me know if you have problems installing.
Here is a list of compatible cameras.
Use SSH or some other method to open a shell.
Now, follow this guide to install GPhoto2.
Now plug in your DSLR via usb, power it up, and execute the following command to make sure GPhoto2 is detecting your camera:
gphoto2 --auto-detect
If things are working properly You should get something similar to the following:
Model Port
----------------------------------------------------------
Nikon DSC D5200 usb:001,016
If there are no cameras detected you will get the following output:
Model Port
----------------------------------------------------------
In this case you should move to the official gphoto2 site and try to find a solution. Make sure you check the list of compatible cameras.
If things are working you should be able to run the following command to acquire an image:
gphoto2 --auto-detect --capture-image
Your camera should take a picture and save it on the camera. You should also be able to download an image to the current directory with the following command:
gphoto2 --auto-detect --capture-image-and-download
You should now see a new image in the current folder by entering the ls
command. If you have problems here they will need to be corrected before continuing.
Octolapse will soon ship with some default scripts, but for now they need to be created manually. As soon as these scripts are available I will update these instructions.
Below you will find a script that will trigger a snapshot, download the image from the camera's internal RAM to the pi, and move it into the proper directory with the proper name. This method preserves all of the functionality of Octolapse that you normally enjoy when using a webcam, including image transformations, post processing, snapshot preview, rendering, etc.
Now we need to create our snapshot script. I put my script in /home/pi/scripts like so:
cd /home/pi/scripts
nano take-snapshot.sh
This will open the nano editor. Copy the following script and paste it into the nano editor by pressing the right mouse key.
IMPORTANT NOTE: The very first line #!/bin/sh
is important, and must be included.
#!/bin/sh
# Put the arguments sent by Octolapse into variables for easy use
SNAPSHOT_NUMBER=$1
DELAY_SECONDS=$2
DATA_DIRECTORY=$3
SNAPSHOT_DIRECTORY=$4
SNAPSHOT_FILENAME=$5
SNAPSHOT_FULL_PATH=$6
# Check to see if the snapshot directory exists
if [ ! -d "${SNAPSHOT_DIRECTORY}" ];
then
echo "Creating directory: ${SNAPSHOT_DIRECTORY}"
mkdir -p "${SNAPSHOT_DIRECTORY}"
fi
# IMPORTANT - You must add gphoto2 to your /etc/sudoers file in order to execute gphoto2 without sudo
# otherwise the following line will fail.
sudo gphoto2 --auto-detect --capture-image-and-download --filename "${SNAPSHOT_FULL_PATH}"
if [ ! -f "${SNAPSHOT_FULL_PATH}" ];
then
echo "The snapshot was not found in the expected directory: '${SNAPSHOT_FULL_PATH}'." >&2
exit 1
fi
Now we need to save the script. Press ctrl + o and then Enter to save. Then press ctrl + x to exit.
Now we need to add execute permission to the script with the following command
chmod +x take-snapshot.sh
Finally, we can test our script by entering in the following command (it's long, so make sure you copy everything):
/home/pi/scripts/take-snapshot.sh 1 1 "" "/home/pi/scripts" "" "/home/pi/scripts/test.jpg"
you should see the following output:
New file is in location /capt0000.jpg on the camera
Saving file as /home/pi/scripts/test.jpg
Deleting file /capt0000.jpg on the camera
If you enter ls
you should see test.jpg in the current directory. You can delete the test image by entering rm test.jpg
.
We're almost done! All that is needed is to create a new DSLR camera profile and to set it up, which is pretty easy and fast compared to the other steps.
First, we'll need to create a new profile.
Open up OctoPrint in a browser window and click on the Octolapse tab. Make sure the Current Settings are expanded. If they are not visible, click on the Current Run Configuration link.
Then open up the camera profiles page within the Octolapse settings by clicking on the 'Cameras' link:
Next click on the Add Profile... button.
Name your profile so you can easily identify the camera. I'm going to use Nikon D5200 DSLR in this example:
Now, change the Camera Type dropdown box to External Camera - Script:
Next enter the following for 'Snapshot Acquire Script'
/home/pi/scripts/take-snapshot.sh
Here is what your Snapshot Acquire Script should look like:
Now, click the Test button next to the Snapshot Acquire Script:
If everything worked, you will see this popup indicating success:
If you get a failure message (will be in red) or a warning message (will be orange), there was a problem. I will try to add some troubleshooting steps, but for now I recommend rechecking your script and testing GPhoto2.
Next, set the 'Snapshot Delay' to 0 since the script won't exit until the photo is taken and downloaded. It's a good idea to turn the snapshot timeout up to 10000 (10 seconds) while you are testing to make sure your camera has enough time to take and download the photo, especially at higher resolutions.
Finally save your profile.
That should be it as far as configuration goes! Now run a short test print. Navigate to the Octolapse tab, expand the Current Run Configuration section, and enable the Test Mode slider at the bottom:
Test mode will prevent your printer from heating up (bed and extruder) and will strip off all extrusion commands, so you won't waste any time or plastic. I strongly recommend you unload your filament, though, just in case there is a bug or glitch in the test mode code, and make sure your bed/hotend stay cool.
Make sure you also select your DSLR profile in the dropdown box under the Timelapse Preview:
You will see a message explaining that no snapshots have been taken yet with your DSLR. This is normal, and you should see snapshots here after the first snapshot is taken during a print.
Select a test file to print. I recommend something small and fast, so you don't have to wait long to make sure things are working correctly. Click Print once you have selected your file.
Octolapse should now run as usual. Since Test Mode is enabled, your bed and hotend should stay cool, no fans should turn on, and no plastic should be extruding. Octolapse will now acquire images from your DSLR, and any other cameras you have enabled. You should hear your camera snapping away during the snapshot phase. Octolapse will put all downloaded images into a new folder created within the following directory structure:
/home/pi/.octoprint/data/octolapse/tmp/octolapse_snapshots_tmp/{SOME_LONG_GUID_HERE}/{ANOTHER_LONG_GUID_HERE}
Note: If you changed the default snapshot directory within the Octolapse main settings, your snapshots should go into that directory instead.
Now that you've completed your test print, check out the resulting timelapse (it might take a while to render). You're probably noticing that the quality isn't quite as high as you'd expect. Never fear, this can be corrected!
Open up the 'Rendering' profile. Consider turning up the bitrate to 15M or 20M. The resulting video will be much larger. I do NOT recommend that you use the H264/H265 codec for DSLR timelapses if you are running Octoprint from a Raspberry Pi, because it often results in a malloc error since there isn't enough memory on the Pi to render lots of ultra high res frames. If anyone has any information about how I can fix this, please let me know!
If you have a multi-core computer (Pi3), you may want to turn up the rendering threads. Rendering an ultra high res timelapse can take a very long time, especially on a pi running only a single thread. Ideally you would use one thread per core. Be sure NOT to attempt a new print while Octolapse is rendering unless you are sure there is plenty of processing power. If you MUST print while you are rendering, make sure to leave at least 1 free core when you set the rendering threads, else OctoPrint may become unresponsive.
Now it's time to adjust your camera settings to get the best possible image. I recommend using very bright lights (more than you think is necessary) and setting all camera controls to manual, including focus, exposure and white balance. You will have to refer to your camera manual for instructions on how to configure your camera's settings. You should take pictures manually and look at the results until you are satisfied with the image quality.
Once you get your camera settings dialed in, it's time to run another test print. Repeat this process of adjusting your settings and running a test print until your video quality meets your expectations. If everything is dialed in, and your lighting is adequate and well positioned, your image quality should be outstanding.
Now, turn off test mode:
I would recommend using the same print you were using in test mode, and trying that before you attempt anything larger.
When the print is finished, examine it for quality. If you are having quality issues, check out the Troubleshooting Print Quality guide. There are also some advanced methods for reducing image capture time, which is the most common reason for DSLR print quality issues. These guides aren't completed yet for the newest version of Octolapse (V0.4), but I will add links once those have been finished.
Congratulations, your DSLR is configured and ready to go!
Coming Soon
The instructions for this are coming soon!
Octolapse is provided without warranties of any kind. By installing Octolapse you agree to accept all liability for any damage caused directly or indirectly by Octolapse.
Use caution and never leave your printer unattended.
If you have a great new guide, see a typo, or have other suggestions for improving the existing documentation, please let me know! You can either submit a feature request or submit a pull request. I would appreciate it greatly!
Consider supporting Octolapse by becoming a Patron, a Github Sponsor, or by sending some coffee/beer money, I would REALLY appreciate it. Almost all of the donations go towards offsetting the cost of development, which are substantial. Plus it always makes my day!
If you cannot afford to leave a tip or just don't want to, that is fine too! Octolapse is free and open source after all. There are other ways you can help ensure that Octolapse continues to be updated and improved:
- Share your Octolapse videos, and be sure to leave a link and explain that the timelapses were captured with Octolapse and OctoPrint (you will be asked how you made the timelapse, so this will also save you some time answering questions). This is not necessary, but it is greatly appreciated.
- Subscribe to my youtube channel.
- Post any bugs you find to the Issues Page. I would like to eliminate as many bugs as possible!
- Participate in the OctoPrint Community Forums, and help all the noobs get OctoPrint and Octolapse working and help expand the hobby. The more people use OctoPrint and Octolapse, the better the software will become!
- If you've created a working and tested printer profile for any printers that aren't in the make/model list, please send it to me! I want to make it as easy as possible for new users to get their printers configured quickly.
- Help me make this documentation better! Octolapse has a LOT of documentation, guides, tips, etc., both here in the Wiki and integrated with the Octolapse plugin. If you find inaccuracies, typos, gaps, or have ideas for improvement, I'd love to hear about them.
- If you have any special talents that could be applied to Octolapse development, like graphic design, video production (think tutorials), programming, etc., maybe you'd like to participate more directly in Octolapse development/documentation?