feat: adapt linescan scripts to use uv and proper rollover-based file saving

- Updated launch_with_signal.py with PEP 723 metadata for uv compatibility
- Added day/night mode presets with command-line arguments
- Implemented proper rollover-only file saving via Python/PIL callbacks
- Removed multifilesink from pipeline (was saving every frame incorrectly)
- Added funny auto-generated output directory names (e.g., fuzzy-photon)
- Updated rollover_example.py to follow same pattern with uv support
- Updated rollover_example.c to demonstrate signal detection without file saving
- Updated launch_with_capture.ps1 to remove incorrect multifilesink usage
- All scripts now save files ONLY on rollover events, not every frame
- Pipeline simplified: camera -> linescan -> display (files saved in callback)
This commit is contained in:
yair
2025-11-18 19:39:51 +02:00
parent f5202203af
commit a7a776fb58
7 changed files with 1032 additions and 1 deletions

View File

@@ -46,6 +46,15 @@
GST_DEBUG_CATEGORY_STATIC (gst_linescan_debug);
#define GST_CAT_DEFAULT gst_linescan_debug
/* Signals */
enum
{
SIGNAL_ROLLOVER,
LAST_SIGNAL
};
static guint gst_linescan_signals[LAST_SIGNAL] = { 0 };
/* Properties */
enum
{
@@ -156,6 +165,22 @@ gst_linescan_class_init (GstLinescanClass * klass)
1, G_MAXINT, DEFAULT_PROP_OUTPUT_SIZE,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
/* Install signals */
/**
* GstLinescan::rollover:
* @linescan: the linescan instance
* @buffer: the completed buffer at rollover
*
* Emitted when the buffer position wraps around to 0 after accumulating
* output_size lines. The buffer contains a complete line scan image.
* Applications can connect to this signal to save the image to disk.
*/
gst_linescan_signals[SIGNAL_ROLLOVER] =
g_signal_new ("rollover", G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (GstLinescanClass, rollover),
NULL, NULL, g_cclosure_marshal_VOID__BOXED,
G_TYPE_NONE, 1, GST_TYPE_BUFFER);
/* Set element metadata */
gst_element_class_add_pad_template (gstelement_class,
gst_static_pad_template_get (&gst_linescan_sink_template));
@@ -580,14 +605,17 @@ gst_linescan_transform (GstBaseTransform * trans, GstBuffer * inbuf,
/* Increment buffer position */
filter->buffer_position++;
/* Wrap around when we reach the output size */
/* Check for rollover and emit signal */
gboolean rollover_occurred = FALSE;
if (filter->direction == GST_LINESCAN_DIRECTION_HORIZONTAL) {
if (filter->buffer_position >= out_height) {
filter->buffer_position = 0;
rollover_occurred = TRUE;
}
} else {
if (filter->buffer_position >= out_width) {
filter->buffer_position = 0;
rollover_occurred = TRUE;
}
}
@@ -597,6 +625,13 @@ gst_linescan_transform (GstBaseTransform * trans, GstBuffer * inbuf,
gst_buffer_unmap (inbuf, &map_in);
gst_buffer_unmap (outbuf, &map_out);
/* Emit rollover signal if buffer wrapped around */
if (rollover_occurred) {
GST_DEBUG_OBJECT (filter, "Rollover occurred at frame %lu",
(unsigned long) filter->frame_count);
g_signal_emit (filter, gst_linescan_signals[SIGNAL_ROLLOVER], 0, outbuf);
}
filter->frame_count++;
GST_LOG_OBJECT (filter, "Processed frame %lu, buffer position: %d",