How To Add Time Delay Between Array of Sequential Exporsures
Posted: Tue Sep 15, 2020 8:50 pm
This is my first post, and I'm a newbie to Python and SharpCap scripting. I've been attempting to collect a series of 20 sequentially larger (and relatively short) exposures to test the linearity of my camera (ZWO ASI 178MC) under various conditions. This camera and SharpCap have been playing nicely together for single manual snapshots. But when the script that I've written runs, the images that are saved appear quite erratic in mean intensity. I suspected a timing issue between the code, SharpCap and my camera. So I've tried adding in a second capture line and even a 2 second pause between exposures, allowing time for synchronization. Here's my code so far. I'm using two sequential capture single frame lines because without this double exposure, the saved results are much more erratic (see last image below).
print SharpCap.Cameras
import time
print time
SharpCap.SelectedCamera = SharpCap.Cameras[0]# Find( lambda x:x.DeviceName == "Test Camera 2 (High Speed)") # edit to grab from your camera
SharpCap.SelectedCamera.Controls.Gain.Value = 383 # Set the gain to 383
Path = "c:\Documents\white1\exposure" # edit this to match your computer folder structure
type = ".png"
exposure_array = [0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2.0] # edit to select exposure
for exposure in exposure_array : # Loop through all exposures
SharpCap.SelectedCamera.Controls.Exposure.Value = exposure # Set the camera exposure
SharpCap.SelectedCamera.CaptureSingleFrameTo(Path + str(exposure) + type) # snap a photo, save in directory and name according to exposure
time.sleep(2)
SharpCap.SelectedCamera.CaptureSingleFrameTo(Path + str(exposure) + type) # repeat added to try to avoid erratic exposures
My 20 desired exposures are 100 ms, 200 ms, 300 ms ... up to 2 seconds. I'm saving the exposure data to a folder (documents) and a sub-folder (white1). Everything looks fine in Camera Control menu while this is running. I see the exposures advancing properly. All data is saved properly. But when I use ImageJ to analyze the saved images I see an unanticipated variation in image intensity. I import this image sequence. I choose an area in the field. Then I plot a z-axis profile of the 20-layer stack. And here's what I see.
And to make matters more confusing to me, I see less erratic data without the time delays.
And here's what happens when I only used a single incidence of the code line that captures single frames.
Any ideas as to what's going on? Are my time delays properly scripted? Is my syntax correct for capturing the sequential exposures without a time delay? SharpCap.SelectedCamera.CaptureSingleFrameTo(Path + str(exposure) + type)
Thanks!
Bob
print SharpCap.Cameras
import time
print time
SharpCap.SelectedCamera = SharpCap.Cameras[0]# Find( lambda x:x.DeviceName == "Test Camera 2 (High Speed)") # edit to grab from your camera
SharpCap.SelectedCamera.Controls.Gain.Value = 383 # Set the gain to 383
Path = "c:\Documents\white1\exposure" # edit this to match your computer folder structure
type = ".png"
exposure_array = [0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2.0] # edit to select exposure
for exposure in exposure_array : # Loop through all exposures
SharpCap.SelectedCamera.Controls.Exposure.Value = exposure # Set the camera exposure
SharpCap.SelectedCamera.CaptureSingleFrameTo(Path + str(exposure) + type) # snap a photo, save in directory and name according to exposure
time.sleep(2)
SharpCap.SelectedCamera.CaptureSingleFrameTo(Path + str(exposure) + type) # repeat added to try to avoid erratic exposures
My 20 desired exposures are 100 ms, 200 ms, 300 ms ... up to 2 seconds. I'm saving the exposure data to a folder (documents) and a sub-folder (white1). Everything looks fine in Camera Control menu while this is running. I see the exposures advancing properly. All data is saved properly. But when I use ImageJ to analyze the saved images I see an unanticipated variation in image intensity. I import this image sequence. I choose an area in the field. Then I plot a z-axis profile of the 20-layer stack. And here's what I see.
And to make matters more confusing to me, I see less erratic data without the time delays.
And here's what happens when I only used a single incidence of the code line that captures single frames.
Any ideas as to what's going on? Are my time delays properly scripted? Is my syntax correct for capturing the sequential exposures without a time delay? SharpCap.SelectedCamera.CaptureSingleFrameTo(Path + str(exposure) + type)
Thanks!
Bob