ommit print

This commit is contained in:
yair
2025-11-18 20:35:15 +02:00
parent a7a776fb58
commit 5c91899669
3 changed files with 1 additions and 193 deletions

View File

@@ -1,43 +0,0 @@
# Linescan Pipeline Example - PowerShell GStreamer Launch
#
# This script demonstrates a GStreamer linescan pipeline using gst-launch-1.0.
# NOTE: This saves EVERY frame using multifilesink, not just on rollover.
#
# For proper rollover-only saving, use the Python scripts instead:
# - launch_with_signal.py (full-featured with camera)
# - rollover_example.py (simple demo)
#
# This script is kept as a reference for the pipeline structure.
#
# Prerequisites:
# 1. Build the plugins: .\build.ps1
# 2. Run from workspace root: c:\dev\gst-plugins-vision
#
# Usage:
# .\gst\linescan\launch_with_capture.ps1
#
# Pipeline:
# idsueyesrc -> intervalometer -> videocrop -> queue -> linescan -> videoconvert -> autovideosink
#
# WARNING: This example saves every output frame, not just on rollover!
# Use Python scripts for rollover-based capture.
$env:GST_DEBUG="linescan:5"
# Simple pipeline - display only (no file saving)
# For file saving on rollover, use launch_with_signal.py instead
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=linescan_timelapse.csv ! `
videocrop bottom=3 ! `
queue ! `
linescan direction=vertical output-size=1900 ! `
videoconvert ! autovideosink
# Note: multifilesink has been removed because it saves EVERY frame.
# To save only on rollover events, use the Python scripts which connect
# to the rollover signal and save via PIL/numpy.

View File

@@ -169,7 +169,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:

View File

@@ -1,149 +0,0 @@
/* Simple Rollover Example - Linescan Buffer Capture Demo (C)
*
* This is a minimal C example showing rollover signal detection.
*
* NOTE: This example demonstrates signal connection but doesn't save files.
* For actual file saving, use the Python examples (rollover_example.py or
* launch_with_signal.py) which use PIL/numpy to properly save images.
*
* In C, you would need to:
* 1. Map the buffer (gst_buffer_map)
* 2. Parse the caps to get width/height/format
* 3. Use a library like libpng or libjpeg to encode and save
*
* Compile with:
* gcc rollover_example.c -o rollover_example `pkg-config --cflags --libs gstreamer-1.0 gstreamer-video-1.0`
*
* Usage:
* ./rollover_example
*
* Pipeline:
* videotestsrc -> linescan -> videoconvert -> autovideosink
* ↓
* (rollover signal)
* ↓
* C callback prints message
*/
#include <gst/gst.h>
#include <gst/video/video.h>
#include <stdio.h>
static gint frame_counter = 0;
/* Callback function when rollover signal is emitted */
static void
on_rollover (GstElement *linescan, GstBuffer *buffer, gpointer user_data)
{
GstCaps *caps;
GstStructure *structure;
gint width, height;
const gchar *format_str;
frame_counter++;
/* Get buffer information */
GstPad *srcpad = gst_element_get_static_pad (linescan, "src");
caps = gst_pad_get_current_caps (srcpad);
structure = gst_caps_get_structure (caps, 0);
gst_structure_get_int (structure, "width", &width);
gst_structure_get_int (structure, "height", &height);
format_str = gst_structure_get_string (structure, "format");
g_print ("[ROLLOVER] Frame %d - %dx%d %s (size: %lu bytes)\n",
frame_counter,
width, height,
format_str,
(unsigned long) gst_buffer_get_size (buffer));
/* NOTE: To actually save the buffer to a file, you would:
* 1. Map the buffer: gst_buffer_map(buffer, &map_info, GST_MAP_READ)
* 2. Encode using libpng/libjpeg based on the data in map_info.data
* 3. Write to file with the frame_counter in the filename
* 4. Unmap: gst_buffer_unmap(buffer, &map_info)
*
* For a complete example with file saving, see the Python version.
*/
gst_caps_unref (caps);
gst_object_unref (srcpad);
}
int
main (int argc, char *argv[])
{
GstElement *pipeline, *source, *linescan;
GstElement *videoconvert, *videosink;
GstBus *bus;
GstMessage *msg;
/* Initialize GStreamer */
gst_init (&argc, &argv);
/* Create elements - simplified pipeline without file branch */
pipeline = gst_pipeline_new ("rollover-pipeline");
source = gst_element_factory_make ("videotestsrc", "source");
linescan = gst_element_factory_make ("linescan", "linescan");
videoconvert = gst_element_factory_make ("videoconvert", "convert");
videosink = gst_element_factory_make ("autovideosink", "videosink");
if (!pipeline || !source || !linescan || !videoconvert || !videosink) {
g_printerr ("Not all elements could be created.\n");
g_printerr ("Make sure linescan plugin is built and in GST_PLUGIN_PATH.\n");
return -1;
}
/* Configure elements */
g_object_set (source, "pattern", 18, NULL); /* ball pattern */
g_object_set (linescan,
"direction", 0, /* horizontal */
"line-index", 100,
"output-size", 400,
NULL);
/* Connect to rollover signal */
g_signal_connect (linescan, "rollover", G_CALLBACK (on_rollover), NULL);
/* Build the pipeline - simple chain */
gst_bin_add_many (GST_BIN (pipeline), source, linescan,
videoconvert, videosink, NULL);
if (!gst_element_link_many (source, linescan, videoconvert, videosink, NULL)) {
g_printerr ("Elements could not be linked.\n");
gst_object_unref (pipeline);
return -1;
}
/* Start playing */
g_print ("Pipeline running. Rollover events will be printed.\n");
g_print ("Press Ctrl+C to stop.\n\n");
gst_element_set_state (pipeline, GST_STATE_PLAYING);
/* Wait until error or EOS */
bus = gst_element_get_bus (pipeline);
msg = gst_bus_timed_pop_filtered (bus, GST_CLOCK_TIME_NONE,
GST_MESSAGE_ERROR | GST_MESSAGE_EOS);
/* Handle any errors */
if (msg != NULL) {
if (GST_MESSAGE_TYPE (msg) == GST_MESSAGE_ERROR) {
GError *err;
gchar *debug_info;
gst_message_parse_error (msg, &err, &debug_info);
g_printerr ("\nError: %s\n", err->message);
g_error_free (err);
g_free (debug_info);
}
gst_message_unref (msg);
}
/* Free resources */
gst_object_unref (bus);
gst_element_set_state (pipeline, GST_STATE_NULL);
gst_object_unref (pipeline);
g_print ("\nDetected %d rollover events\n", frame_counter);
return 0;
}