From 083cd8670246fdc79dddc0756261e2eb76276406 Mon Sep 17 00:00:00 2001 From: yair Date: Sun, 16 Nov 2025 01:58:36 +0200 Subject: [PATCH] fix: correct exposure units from seconds to milliseconds - Update idsueyesrc exposure property to use milliseconds (per gst-inspect) - Fix default exposure value from 0.016 to 10ms - Update validation range to 1.0-1000.0ms in control server - Correct all documentation and examples in UDP_CONTROL_PROTOCOL.md - Update test_exposure_control.py to use millisecond values Resolves unit mismatch between documented seconds and actual milliseconds expected by the idsueyesrc GStreamer element. --- README.md | 19 +------------------ scripts/UDP_CONTROL_PROTOCOL.md | 26 +++++++++++++------------- scripts/launch-ids.py | 16 ++++++++-------- scripts/test_exposure_control.py | 22 +++++++++++----------- 4 files changed, 33 insertions(+), 50 deletions(-) diff --git a/README.md b/README.md index dd865af..b3e2cda 100644 --- a/README.md +++ b/README.md @@ -31,23 +31,6 @@ gst-launch-1.0 idsueyesrc config-file=ini/whole-presacler64_autoexp-binningx2.in **Note:** The `rollingsum` element analyzes a single column of pixels and drops frames when the column mean deviates from the rolling mean baseline by more than the threshold. Use `videoconvert` to ensure proper format negotiation. -### Additional rollingsum examples - -Analyze column 320 with larger window: -```powershell -gst-launch-1.0 idsueyesrc config-file=ini/whole-presacler64_autoexp-binningx2.ini exposure=0.5 ! videoconvert ! video/x-raw,format=GRAY8 ! rollingsum window-size=5000 column-index=320 threshold=0.3 ! queue ! autovideosink -``` - -Use stride for faster processing (sample every 2 rows): -```powershell -gst-launch-1.0 idsueyesrc config-file=ini/whole-presacler64_autoexp-binningx2.ini exposure=0.5 ! videoconvert ! video/x-raw,format=GRAY8 ! rollingsum window-size=1000 column-index=1 stride=2 threshold=0.5 ! queue ! autovideosink -``` - -Lower threshold for more sensitive detection: -```powershell -gst-launch-1.0 idsueyesrc config-file=ini/whole-presacler64_autoexp-binningx2.ini exposure=0.5 ! videoconvert ! video/x-raw,format=GRAY8 ! rollingsum threshold=0.2 ! queue ! autovideosink -``` - ## Network Streaming ### Quick Start - Single Line Transmission (2456x1) @@ -55,7 +38,7 @@ gst-launch-1.0 idsueyesrc config-file=ini/whole-presacler64_autoexp-binningx2.in #### Send Single Line via UDP Extract and transmit one line from camera (daytime, 200fps): ```powershell -gst-launch-1.0 idsueyesrc config-file=ini/200fps-2456x4pix-cw.ini exposure=5 framerate=200 ` +gst-launch-1.0 idsueyesrc config-file=ini/100fps-10exp-2456x4pix-500top-cw-extragain.ini exposure=5 framerate=200 ` ! videocrop bottom=3 ` ! queue ` ! udpsink host=127.0.0.1 port=5000 diff --git a/scripts/UDP_CONTROL_PROTOCOL.md b/scripts/UDP_CONTROL_PROTOCOL.md index e446ac4..5d54940 100644 --- a/scripts/UDP_CONTROL_PROTOCOL.md +++ b/scripts/UDP_CONTROL_PROTOCOL.md @@ -62,9 +62,9 @@ SET_EXPOSURE ``` **Parameters**: -- ``: Exposure time in seconds (float) - - Range: 0.001 to 1.0 seconds (1ms to 1000ms) - - Examples: `0.016` (16ms), `0.001` (1ms), `0.100` (100ms) +- ``: Exposure time in milliseconds (float) + - Range: 1.0 to 1000.0 milliseconds + - Examples: `16` (16ms), `1` (1ms), `100` (100ms) **Response**: ``` @@ -77,11 +77,11 @@ ERROR **Examples**: ``` -Client: SET_EXPOSURE 0.016\n -Server: OK 0.016\n +Client: SET_EXPOSURE 16\n +Server: OK 16\n -Client: SET_EXPOSURE 2.0\n -Server: ERROR Value out of range (0.001-1.0)\n +Client: SET_EXPOSURE 2000\n +Server: ERROR Value out of range (1.0-1000.0)\n ``` ### 2. GET_EXPOSURE @@ -103,7 +103,7 @@ OK **Example**: ``` Client: GET_EXPOSURE\n -Server: OK 0.016\n +Server: OK 16\n ``` ### 3. SET_FRAMERATE @@ -176,7 +176,7 @@ OK exposure= framerate= state= **Example**: ``` Client: STATUS\n -Server: OK exposure=0.016 framerate=22.0 state=PLAYING\n +Server: OK exposure=16 framerate=22.0 state=PLAYING\n ``` ## Error Handling @@ -192,7 +192,7 @@ ERROR : |------|-------------|---------| | `INVALID_COMMAND` | Unknown command | `ERROR INVALID_COMMAND: Unknown command 'FOO'` | | `INVALID_SYNTAX` | Malformed command | `ERROR INVALID_SYNTAX: Missing parameter` | -| `OUT_OF_RANGE` | Value out of valid range | `ERROR OUT_OF_RANGE: Exposure must be 0.001-1.0` | +| `OUT_OF_RANGE` | Value out of valid range | `ERROR OUT_OF_RANGE: Exposure must be 1.0-1000.0` | | `PIPELINE_ERROR` | Pipeline not running | `ERROR PIPELINE_ERROR: Pipeline not in PLAYING state` | ## Implementation Notes @@ -227,7 +227,7 @@ def send_command(command): return response.decode().strip() # Set exposure to 10ms -print(send_command("SET_EXPOSURE 0.010")) +print(send_command("SET_EXPOSURE 10")) # Get current exposure print(send_command("GET_EXPOSURE")) @@ -239,7 +239,7 @@ print(send_command("SET_FRAMERATE 30")) ### Command Line (netcat/nc) ```bash # Set exposure -echo "SET_EXPOSURE 0.020" | nc -u 127.0.0.1 5001 +echo "SET_EXPOSURE 20" | nc -u 127.0.0.1 5001 # Get exposure echo "GET_EXPOSURE" | nc -u 127.0.0.1 5001 @@ -254,7 +254,7 @@ $udpClient = New-Object System.Net.Sockets.UdpClient $endpoint = New-Object System.Net.IPEndPoint([System.Net.IPAddress]::Parse("127.0.0.1"), 5001) # Send command -$bytes = [System.Text.Encoding]::ASCII.GetBytes("SET_EXPOSURE 0.015`n") +$bytes = [System.Text.Encoding]::ASCII.GetBytes("SET_EXPOSURE 15`n") $udpClient.Send($bytes, $bytes.Length, $endpoint) # Receive response diff --git a/scripts/launch-ids.py b/scripts/launch-ids.py index e4e27b9..3549358 100644 --- a/scripts/launch-ids.py +++ b/scripts/launch-ids.py @@ -16,18 +16,18 @@ # Features: # - Video streaming on UDP port 5000 (127.0.0.1) # - Control interface on UDP port 5001 (0.0.0.0) -# - Dynamic exposure control (0.001-1.0 seconds) +# - Dynamic exposure control (1.0-1000.0 milliseconds) # - Dynamic framerate control (1-500 fps) # # Control Commands: -# SET_EXPOSURE - Set exposure in seconds (e.g., 0.016) +# SET_EXPOSURE - Set exposure in milliseconds (e.g., 16) # GET_EXPOSURE - Get current exposure value # SET_FRAMERATE - Set framerate in Hz (e.g., 30) # GET_FRAMERATE - Get current framerate # STATUS - Get pipeline status and current settings # # Example Usage: -# echo "SET_EXPOSURE 0.010" | nc -u 127.0.0.1 5001 +# echo "SET_EXPOSURE 10" | nc -u 127.0.0.1 5001 # echo "GET_EXPOSURE" | nc -u 127.0.0.1 5001 # # Testing: @@ -171,8 +171,8 @@ class ControlServer: try: value = float(parts[1]) - if value < 0.001 or value > 1.0: - return "ERROR OUT_OF_RANGE: Exposure must be 0.001-1.0 seconds" + if value < 1.0 or value > 1000.0: + return "ERROR OUT_OF_RANGE: Exposure must be 1.0-1000.0 milliseconds" self.src.set_property("exposure", value) # Verify the value was set @@ -250,11 +250,11 @@ pipeline = Gst.Pipeline() src = Gst.ElementFactory.make("idsueyesrc", "src") src.set_property("config-file", "ini/100fps-10exp-2456x4pix-500top-cw-extragain.ini") -# Exposure in seconds (e.g., 0.016) -src.set_property("exposure", 0.016) +# Exposure in milliseconds (e.g., 10) +src.set_property("exposure", 10) # Frame rate -src.set_property("framerate", 22) +src.set_property("framerate", 750) # Video crop to remove bottom 3 pixels videocrop = Gst.ElementFactory.make("videocrop", "crop") diff --git a/scripts/test_exposure_control.py b/scripts/test_exposure_control.py index 4b6c455..f3146b3 100644 --- a/scripts/test_exposure_control.py +++ b/scripts/test_exposure_control.py @@ -77,8 +77,8 @@ def main(): time.sleep(0.2) # Test 2: Set exposure to 10ms - response = send_command("SET_EXPOSURE 0.110") - print_test(2, "Set exposure to 10ms", "SET_EXPOSURE 0.010", response) + response = send_command("SET_EXPOSURE 10") + print_test(2, "Set exposure to 10ms", "SET_EXPOSURE 10", response) time.sleep(5.2) # Test 3: Verify exposure was set @@ -87,8 +87,8 @@ def main(): time.sleep(0.2) # Test 4: Set exposure to 20ms - response = send_command("SET_EXPOSURE 0.020") - print_test(4, "Set exposure to 20ms", "SET_EXPOSURE 0.020", response) + response = send_command("SET_EXPOSURE 20") + print_test(4, "Set exposure to 20ms", "SET_EXPOSURE 20", response) time.sleep(0.2) # Test 5: Get framerate @@ -117,13 +117,13 @@ def main(): time.sleep(0.2) # Test 10: Out of range exposure (too high) - response = send_command("SET_EXPOSURE 5.0") - print_test(10, "Out of range exposure (5.0s)", "SET_EXPOSURE 5.0", response) + response = send_command("SET_EXPOSURE 5000") + print_test(10, "Out of range exposure (5000ms)", "SET_EXPOSURE 5000", response) time.sleep(0.2) # Test 11: Out of range exposure (too low) - response = send_command("SET_EXPOSURE 0.0001") - print_test(11, "Out of range exposure (0.1ms)", "SET_EXPOSURE 0.0001", response) + response = send_command("SET_EXPOSURE 0.1") + print_test(11, "Out of range exposure (0.1ms)", "SET_EXPOSURE 0.1", response) time.sleep(0.2) # Test 12: Invalid syntax (missing parameter) @@ -137,8 +137,8 @@ def main(): time.sleep(0.2) # Test 14: Restore original exposure (16ms) - response = send_command("SET_EXPOSURE 0.016") - print_test(14, "Restore exposure to 16ms", "SET_EXPOSURE 0.016", response) + response = send_command("SET_EXPOSURE 16") + print_test(14, "Restore exposure to 16ms", "SET_EXPOSURE 16", response) time.sleep(0.2) # Test 15: Restore original framerate (22 fps) @@ -150,7 +150,7 @@ def main(): print("Test completed!") print() print("Quick reference:") - print(" echo 'SET_EXPOSURE 0.010' | nc -u 127.0.0.1 5001") + print(" echo 'SET_EXPOSURE 10' | nc -u 127.0.0.1 5001") print(" echo 'GET_EXPOSURE' | nc -u 127.0.0.1 5001") print(" echo 'STATUS' | nc -u 127.0.0.1 5001") print("=" * 70)