Skip to content

Latest commit

 

History

History
129 lines (98 loc) · 4.05 KB

File metadata and controls

129 lines (98 loc) · 4.05 KB

Practical Solution for Nvidia CSI Brightness Control

Test Results Analysis

From your test output:

  • Dark (50000ns, gain=1): Failed to create capture session - exposure too low
  • Normal (200000ns, gain=2): 4.1M file - captured successfully
  • Bright (5000000ns, gain=8): 1.8M file - similar brightness to normal
  • Very Bright (30000000ns, gain=10): 1.2M file - noticeably brighter

Key Finding

GAIN has more effect on brightness than EXPOSURE for this camera setup.

The camera appears to have auto-exposure active that overrides manual exposure settings, but gain settings are being respected, especially at higher values (8-10).

Recommended Approach

Option 1: Focus on Gain Control (Recommended)

Since gain works reliably, we should:

  1. Primary control: Use GAIN (1.0 to 10.625) as the main brightness control
  2. Secondary control: Keep exposure at a fixed reasonable value (e.g., 200000ns)
  3. User guidance: Update UI to indicate "Use Gain to control brightness"

Option 2: Use Gain + High Exposure Range

Keep both controls but:

  1. Set exposure range to where it has effect: 5000000 to 30000000 (5ms to 30ms)
  2. Emphasize gain as the primary control
  3. Note that low exposure values don't work well

Option 3: Test Additional AE Lock Parameters

Run the new test to see if we can fully disable auto-exposure:

chmod +x test_ae_lock.sh
./test_ae_lock.sh

This tests:

  • aelock=true - Lock auto-exposure
  • awblock=true - Lock auto white balance
  • exposurecompensation=0 - Disable exposure compensation
  • Gain-only control (no exposure parameter)

Current Implementation Status

What Works ✓

  1. Save button is enabled for Nvidia CSI cameras
  2. Config file is updated when settings change
  3. Service reads config changes
  4. Gain settings are applied and affect brightness

What Doesn't Work Fully ✗

  1. Exposure settings are applied but auto-exposure overrides them
  2. Low exposure values (< 100000ns) cause capture failures
  3. Mid-range exposure changes (100000 to 5000000) have minimal visible effect

Recommended Settings for Users

For Dark Images:

  • Gain: 1.0 to 2.0
  • Exposure: 200000 (fixed)

For Normal Images:

  • Gain: 2.0 to 5.0
  • Exposure: 200000 to 5000000

For Bright Images:

  • Gain: 5.0 to 10.625
  • Exposure: 5000000 to 30000000

Next Steps

  1. Run the AE lock test:

    chmod +x test_ae_lock.sh
    ./test_ae_lock.sh
  2. Check if gain-only control works better: Compare test_gain_only_low.jpg vs test_gain_only_high.jpg

  3. If gain-only works well, consider:

    • Simplifying UI to focus on gain
    • Setting exposure to a fixed optimal value
    • Or hiding exposure in "Advanced Settings"
  4. Deploy current code - It will work, with gain being the primary brightness control

Alternative: Post-Processing Approach

If manual camera control remains unreliable, we could:

  1. Capture at fixed camera settings
  2. Apply brightness/contrast adjustment in software (OpenCV)
  3. This gives consistent, predictable results
  4. Trade-off: Slightly more CPU usage, but more reliable

Code Changes Made

Updated Minimum Exposure

  • Changed from 50000 to 100000 (since 50000 fails)
  • Updated UI constraint text to note that gain has more effect

Current Working Range

  • Gain: 1.0 to 10.625 (works reliably)
  • Exposure: 100000 to 30000000 (applied but may be overridden by AE)

Capture Script Parameters

nvarguscamerasrc sensor_id=0 \
    aeantibanding=0 \
    wbmode=0 \
    exposuretimerange="$EXPOSURE $EXPOSURE" \
    gainrange="$GAIN $GAIN"

User Documentation

Add to user guide:

Brightness Control for Nvidia CSI Camera

The Nvidia CSI camera uses two parameters to control brightness:

  • Gain (1.0 to 10.625): Primary brightness control - has the most visible effect
  • Exposure (0.1ms to 30ms): Secondary control - may have limited effect due to auto-exposure

For best results:

  • Adjust Gain first to get the desired brightness
  • Fine-tune with Exposure if needed
  • Higher values = brighter images