Octolapse: How to turn off saving and, rendering to the PI?

I know this is all early DSLR beta stuff but...

Its a little slow with very high resolutions pictures which I think causes a slight delay in the printing itself.
So I would like to turn off rendering and downloading with the PI mainly for post-processing reason but, I would like to save the images to the DSLR's native sd card. Then compile and process them separately in another software.

What did you already try to solve it?
Um nothing yet..

All the software is fully up to date

Octolapse 0.3.4rc1.dev3

OctoPrint : 1.3.9

I'm using an adapter for my Nikon D3200. I think the format of the shutter release hardware is called an UM-2 and/or MC-DC1/MC-DC2. I managed to buy a third-party [pro]master Camera Release Cable "Fits NIKON DC2 Connector" which presents on the other end as a three-conductor 1/8" stereo plug. If you can then find a three-conductor 1/8" stereo jack (typical of an iPhone/iPod accessory) then you can interface with the Nikon's shutter release system.

I'm reasonably sure I've heard others suggest that the OctoLapse plugin can trigger an external DSLR so check in that space as well. For the Nikon—in order to take a photo—you have to connect the focus pin first, short delay and then connect the shutter pin. This gives the autofocus a chance to do its thing.

@guru
Octolapse's "external camera" feature does work with the current nikon(s) 5300, 5600 & 850 im using. (using the tethering cable, not the shutter release cable) It triggers and takes the photos but, I believe the script your instructed to write for this does a function call to download and delete the image from the camera's ram when it downloads them to the pi. This also seems to place the printer on an extended hold until the file finishes transfering Though i'm not savvy enough to edit this myself I guessing its something Lurker shouldn't have an issue with.
I'm also using a manual focus rather than an autofocus to ensure I have a consistent result, I would not recommend autofocus for any kind of timelapse really.

Interesting... I hadn't thought of tethering with a USB cable but that makes sense. To be pendantic, there's also the WU-1a wireless dongle which makes the Nikon a wi-fi hotspot and which allows access to the internal SD card inside the camera to include the triggering of photography. It's a little fussy but it could be leveraged, in theory.

Warning: Novel incoming!

