Compare commits
5 Commits
312972d0c6
...
89f904cd71
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
89f904cd71 | ||
|
|
a81587e8c6 | ||
|
|
d2c1030354 | ||
|
|
45fa4c07b4 | ||
|
|
93d8da45e6 |
20
README.md
20
README.md
@@ -35,7 +35,7 @@ udpsink host=10.81.2.183 port=5000
|
||||
now moving to automatic exposure (see [gstintervalometer](gst\intervalometer\gstintervalometer.c))
|
||||
```pwsh
|
||||
uv run .\scripts\launch-ids.py `
|
||||
--config .\ini\2456x4pix-500top-cw.ini `
|
||||
--config .\ini\2456x4pix-500top-cw-extragain.ini `
|
||||
--device-id 1 `
|
||||
--framerate 750 `
|
||||
--gain 52 `
|
||||
@@ -49,11 +49,27 @@ uv run .\scripts\launch-ids.py `
|
||||
intervalometer enabled=true camera-element=cam `
|
||||
ramp-rate=vslow `
|
||||
update-interval=1000 `
|
||||
gain-ma52 `
|
||||
gain=52 `
|
||||
log-file=timelapse.csv ! `
|
||||
videocrop bottom=3 ! queue ! udpsink host=10.81.2.183 port=5000
|
||||
```
|
||||
|
||||
```pwsh
|
||||
$env:GST_DEBUG="linescan:5";
|
||||
|
||||
gst-launch-1.0 idsueyesrc config-file=ini/roi-night.ini `
|
||||
exposure=5.25 framerate=200 gain=42 name=cam device-id=2 ! `
|
||||
intervalometer enabled=true camera-element=cam `
|
||||
ramp-rate=vslow `
|
||||
update-interval=1000 `
|
||||
gain-max=52 `
|
||||
log-file=timelapse.csv ! `
|
||||
videocrop bottom=3 ! `
|
||||
queue ! `
|
||||
linescan direction=vertical output-size=1900 ! `
|
||||
videoconvert ! autovideosink
|
||||
```
|
||||
|
||||
#### Receive and Display
|
||||
```pwsh
|
||||
uv run .\scripts\recv_raw_rolling.py --display-fps 60
|
||||
|
||||
@@ -73,6 +73,7 @@ make install
|
||||
| Property | Type | Range | Default | Description |
|
||||
|----------|------|-------|---------|-------------|
|
||||
| `brightness-smoothing` | double | 0.0-1.0 | 0.1 | Temporal smoothing factor (EMA alpha) |
|
||||
| `brightness-deadband` | double | 0.0-50.0 | 10.0 | Deadband zone to prevent oscillation (0=disabled) |
|
||||
|
||||
### Logging
|
||||
|
||||
@@ -138,6 +139,7 @@ gst-launch-1.0 \
|
||||
ramp-rate=vslow \
|
||||
update-interval=1000 \
|
||||
brightness-smoothing=0.1 \
|
||||
brightness-deadband=10.0 \
|
||||
log-file=timelapse.csv ! \
|
||||
videocrop bottom=3 ! queue ! videoconvert ! autovideosink
|
||||
```
|
||||
@@ -146,6 +148,7 @@ gst-launch-1.0 \
|
||||
- `ramp-rate=vslow`: 5% exposure steps per update (smooth transitions)
|
||||
- `update-interval=1000`: Updates every 1 second (not too aggressive)
|
||||
- `brightness-smoothing=0.1`: Filters out moving objects (cars, people, birds)
|
||||
- `brightness-deadband=10.0`: Prevents oscillation by creating a stable zone
|
||||
|
||||
### Complete Time-Lapse Recording
|
||||
|
||||
@@ -166,14 +169,15 @@ gst-launch-1.0 idsueyesrc name=cam framerate=1 ! \
|
||||
|
||||
### Exposure Control Algorithm
|
||||
|
||||
The filter uses a YASS-inspired algorithm:
|
||||
The filter uses a YASS-inspired algorithm with deadband control:
|
||||
|
||||
1. **Brightness Analysis**: Calculates average brightness of each frame
|
||||
2. **Error Calculation**: Compares to target brightness (with compensation)
|
||||
3. **Ramping Priority**:
|
||||
2. **Deadband Check**: If brightness is within deadband zone, skip adjustments (prevents oscillation)
|
||||
3. **Error Calculation**: Compares to target brightness (with compensation)
|
||||
4. **Ramping Priority**:
|
||||
- When too bright: Decreases exposure first, then gain
|
||||
- When too dark: Increases exposure first (up to max), then gain
|
||||
4. **Smooth Ramping**: Changes are gradual based on ramp-rate setting
|
||||
5. **Smooth Ramping**: Changes are gradual based on ramp-rate setting
|
||||
|
||||
### Typical Behavior
|
||||
|
||||
@@ -246,6 +250,29 @@ smoothed_brightness = (alpha × current_brightness) + ((1 - alpha) × previous_s
|
||||
|
||||
**Effect:** With `brightness-smoothing=0.1`, the algorithm effectively averages brightness over ~10 frames, filtering out cars, people, and birds while still tracking slow lighting trends.
|
||||
|
||||
### Brightness Deadband
|
||||
|
||||
The `brightness-deadband` property creates a tolerance zone around the target brightness where no adjustments are made. This prevents oscillation caused by continuous micro-adjustments.
|
||||
|
||||
**How it works:**
|
||||
- When brightness is within ±deadband of target, no changes are made
|
||||
- When brightness exceeds the deadband, normal adjustments resume
|
||||
- Allows fast corrections when needed, prevents hunting when stable
|
||||
|
||||
| Value | Behavior | Best For |
|
||||
|-------|----------|----------|
|
||||
| 0.0 | No deadband (disabled) | Maximum responsiveness (may oscillate) |
|
||||
| 5.0 | Narrow deadband | Slow update rates (>500ms) |
|
||||
| **10.0** | **Standard deadband (default)** | **Fast update rates (10-100ms), prevents oscillation** |
|
||||
| 20.0 | Wide deadband | Very stable, less responsive |
|
||||
|
||||
**Example:**
|
||||
- With `target-brightness=128` and `brightness-deadband=10.0`
|
||||
- No adjustments when brightness is between 118-138
|
||||
- Adjustments resume when brightness < 118 or > 138
|
||||
|
||||
**Important:** Higher deadband = more stability but less precision. Lower deadband = more precision but potential oscillation at fast update rates.
|
||||
|
||||
## Tips for Best Results
|
||||
|
||||
### Dawn/Dusk Time-Lapse (Recommended Configuration)
|
||||
@@ -254,6 +281,7 @@ smoothed_brightness = (alpha × current_brightness) + ((1 - alpha) × previous_s
|
||||
ramp-rate: vslow (5% steps - very gradual)
|
||||
update-interval: 1000 (1 second between updates)
|
||||
brightness-smoothing: 0.1 (filter moving objects)
|
||||
brightness-deadband: 10.0 (prevent oscillation)
|
||||
exposure-min: 0.85 (or camera minimum)
|
||||
exposure-max: 1.24 (or 1/framerate)
|
||||
gain-min: 0 (cleanest image)
|
||||
@@ -267,15 +295,18 @@ target-brightness: 128
|
||||
- Brightness smoothing filters transient changes (cars, people)
|
||||
- Results in smooth, flicker-free time-lapse
|
||||
|
||||
### Fast Changing Conditions
|
||||
### Fast Changing Conditions (with Fast Update Rates)
|
||||
|
||||
```
|
||||
ramp-rate: fast or vfast
|
||||
update-interval: 100-500
|
||||
update-interval: 10-100 (very fast updates)
|
||||
brightness-smoothing: 0.3-1.0 (more responsive)
|
||||
brightness-deadband: 10.0-15.0 (ESSENTIAL to prevent oscillation)
|
||||
compensation: Adjust to preference (-1.0 for darker, +1.0 for brighter)
|
||||
```
|
||||
|
||||
**Critical:** When using fast update rates (10-100ms), `brightness-deadband` is ESSENTIAL to prevent oscillation. Without it, the algorithm will continuously overshoot and create flickering.
|
||||
|
||||
### Maximum Image Quality
|
||||
|
||||
```
|
||||
@@ -284,13 +315,15 @@ ramp-rate: slow or vslow (smoother transitions)
|
||||
update-interval: 1000-2000
|
||||
```
|
||||
|
||||
### Avoiding Flickering
|
||||
### Avoiding Flickering and Oscillation
|
||||
|
||||
If you experience flickering or oscillation:
|
||||
1. **Increase update-interval**: Start with 1000ms
|
||||
2. **Decrease ramp-rate**: Use `vslow` or `slow`
|
||||
3. **Enable brightness-smoothing**: Set to 0.1 or lower
|
||||
4. **Check your settings**: At 50fps, 100ms updates = every 5 frames (too fast!)
|
||||
1. **Enable deadband (MOST IMPORTANT)**: Set `brightness-deadband=10.0` or higher
|
||||
2. **Increase update-interval**: Start with 1000ms for slow changes, or keep at 10-100ms with deadband for fast response
|
||||
3. **Decrease ramp-rate**: Use `vslow` or `slow`
|
||||
4. **Enable brightness-smoothing**: Set to 0.1 or lower
|
||||
|
||||
**The New Solution:** With the `brightness-deadband` parameter, you can now use fast update rates (10ms) with fast ramp rates without oscillation! The deadband creates a stable zone that prevents continuous micro-adjustments.
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
@@ -300,10 +333,11 @@ If you experience flickering or oscillation:
|
||||
- Ensure `enabled=true` is set
|
||||
|
||||
**Flickering or oscillating exposure:**
|
||||
- **Primary cause:** Update interval too fast for your frame rate
|
||||
- **Solution:** Increase `update-interval` to 1000ms
|
||||
- **Primary cause:** No deadband zone at fast update rates
|
||||
- **Solution:** Set `brightness-deadband=10.0` (or higher)
|
||||
- **Alternative:** Increase `update-interval` to 1000ms
|
||||
- **Also try:** Set `ramp-rate=vslow` and `brightness-smoothing=0.1`
|
||||
- **At 50fps:** Never use update intervals < 500ms
|
||||
- **New capability:** With deadband enabled, you CAN use fast update intervals (10-100ms) for rapid response without oscillation!
|
||||
|
||||
**Changes too fast/slow:**
|
||||
- Adjust `ramp-rate` property
|
||||
@@ -359,6 +393,18 @@ The original implementation used GObject property specs to query exposure limits
|
||||
|
||||
Added Exponential Moving Average (EMA) filtering to handle transient brightness changes from moving objects (cars, people, birds). This prevents exposure oscillation while maintaining responsiveness to actual lighting changes.
|
||||
|
||||
### Brightness Deadband (Anti-Oscillation)
|
||||
|
||||
Added deadband control to prevent continuous micro-adjustments that cause oscillation. When brightness is within the deadband zone (default ±10 units), no adjustments are made. This allows:
|
||||
- Fast update rates (10-100ms) without oscillation
|
||||
- Rapid response when changes exceed deadband
|
||||
- Stable operation at any ramp rate
|
||||
|
||||
**Implementation in [`gstintervalometer.c:698-707`](gst/intervalometer/gstintervalometer.c:698-707):**
|
||||
- Checks absolute error against deadband before making adjustments
|
||||
- Skips exposure/gain changes when within tolerance
|
||||
- Allows full-speed corrections when brightness significantly deviates
|
||||
|
||||
## License
|
||||
|
||||
This filter is part of gst-plugins-vision and released under the GNU Library General Public License (LGPL).
|
||||
|
||||
@@ -62,7 +62,8 @@ enum
|
||||
PROP_LOG_FILE,
|
||||
PROP_CAMERA_ELEMENT,
|
||||
PROP_UPDATE_INTERVAL,
|
||||
PROP_BRIGHTNESS_SMOOTHING
|
||||
PROP_BRIGHTNESS_SMOOTHING,
|
||||
PROP_BRIGHTNESS_DEADBAND
|
||||
};
|
||||
|
||||
#define DEFAULT_PROP_ENABLED TRUE
|
||||
@@ -77,6 +78,7 @@ enum
|
||||
#define DEFAULT_PROP_CAMERA_ELEMENT ""
|
||||
#define DEFAULT_PROP_UPDATE_INTERVAL 100 /* Update every 100ms (10 Hz) */
|
||||
#define DEFAULT_PROP_BRIGHTNESS_SMOOTHING 0.1 /* 10% new, 90% history - heavy smoothing for time-lapse */
|
||||
#define DEFAULT_PROP_BRIGHTNESS_DEADBAND 10.0 /* ±10 brightness units deadband zone */
|
||||
|
||||
/* GStreamer boilerplate */
|
||||
#define gst_intervalometer_parent_class parent_class
|
||||
@@ -242,6 +244,14 @@ gst_intervalometer_class_init (GstIntervalometerClass * klass)
|
||||
0.0, 1.0, DEFAULT_PROP_BRIGHTNESS_SMOOTHING,
|
||||
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
||||
|
||||
g_object_class_install_property (gobject_class, PROP_BRIGHTNESS_DEADBAND,
|
||||
g_param_spec_double ("brightness-deadband", "Brightness Deadband",
|
||||
"Deadband zone around target brightness where no adjustments are made (0=disabled). "
|
||||
"Creates a stable zone to prevent oscillation. "
|
||||
"Recommended: 10.0 for fast update rates, 5.0 for slower rates, 0.0 to disable",
|
||||
0.0, 50.0, DEFAULT_PROP_BRIGHTNESS_DEADBAND,
|
||||
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
||||
|
||||
/* Set element metadata */
|
||||
gst_element_class_add_pad_template (gstelement_class,
|
||||
gst_static_pad_template_get (&gst_intervalometer_sink_template));
|
||||
@@ -278,6 +288,7 @@ gst_intervalometer_init (GstIntervalometer * filter)
|
||||
filter->camera_element_name = g_strdup (DEFAULT_PROP_CAMERA_ELEMENT);
|
||||
filter->update_interval = DEFAULT_PROP_UPDATE_INTERVAL;
|
||||
filter->brightness_smoothing = DEFAULT_PROP_BRIGHTNESS_SMOOTHING;
|
||||
filter->brightness_deadband = DEFAULT_PROP_BRIGHTNESS_DEADBAND;
|
||||
|
||||
/* Initialize internal state */
|
||||
filter->camera_src = NULL;
|
||||
@@ -350,6 +361,9 @@ gst_intervalometer_set_property (GObject * object, guint prop_id,
|
||||
case PROP_BRIGHTNESS_SMOOTHING:
|
||||
filter->brightness_smoothing = g_value_get_double (value);
|
||||
break;
|
||||
case PROP_BRIGHTNESS_DEADBAND:
|
||||
filter->brightness_deadband = g_value_get_double (value);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
@@ -399,6 +413,9 @@ gst_intervalometer_get_property (GObject * object, guint prop_id,
|
||||
case PROP_BRIGHTNESS_SMOOTHING:
|
||||
g_value_set_double (value, filter->brightness_smoothing);
|
||||
break;
|
||||
case PROP_BRIGHTNESS_DEADBAND:
|
||||
g_value_set_double (value, filter->brightness_deadband);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
@@ -690,6 +707,7 @@ gst_intervalometer_update_camera_settings (GstIntervalometer * filter,
|
||||
{
|
||||
gdouble error, adjusted_target, exposure_range, gain_range;
|
||||
gdouble ramp_multiplier;
|
||||
gdouble abs_error;
|
||||
|
||||
if (!filter->camera_src) {
|
||||
return;
|
||||
@@ -699,6 +717,14 @@ gst_intervalometer_update_camera_settings (GstIntervalometer * filter,
|
||||
error = (filter->target_brightness - brightness) *
|
||||
pow (2.0, filter->compensation);
|
||||
|
||||
/* Check deadband zone - if enabled and brightness is within tolerance, skip adjustments */
|
||||
abs_error = fabs(filter->target_brightness - brightness);
|
||||
if (filter->brightness_deadband > 0.0 && abs_error < filter->brightness_deadband) {
|
||||
GST_DEBUG_OBJECT (filter, "Within deadband zone (error=%.2f < %.2f), skipping adjustment",
|
||||
abs_error, filter->brightness_deadband);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Adjust target brightness based on error */
|
||||
adjusted_target = filter->target_brightness + error;
|
||||
|
||||
|
||||
@@ -75,6 +75,7 @@ struct _GstIntervalometer
|
||||
gchar *camera_element_name; /* Name of upstream idsueyesrc element */
|
||||
guint update_interval; /* Update interval in milliseconds */
|
||||
gdouble brightness_smoothing; /* Brightness smoothing factor (0-1, 0=no smoothing) */
|
||||
gdouble brightness_deadband; /* Deadband zone to prevent oscillation (0=disabled) */
|
||||
|
||||
/* Internal state */
|
||||
GstElement *camera_src; /* Reference to upstream camera element */
|
||||
|
||||
@@ -64,13 +64,6 @@
|
||||
#
|
||||
# Troubleshooting:
|
||||
#
|
||||
# Error: "unknown signal name: rollover"
|
||||
# - Cause: Linescan plugin not found or not properly registered with GStreamer
|
||||
# - Solution:
|
||||
# 1. Build plugins: .\build.ps1
|
||||
# 2. Ensure GST_PLUGIN_PATH environment variable includes build output directory
|
||||
# 3. Check plugin was built: look for linescan.dll in build directory
|
||||
# 4. Test plugin availability: gst-inspect-1.0 linescan
|
||||
#
|
||||
# Error: "No such element 'linescan'" or "No such element 'idsueyesrc'"
|
||||
# - Cause: Custom plugins not found in GST_PLUGIN_PATH
|
||||
@@ -79,10 +72,6 @@
|
||||
# 2. Set GST_PLUGIN_PATH to include the build directory
|
||||
# 3. Run: gst-inspect-1.0 --print-plugin-auto-install-info to check plugins
|
||||
#
|
||||
# Error: "Not all elements could be created"
|
||||
# - Cause: Missing GStreamer plugins or dependencies
|
||||
# - Solution: Check that all required plugins are built and GStreamer is properly installed
|
||||
#
|
||||
# Performance Notes:
|
||||
# - Files are saved via Python/PIL in the rollover callback (only when buffer wraps)
|
||||
# - The display shows the live linescan accumulation
|
||||
@@ -169,7 +158,7 @@ def on_rollover(linescan, buffer):
|
||||
# Map the buffer to get image data
|
||||
success, mapinfo = buffer.map(Gst.MapFlags.READ)
|
||||
if not success:
|
||||
# print(f"[ROLLOVER ERROR] Failed to map buffer for frame {frame_counter}")
|
||||
print(f"[ROLLOVER ERROR] Failed to map buffer for frame {frame_counter}")
|
||||
return
|
||||
|
||||
try:
|
||||
@@ -208,7 +197,7 @@ def on_rollover(linescan, buffer):
|
||||
else:
|
||||
img.save(filename, 'JPEG', quality=95)
|
||||
|
||||
print(f"[ROLLOVER] Frame {frame_counter} saved to: {filename}")
|
||||
# print(f"[ROLLOVER] Frame {frame_counter} saved to: {filename}")
|
||||
|
||||
except Exception as e:
|
||||
print(f"[ROLLOVER ERROR] Failed to save frame {frame_counter}: {e}")
|
||||
@@ -261,7 +250,7 @@ Examples:
|
||||
parser.add_argument('--output-dir', '-o', metavar='DIR',
|
||||
help='Output directory (default: results/<date>/<funny-name>)')
|
||||
parser.add_argument('--mode', '-m', choices=['day', 'night'], default='day',
|
||||
help='Camera mode: day (0.4ms exposure, 0 gain) or night (5.25ms exposure, 65 gain) (default: day)')
|
||||
help='Camera mode: day (0.2ms exposure, 0 gain) or night (5.25ms exposure, 65 gain) (default: day)')
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
@@ -395,10 +384,12 @@ Examples:
|
||||
|
||||
# Configure intervalometer
|
||||
intervalometer.set_property("enabled", True)
|
||||
intervalometer.set_property("camera-element", source)
|
||||
intervalometer.set_property("ramp-rate", "vslow")
|
||||
intervalometer.set_property("update-interval", 1000)
|
||||
intervalometer.set_property("gain-max", 65)
|
||||
intervalometer.set_property("camera-element", "source")
|
||||
intervalometer.set_property("ramp-rate", "slow")
|
||||
intervalometer.set_property("update-interval", 500)
|
||||
intervalometer.set_property("brightness-deadband", 10.0)
|
||||
intervalometer.set_property("gain-max", 82)
|
||||
intervalometer.set_property("target-brightness", 80.0)
|
||||
intervalometer.set_property("log-file", "timelapse.csv")
|
||||
|
||||
# Configure videocrop
|
||||
|
||||
@@ -1,18 +1,49 @@
|
||||
# Pipeline with tee to display and save frames on rollover
|
||||
# Linescan Pipeline Launcher
|
||||
# Simple wrapper around launch-ids.py with sensible defaults
|
||||
# Run from workspace root: c:\dev\gst-plugins-vision
|
||||
# Or adjust the config-file path below
|
||||
|
||||
param(
|
||||
[Parameter(Position=0)]
|
||||
[ValidateSet('day', 'night')]
|
||||
[string]$Mode = 'day',
|
||||
|
||||
[switch]$Help
|
||||
)
|
||||
|
||||
if ($Help) {
|
||||
Write-Host @"
|
||||
Linescan Pipeline Launcher
|
||||
|
||||
Usage: .\launch_linescan.ps1 [day|night] [-Help]
|
||||
|
||||
Modes:
|
||||
day - Day mode: exposure=0.2ms, gain=0, framerate=200fps (default)
|
||||
night - Night mode: exposure=5.25ms, gain=65, framerate=200fps
|
||||
|
||||
All settings are configured in launch-ids.py with these defaults:
|
||||
- Config: ini/roi-night.ini
|
||||
- Device ID: 1
|
||||
- Intervalometer: enabled
|
||||
- Ramp rate: fast
|
||||
- Update interval: 500ms
|
||||
- Brightness deadband: 10.0
|
||||
- Gain max: 82
|
||||
- Target brightness: 80
|
||||
- Log file: timelapse.csv
|
||||
|
||||
Examples:
|
||||
.\launch_linescan.ps1 # Run in day mode (default)
|
||||
.\launch_linescan.ps1 day # Run in day mode (explicit)
|
||||
.\launch_linescan.ps1 night # Run in night mode
|
||||
.\launch_linescan.ps1 -Help # Show this help
|
||||
"@
|
||||
exit 0
|
||||
}
|
||||
|
||||
$env:GST_DEBUG="linescan:5"
|
||||
|
||||
# Note: Run this from the workspace root (c:\dev\gst-plugins-vision)
|
||||
# If running from gst/linescan/, use: config-file=../../ini/roi-night.ini
|
||||
uv run .\scripts\launch-ids.py `
|
||||
--config .\ini\2456x4pix-500top-cw-extragain.ini `
|
||||
--device-id 1 `
|
||||
--framerate 750 `
|
||||
--gain 0 `
|
||||
--gain-boost `
|
||||
--exposure 0.04 `
|
||||
--host 10.81.2.183 `
|
||||
--port 5000 `
|
||||
--control-port 5001
|
||||
Write-Host "Launching linescan pipeline in $Mode mode..."
|
||||
Write-Host ""
|
||||
|
||||
# All configuration is handled by launch-ids.py defaults
|
||||
uv run .\scripts\launch-ids.py --mode $Mode
|
||||
@@ -17,6 +17,9 @@
|
||||
# Basic Usage:
|
||||
# uv run .\scripts\launch-ids.py # Use all defaults
|
||||
# uv run .\scripts\launch-ids.py --help # Show all options
|
||||
# uv run .\scripts\launch-ids.py --mode day # Day mode preset (0.2ms, 0 gain)
|
||||
# uv run .\scripts\launch-ids.py --mode night # Night mode preset (5.25ms, 65 gain)
|
||||
# uv run .\scripts\launch-ids.py --intervalometer # Enable auto-exposure control
|
||||
# uv run .\scripts\launch-ids.py exposure 16 # Set exposure to 16ms (simplified)
|
||||
# uv run .\scripts\launch-ids.py framerate 30 # Set framerate to 30fps (simplified)
|
||||
# uv run .\scripts\launch-ids.py gain 50 # Set gain to 50 (simplified)
|
||||
@@ -26,7 +29,7 @@
|
||||
# uv run .\scripts\launch-ids.py --display # Enable 1/4 sized preview window
|
||||
#
|
||||
# Features:
|
||||
# - Configurable video streaming (default: UDP port 5000 to 127.0.0.1)
|
||||
# - Configurable video streaming (default: UDP port 5000 to 10.81.2.183)
|
||||
# - Optional control interface (default: UDP port 5001 on 0.0.0.0)
|
||||
# - Dynamic exposure control (0.015-30000 milliseconds, default: 10ms)
|
||||
# - Auto-exposure mode support (--auto-exposure flag)
|
||||
@@ -510,6 +513,9 @@ def parse_arguments():
|
||||
epilog="""
|
||||
Examples:
|
||||
%(prog)s # Use all defaults
|
||||
%(prog)s --mode day # Day mode (0.2ms, 0 gain)
|
||||
%(prog)s --mode night # Night mode (5.25ms, 65 gain)
|
||||
%(prog)s --mode day --intervalometer # Day mode with auto-exposure
|
||||
%(prog)s exposure 16 # Set exposure to 16ms
|
||||
%(prog)s framerate 30 # Set framerate to 30fps
|
||||
%(prog)s gain 50 # Set gain to 50
|
||||
@@ -532,12 +538,34 @@ Examples:
|
||||
nargs='?',
|
||||
help='Value to set for the property (simplified syntax)')
|
||||
|
||||
# Mode selection
|
||||
mode_group = parser.add_argument_group('Mode Selection')
|
||||
mode_group.add_argument(
|
||||
'--mode', '-m',
|
||||
choices=['day', 'night'],
|
||||
default='day',
|
||||
help='Camera mode preset: day (0.2ms exposure, 0 gain, 200fps) or night (5.25ms exposure, 65 gain, 200fps)'
|
||||
)
|
||||
mode_group.add_argument(
|
||||
'--intervalometer',
|
||||
dest='intervalometer',
|
||||
action='store_true',
|
||||
default=True,
|
||||
help='Enable intervalometer for automatic exposure control (enabled by default)'
|
||||
)
|
||||
mode_group.add_argument(
|
||||
'--no-intervalometer',
|
||||
dest='intervalometer',
|
||||
action='store_false',
|
||||
help='Disable intervalometer'
|
||||
)
|
||||
|
||||
# Camera configuration
|
||||
camera_group = parser.add_argument_group('Camera Settings')
|
||||
camera_group.add_argument(
|
||||
'--config', '--config-file',
|
||||
type=str,
|
||||
default='ini/100fps-10exp-2456x4pix-500top-cw-extragain.ini',
|
||||
default='ini/2456x4pix-500top-cw-extragain.ini',
|
||||
metavar='PATH',
|
||||
help='Camera configuration file path'
|
||||
)
|
||||
@@ -565,7 +593,7 @@ Examples:
|
||||
camera_group.add_argument(
|
||||
'--device-id',
|
||||
type=int,
|
||||
default=0,
|
||||
default=1,
|
||||
metavar='ID',
|
||||
help='Device ID (system enumeration, 0 is first, 0-254)'
|
||||
)
|
||||
@@ -624,7 +652,7 @@ Examples:
|
||||
network_group.add_argument(
|
||||
'--host', '--udp-host',
|
||||
type=str,
|
||||
default='127.0.0.1',
|
||||
default='10.81.2.183',
|
||||
metavar='IP',
|
||||
help='UDP streaming destination host'
|
||||
)
|
||||
@@ -704,6 +732,22 @@ Examples:
|
||||
elif args.property and not args.value:
|
||||
parser.error(f"Property '{args.property}' requires a value")
|
||||
|
||||
# Handle mode presets (day is default)
|
||||
if args.mode == 'day':
|
||||
if args.exposure is None:
|
||||
args.exposure = 0.2
|
||||
if args.gain is None:
|
||||
args.gain = 0
|
||||
if args.framerate is None:
|
||||
args.framerate = 200
|
||||
elif args.mode == 'night':
|
||||
if args.exposure is None:
|
||||
args.exposure = 5.25
|
||||
if args.gain is None:
|
||||
args.gain = 65
|
||||
if args.framerate is None:
|
||||
args.framerate = 200
|
||||
|
||||
# Validation - only validate if provided
|
||||
if args.exposure is not None and (args.exposure < 0.015 or args.exposure > 30000):
|
||||
parser.error(f"Exposure must be between 0.015 and 30000 ms, got {args.exposure}")
|
||||
@@ -795,8 +839,30 @@ if args.auto_gain:
|
||||
if args.gain_boost:
|
||||
src.set_property("gain-boost", True)
|
||||
|
||||
# Video crop to remove bottom pixels (if enabled)
|
||||
# Build pipeline elements list
|
||||
elements_to_link = [src]
|
||||
|
||||
# Add intervalometer if enabled
|
||||
if args.intervalometer:
|
||||
intervalometer = Gst.ElementFactory.make("intervalometer", "intervalometer")
|
||||
if not intervalometer:
|
||||
print("ERROR: Could not create intervalometer element")
|
||||
print("Make sure the intervalometer plugin is built and in GST_PLUGIN_PATH")
|
||||
exit(1)
|
||||
|
||||
# Configure intervalometer
|
||||
intervalometer.set_property("enabled", True)
|
||||
intervalometer.set_property("camera-element", "src")
|
||||
intervalometer.set_property("ramp-rate", "slow")
|
||||
intervalometer.set_property("update-interval", 500)
|
||||
intervalometer.set_property("brightness-deadband", 10.0)
|
||||
intervalometer.set_property("gain-max", 82)
|
||||
intervalometer.set_property("target-brightness", 80.0)
|
||||
intervalometer.set_property("log-file", "timelapse.csv")
|
||||
|
||||
elements_to_link.append(intervalometer)
|
||||
|
||||
# Video crop to remove bottom pixels (if enabled)
|
||||
if args.crop_bottom > 0:
|
||||
videocrop = Gst.ElementFactory.make("videocrop", "crop")
|
||||
videocrop.set_property("bottom", args.crop_bottom)
|
||||
@@ -933,6 +999,8 @@ if not args.quiet:
|
||||
print("=" * 60)
|
||||
print("IDS uEye Camera - Pipeline Configuration")
|
||||
print("=" * 60)
|
||||
if args.mode:
|
||||
print(f"Mode: {args.mode}")
|
||||
print(f"Camera config: {args.config}")
|
||||
print(f"Camera ID: {args.camera_id}")
|
||||
print(f"Device ID: {args.device_id}")
|
||||
@@ -951,6 +1019,15 @@ if not args.quiet:
|
||||
print(f"Auto-exposure: {'enabled' if args.auto_exposure else '(from INI file)'}")
|
||||
print(f"Auto-gain: {'enabled' if args.auto_gain else '(from INI file)'}")
|
||||
print(f"Gain boost: {'enabled' if args.gain_boost else '(from INI file)'}")
|
||||
if args.intervalometer:
|
||||
print()
|
||||
print("Intervalometer: enabled")
|
||||
print(" Ramp rate: slow")
|
||||
print(" Update int: 500 ms")
|
||||
print(" Deadband: 10.0")
|
||||
print(" Gain max: 82")
|
||||
print(" Target bright: 80")
|
||||
print(" Log file: timelapse.csv")
|
||||
if args.crop_bottom > 0:
|
||||
print(f"Crop bottom: {args.crop_bottom} pixels")
|
||||
else:
|
||||
|
||||
Reference in New Issue
Block a user