Implements YASS-inspired automatic exposure control for IDS uEye cameras.
The intervalometer filter analyzes video brightness in real-time and
smoothly ramps camera exposure and gain settings during changing light
conditions - ideal for sunset/sunrise time-lapse photography.
Key features:
- Automatic exposure ramping (0.85-1.24ms configurable range)
- Automatic gain control (0-52 configurable range)
- Real-time brightness analysis (GRAY8, GRAY16, RGB, BGR, BGRA)
- YASS-inspired ramping algorithm (exposure priority, then gain)
- Configurable ramp rates (VSlow/Slow/Medium/Fast/VFast)
- Exposure compensation (±4 stops)
- CSV logging of exposure parameters
- Direct GObject property control (no message bus overhead)
Technical implementation:
- GstBaseTransform filter for in-place processing
- Discovers upstream camera element by name
- Controls camera via g_object_set() for synchronous updates
- Frame-by-frame brightness calculation with format support
Files added:
- gst/intervalometer/gstintervalometer.c: Main implementation (734 lines)
- gst/intervalometer/gstintervalometer.h: Header with structure definitions
- gst/intervalometer/CMakeLists.txt: Build configuration
- gst/intervalometer/README.md: Comprehensive documentation
Files modified:
- gst/CMakeLists.txt: Added intervalometer subdirectory
- build.ps1: Added intervalometer to build and deployment pipeline
Usage example:
gst-launch-1.0 idsueyesrc name=cam ! \\
intervalometer enabled=true camera-element=cam \\
exposure-min=0.85 exposure-max=1.24 \\
gain-min=0 gain-max=52 ramp-rate=medium ! \\
autovideosink
Inspired by YASS (Yet Another Sunset Script) for CHDK cameras by
waterwingz, based on work by Fbonomi and soulf2.
104 lines
3.5 KiB
C
104 lines
3.5 KiB
C
/* GStreamer
|
|
* Copyright (C) 2024 FIXME <fixme@example.com>
|
|
*
|
|
* This library is free software; you can redistribute it and/or
|
|
* modify it under the terms of the GNU Library General Public
|
|
* License as published by the Free Software Foundation; either
|
|
* version 2 of the License, or (at your option) any later version.
|
|
*
|
|
* This library is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
* Library General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU Library General Public
|
|
* License along with this library; if not, write to the
|
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
* Boston, MA 02111-1307, USA.
|
|
*/
|
|
|
|
#ifndef __GST_INTERVALOMETER_H__
|
|
#define __GST_INTERVALOMETER_H__
|
|
|
|
#include <stdio.h>
|
|
#include <gst/base/gstbasetransform.h>
|
|
#include <gst/video/video.h>
|
|
|
|
G_BEGIN_DECLS
|
|
|
|
#define GST_TYPE_INTERVALOMETER \
|
|
(gst_intervalometer_get_type())
|
|
#define GST_INTERVALOMETER(obj) \
|
|
(G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_INTERVALOMETER,GstIntervalometer))
|
|
#define GST_INTERVALOMETER_CLASS(klass) \
|
|
(G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_INTERVALOMETER,GstIntervalometerClass))
|
|
#define GST_IS_INTERVALOMETER(obj) \
|
|
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_INTERVALOMETER))
|
|
#define GST_IS_INTERVALOMETER_CLASS(klass) \
|
|
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_INTERVALOMETER))
|
|
|
|
typedef struct _GstIntervalometer GstIntervalometer;
|
|
typedef struct _GstIntervalometerClass GstIntervalometerClass;
|
|
|
|
typedef enum {
|
|
RAMP_RATE_VSLOW = 0,
|
|
RAMP_RATE_SLOW,
|
|
RAMP_RATE_MEDIUM,
|
|
RAMP_RATE_FAST,
|
|
RAMP_RATE_VFAST
|
|
} GstIntervalometerRampRate;
|
|
|
|
/**
|
|
* GstIntervalometer:
|
|
* @element: the parent element.
|
|
*
|
|
* Auto-exposure controller for IDS uEye cameras.
|
|
* Inspired by YASS (Yet Another Sunset Script) for CHDK cameras.
|
|
*/
|
|
struct _GstIntervalometer
|
|
{
|
|
GstBaseTransform element;
|
|
|
|
/* Properties */
|
|
gboolean enabled;
|
|
gdouble target_brightness; /* Target average brightness (0-255) */
|
|
gdouble compensation; /* Exposure compensation in stops */
|
|
gdouble exposure_min; /* Minimum exposure in ms */
|
|
gdouble exposure_max; /* Maximum exposure in ms */
|
|
gint gain_min; /* Minimum gain (0-100) */
|
|
gint gain_max; /* Maximum gain (0-100) */
|
|
GstIntervalometerRampRate ramp_rate;
|
|
gchar *log_file; /* CSV log file path */
|
|
gchar *camera_element_name; /* Name of upstream idsueyesrc element */
|
|
|
|
/* Internal state */
|
|
GstElement *camera_src; /* Reference to upstream camera element */
|
|
gdouble current_exposure; /* Current exposure setting */
|
|
gint current_gain; /* Current gain setting */
|
|
gdouble target_exposure; /* Target exposure for ramping */
|
|
gint target_gain; /* Target gain for ramping */
|
|
|
|
guint64 frame_count; /* Number of frames processed */
|
|
GstClockTime start_time; /* Time when processing started */
|
|
|
|
FILE *log_fp; /* Log file handle */
|
|
gboolean log_header_written; /* Whether CSV header has been written */
|
|
|
|
/* Video info */
|
|
GstVideoInfo video_info;
|
|
gboolean video_info_valid;
|
|
|
|
/* Ramping parameters */
|
|
gdouble ramp_step; /* Current ramping step size */
|
|
};
|
|
|
|
struct _GstIntervalometerClass
|
|
{
|
|
GstBaseTransformClass parent_class;
|
|
};
|
|
|
|
GType gst_intervalometer_get_type(void);
|
|
|
|
G_END_DECLS
|
|
|
|
#endif /* __GST_INTERVALOMETER_H__ */ |