Ad blocker interference detected!
Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers
Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.
contae.lua v0.11 Raw meter based auto exposure for continuous shooting
This script requires CHDK 1.4.1 or later
The basic idea is the script adjusts exposure after each shot in a continuous sequence to avoid over or under exposure in the next shot.
Fixed a bug that caused exposure to stop increasing when Max ISO was hit, regardless of Max Tv. Thanks udo for the report.
Discussion / Bug reporting thread: http://chdk.setepontos.com/index.php?topic=12696.0
Download v0.11: https://app.box.com/s/yufl1s5of38pk7y8x9zuy5a8oipdugnx
When the script is running, keys like set, up, down, left, right, half shoot are passed to the Canon firmware. Menu exits the script.
When full shoot is pressed, a shooting burst starts. The first shot in the burst uses the exposure set by the Canon firmware, possibly modified by Ev shift options described below. Exposure of subsequent shots in the burst are based on analyzing the raw buffer. The burst continues as long as the shutter is held down. If the camera is not in Canon continuous mode, the shooting is done by simulating holding half press and clicking full press for each shot. The shooting rate in this mode may be similar to, or slower than Canon continuous mode depending on the camera.
If you hold the shutter down while starting the script, it will half shoot and start a burst as soon as it is ready.
The metering is done using an adjustable sized rectangle in the middle of the sensor, and the script normally tries to keep this at the "neutral" value. Additionally, a histogram of the entire sensor is used to limit amount of over and under exposed pixels in the entire scene to user specified ranges.
This is under development and not completed. In particular:
- Doesn't handle aperture adjustments yet. This means the initial aperture value set by the Canon firmware or CHDK overrides will be used for every shot.
- ND filter control is only available on cameras without an adjustable aperture, and the ND value may be inaccurate if the canon firmware did not set the ND filter in for the first exposure.
- There are too many options, and their meanings are not clear.
- Not all Canon controls are passed though.
Earlier development discussion can be found in the script hook development thread: http://chdk.setepontos.com/index.php?topic=11081.msg119265#msg119265
The sequence of images in this box.com folder shows the script in operation, with the debug overlay enabled.
Meter width %Edit
Width of meter area, in percent of active area.
Meter height %Edit
Height of meter area, in percent of active area.
Ever step-th pixel is measured. To sample all colors, it should be odd. To prevent overflow, the total number of pixels (size/step)^2 must be less than unsigned_max / white_level. (~1M for 12 bpp, 250K for 14 bpp). Larger numbers of pixels will be slower.
Max Ev changeEdit
Maximum exposure change in a single step, in fractions of a stop.
Use initial Ev as targetEdit
Use the exposure of the initial shot as the target Ev instead of the pre-defined neutral value.
Shift the target exposure by specified number of stops. If "Use initial Ev as target" is enabled, the shift is applied to the initial value. Otherwise, it is relative to the neutral value.
Max Tv Sec/1000Edit
Longest shutter speed to use, in 1/1000ths of a sec. If required exposure is longer, ISO will be used up to ISO limits.
Min Tv Sec/100KEdit
Shortest shutter speed to use, in 1/100000ths of a sec. If required exposure is shorter, it will be limited to this value.
ISO value to use if shutter limits (described below) not reached. Should normally be lowest ISO. In Canon UI units.
ISO adj TV Sec/1000Edit
Shutter speed (in 1/1000ths of a sec) at which ISO will start to be increased. If the exposure time exceeds this value, exposure will changes are split 50/50 between shutter and ISO, subject to limits below
Absolute max ISO to be used. In Canon UI units.
ND Tv Sec/10000Edit
Shutter speed (in 1/10000ths of a sec) below which ND filter is put in. Ignored on cameras with an adjustable aperture, even if they also have an ND filter. 0 disables.
Meter high thresh EvEdit
Meter value in to start limiting under exposure protection, in stops above neutral. As the meter value exceeds this value, the influence of under exposure protection is reduced.
Meter high limit EvEdit
Maximum meter value allowed from under exposure protection, in stops above neutral.
Meter high max weightEdit
Controls the maximum influence of the meter high limit relative to histogram under exposure. The influence of the meter increases proportional to the square of the fraction by which it exceeds the threshold, such that the max weight value is be reached at the limit Ev. If set to 100 (the standard weight before threshold), this behavior is disabled.
Meter low thresh EvEdit
Meter value to start limiting over-exposure protection, in stops below neutral. As the meter value falls the number of stops specified below neutral, the amount that over exposure protection can reduce exposure is reduced.
Meter low limit EvEdit
Minimum meter value allowed from over exposure protection, in stops below neutral.
Meter high max weightEdit
Controls the maximum influence of the meter high limit relative to histogram over exposure, similar to max weight.
Overexp thresh x/100kEdit
The fraction in parts per 100,000 of pixels that must be near to white level to trigger over exposure protection. 0 Disables over exposure protection. Note: for low values to work, the histogram step (described below) must be set to allow a sufficient number of pixels to be sampled. If the threshold represents less than 10 pixels, are warning is recorded in the log.
Overexp Ev rangeEdit
What fraction of a stop below white level is considered over exposed.
Overexp max weightEdit
Maximum weight for over exposure protection. This controls how far beyond the overexposure threshold the weight continues to increase.
Priority modifier for over exposure protection. If greater than 0, the weight of under exposure and meter driven exposure increases is reduced proportional to the amount of over exposure, such that the "prio" value is subtracted from the weight when overexp thresh is reached.
Underexp thresh x/100kEdit
Similar to overexp thresh above, but for pixels near black level. 0 Disabled under exposure protection.
Number of stops below neutral a value must be to count as underexposed. Pixels with 0-4 shot histogram value are not counted as underexposure, since this usually indicates defective pixels.
Underexp max weightEdit
Maximum weight for under exposure protection, similar to Overexp max weight above.
Priority modifier for under exposure protection, similar to Overexp prio above.
The step between pixels sampled for under / over protection. Smaller values sample more pixels, allowing smaller areas to be detected and lower under/over thresholds to be used, at the expense of increased processing time. On D10 (12 megapixel) a step of 11 samples ~100k pixels, and takes 60-70ms to process, equating to ~1500 pixels/msec.
Draw Debug infoEdit
Draw metering information on the raw buffer. From top to bottom
- A bar near the top of the screen, representing the metered value as a % of white level (log scale), with tick marks at 1 EV intervals. The larger ticks are black level, neutral, white level, and Ev shift if enabled. Yellow and red ticks above the bar show the meter thresh and limit values, respectively.
- A bar showing the change in exposure as a fraction of the max EV change value described below. The origin is at the center, with longer exposure to the right, and shorter exposure to the left.
- A bar extending from left to right, representing % underexposed pixels. Red if above threshold, max at middle of screen.
- A bar extending from right to left, representing % overexposed pixels. Red if above threshold, max at middle of screen.
- A box or reticle around the meter area, controlled by Meter Area option below
Drawing takes adds a small amount to shooting time (e.g. 20 ms on d10.) The log contains this information and much more, but having it in the images makes it easier to see what the code is doing.
Controls whether the metering area is drawn, either just the corners or a box
Gauge Y offset %Edit
Controls the vertical location of the debug info, in % of full resolution jpeg area height. 0 uses a default offset of 80 pixels. Use to make the debug info visible on jpegs with a different aspect ration form the sensor.
If enabled, the log is written to A/contae.csv
- None = do not record a log
- Append = append to existing log
- Replace = replace any existing log
Raw hook sleepEdit
Insert a script sleep just before the raw hook is released. This appears to avoid issues with D10 taking some shots with the shutter closed when debug drawing is not enabled.
Log file descriptionEdit
The log is a CSV with a bunch of columns. Some of the more relevant/useful ones are described below.
sv, tv, avEdit
exposure values for the shot with the image number indicated in the exp column.
Scene brightness. For pre-shoot, this comes from the Canon firmware. Otherwise, calculated from exposure params and meter value.
the average value of the metered area. *96 gives this as an APEX96 value where the target exposure is 0. Negative values indicate an underexposure, positive is overexposure.
Fraction of pixel in the over and under ranges, in percent.
meter_weight, over_weight, underweightEdit
Weights controlling the relative contribution of the meter area, under and over exposure protection to the final exposure change.
exposure change requested for the next shot. Positive values mean more exposure (longer Tv, higher ISO)
various cases in the metering process trigger messages here, e.g if shutter limits hit etc.