You are absolutely correct. Acquiring and downloading ultra high res images can take a while. I assume you are using my sample script from the Octolapse wiki page? If so, this script not only takes a pic, but waits for it to save to internal ram, then downloads the image to the pi via USB2 (at least it's usb2 in my case). For very large images this can add several seconds to the capture time.

I've developed two alternative methods (my next video will be about this) to deal with this.

Option 1: - Render manually, don't download images to pi

  1. Use a camera initialization script (in camera profile settings) to set the capture target to SD instead if internal ram. Here is an example:
#!/bin/sh
# Camera Pre-Render script
# Written by: Formerlurker@pm.me

# Put the arguments sent by Octolapse into variables for easy use
CAMERA_NAME=$1
# Set camera to save images to flash memory
gphoto2 --set-config capturetarget=2
  1. Switch the snapshot acquisition script to use the --trigger-capture flag instead of the --capture-image-and-download flag like so:
#!/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

# trigger the camera and exit immediately, this will return right after the shutter closes, so no camera delay is necessary
gphoto2 --trigger-capture
  1. Manually download the images from your camera and render them as you see fit.

Option 2 - Erase ALL images from SD, don't download images to pi, and allow Octolapse to render. The script I'm using also leaves images on SD so you can also render manually if you want. You could easily delete the images from the camera after downloading them if you are so inclined.

  1. In the camera initialization script, also DELETE ALL IMAGE FILES RECURSIVELY (save your family photos first!!!). I haven't found a workaround for this yet, but it's required later on (you'll see why).
#!/bin/sh
# Camera Pre-Render script
# Written by: Formerlurker@pm.me

# Put the arguments sent by Octolapse into variables for easy use
CAMERA_NAME=$1
# Set camera to save images to flash memory
gphoto2 --set-config capturetarget=2
# DELETE ALL FILES ON THE CAMERA, SO BACKUP YOUR FAMILY PHOTOS FIRST!
gphoto2 --delete-all-files --recurse
  1. Use the same snapshot acquisition script as above.
  2. Use this pre-render script to download and rename all of the images from the DSLR right before rendering:
#!/bin/sh
# Camera Pre-Render script
# Written by: Formerlurker@pm.me

# Put the arguments sent by Octolapse into variables for easy use
CAMERA_NAME=$1
SNAPSHOT_DIRECTORY=$2
SNAPSHOT_FILENAME_TEMPLATE=$3
SNAPSHOT_FULL_PATH_TEMPLATE=$4

# Check to see if the snapshot directory exists
if [ ! -d "${SNAPSHOT_DIRECTORY}" ];
then
  echo "Creating directory: ${SNAPSHOT_DIRECTORY}"
  mkdir -p "${SNAPSHOT_DIRECTORY}"
fi

# switch to the snapshot directory
cd "${SNAPSHOT_DIRECTORY}"

# download all of the images on the camera
gphoto2 --get-all-files --force-overwrite

# rename images according to the supplied file template
a=0
for i in *.JPG *.jpg *.JPEG *.jpeg; do
  new=$(printf "${SNAPSHOT_FILENAME_TEMPLATE}" "${a}")
  mv -- "${i}" "${new}"
  a=$((a+1))
done

This way you will get a rendered timelapse at the end, AND you will have all of the images on your camera! Either method should cut your DSLR image acquisition time down by several seconds (reduced by over half for me at 4000x6000 resolution).

There are some drawbacks. You won't get any timelapse preview for the DSLR within the Octolapse tab. My workaround for this is to also capture a timelapse with my webcam. It's nice to have multiple angles anyway! Also, currently no metadata will be captured so the rendering text overlay will not work with this method. Similarly the image transformations (rotate, mirror, etc) will not work. I know how to fix these two limitations, but haven't done so yet. Hopefully sometime soon.

Let me know how it turns out or if you have any questions or suggestions! Good luck!

I'll test these out and let you know if I have any issues. Thanks for the great reply.

1 Like

I'm probably doing something wrong but, I placed the script you posted under cd /home/pi/scripts then edited the nano take snapshot but It didn't seem to change anything after I saved and rebooted.

Did you update the camera settings with the new script paths? It definitely should have changed something. You probably did this but just in case can you send me a pic of the script paths within your camera profile? You should have 3 script paths defined: Initialization Script, Pre Render Script, Image Acquisition Script.

Probably not, I'm not very good with the pi yet, so I was just guessing based on the script structure where to put it exactly. I applied the script you provided and, replaced the part of step 5 of your github wiki external camera setup. https://github.com/FormerLurker/Octolapse/wiki/Configuring-an-External-Camera

So I ran option one in cd/home/pi/scripts (pasted in)
I then opened nano take-snapshot.sh and, added the second part of option 1.
I'm guessing that wasn't correct.
Lets assume we're working fresh install. How would I go about properly applying this code to octolapse?

Did you create the camera initialization script I posted for Option 1? There is a line in there that is VERY important and tells your camera to save on your SD card:

gphoto2 --set-config capturetarget=2

You'll have to add the path for this script to your Octolapse camera profile (assuming you ran nano initialize-camera.sh from the /home/pi/scripts folder, pasted the init script into the editor, saved, and added permissions by running chmod +x initialize-camera.sh) like so:

It would also be possible to get this working by editing the take-snapshot.sh file by adding gphoto2 --set-config capturetarget=2 command right before the gphoto2 --trigger-capture command. I think that might add a small amount of time to the capture process. I haven't measured the effect, however, so it might be very small.

Hi FormerLurker,

Thanks for the very detailed write up. I just have 2 questions.

  1. If I'm going with option 2, am I able to remove the camera SD card once the print is finished and all images are taken?

  2. Can you tell me if i'm calling my scripts in the correct places?

  • Snapshot Acquire Script - /home/pi/scripts/take-snapshot.sh

  • Before Print Start Script - /home/pi/scripts/camera-initilization.sh

  • Before Render Script - /home/pi.scripts/before-render.sh

I changed the take-snapshot.sh script to the one listed in option 1.

Thanks for your help!

Shikan

@Shikan_Yue,

  1. If I'm going with option 2, am I able to remove the camera SD card once the print is finished and all images are taken?

Yes! The images should remain until you start another print. Remember that the initialization script is deleting ALL images from the SD card.

  1. Can you tell me if i'm calling my scripts in the correct places?

There really is no wrong place as long as you have added the proper permissions. However, this looks suspect:

Before Render Script - /home/pi.scripts/before-render.sh

Maybe you meant this:

Before Render Script - /home/pi/scripts/before-render.sh

I hope that helps!

EDIT: Reading thorough the thread again, I did not give the script permission to run without a password. Will try that and let you know how it goes.

You were not kidding about the quick response!

I ended up fixing that before testing.

I'm am getting an error immediately if I try to start a test print or if I try to test the before print start script. It goes away if I remove the script.

Error message:

Octolapse - Camera Settings Error

There were 1 errors while applying custom camera settings/scripts:
camera_initialization_error: The custom camera initialization script failed with the following error message: The process does not exist

Any thoughts?

Hi again,

I've spent the past few hours trying to run this and have had little luck. The best result was that the camera would take snapshots for the first 10-15 layers. After that an unspecified camera error would pop up and the camera would no longer take snapshots. I've uploaded a log file as well as the octolapse.json

The snapshot acquisition code from the wiki page works great, I just can't seem to get this version running.

Thanks for your help!Octolapse Log Files.zip (287.7 KB)

I don't see any camera errors in your log file, but I DO see snapshots being taken VERY frequently (every 10 seconds or so). If your camera memory is slow and you are taking very high res images, you are probably overrunning your RAM buffer, which will likely cause an error in gphoto2.

Try a print that gives your camera more time to save images to SD, or just ignore the camera error and accept that you will miss a few snapshots if you have many very quick layers. See if the timelapse renders. Octolapse should nicely tolerate and report camera errors like this.

You could also try adding faster flash memory to your camera and see if that helps. Not sure about the specifics of your DSLR, but it could help. OR you could turn down the resolution or increase the image compression, both should help.

This really sounds like a hardware/gphoto2 limitation (I wouldn't call it an issue), but since I'm not seeing any camera error in the log, I can't be 100% sure. You could try manually calling gphoto2 and see how many images you can take in rapid succession before it starts reporting an error (My camera will do this, and I suspect pretty much all will). That should give us a decent error report.

Thanks!

I missed this earlier message. Did you ever get this to work? The initialization script is very important, because it sets the image target to SD (it defaults to RAM for most (all?) cameras).

If you are having trouble with that initialization script, try to run the command manually through the command line and see if there are problems. It is also possible to query the camera for its capabilities (look into the gphoto2 docs), perhaps yours requires a slightly different script? I would help more with this but I'm out of town and don't have access to the equipment necessary to try out commands :frowning: I should be back Sunday though.

This was just an error on my part. I did not give proper permission to the camera initialization script. It worked perfectly after that.

[quote="FormerLurker, post:15, topic:4341, full:true"]
I don't see any camera errors in your log file, but I DO see snapshots being taken VERY frequently (every 10 seconds or so). If your camera memory is slow and you are taking very high res images, you are probably overrunning your RAM buffer, which will likely cause an error in gphoto2.

This is probably my fault again, I wanted a way to quickly run tests so I made a 10 x 10 mm cylinder with 1mm wall thickness. Each layer runs super fast since it's only drawing two very small circles. I will try again with a more reasonable model and report back.

Cool, maybe just turn your feed rate way down to like 10%? That way you can reuse your test gcode without having to slice something new :slight_smile:

Ive been trying to get this scripts to work and followed the instructions just like you wrote and i really apreciate you for sharing this instructions.

the scripts and my camera were working and shooting but the photos didnt save on the SD and as mentioned by Shikan Yue every 15 layers the camera just stopped working, my personal solution was to write in the initialize-camera.sh

gphoto2 --set-config capturetarget=1

Instead of

gphoto2 --set-config capturetarget=2

After that my camera worked fine!