Skip to content

Conversation

Copy link

Copilot AI commented Dec 23, 2025

Implements a software GigE Vision adapter that exposes USB cameras as network-discoverable GigE Vision devices. Enables standard machine vision clients (Aravis, Vimba, eBUS) to access USB cameras over the network.

Implementation

Protocol Stack (gigeCam/)

  • gvcp_server.py - Control protocol (discovery, register I/O, acquisition control)
  • gvsp_streamer.py - Stream protocol (leader/payload/trailer packets, MTU-aware fragmentation)
  • usb_camera.py - OpenCV capture with thread-safe buffering and format conversion
  • config.py - GigE Vision 2.0 register map (30+ registers), command codes, constants

Server (gige_camera_server.py)

  • Multi-threaded coordination of capture, control, and streaming
  • CLI for camera selection, resolution, frame rate, network interface
  • Signal handlers for graceful shutdown

Compliance

  • GVCP: Discovery broadcast response (port 3956), register read/write
  • GVSP: Standard packet structure with block/packet ID sequencing
  • Pixel formats: Mono8, RGB8, BGR8
  • Virtual register map following GigE Vision 2.0 bootstrap specification

Usage

# Install dependencies
pip install -r gigeCam/requirements.txt

# Start server with default camera
python gigeCam/gige_camera_server.py

# Configure resolution and interface
python gigeCam/gige_camera_server.py --camera 0 --width 1920 --height 1080 --interface 192.168.1.100

Discovery and streaming work with any GenICam-compliant client. See gigeCam/README.md for network configuration and client setup.

Repository Impact

All code isolated in gigeCam/ folder. No modifications to existing Java application. Updated .gitignore for Python artifacts.

Original prompt

Objective

Create a Python program in a new gigeCam folder that captures video from a USB camera and outputs it as a GigE Vision stream, effectively making the USB camera appear as a GigE Vision camera on the network.

Requirements

Folder Structure

Create a new folder gigeCam/ in the repository root with the following structure:

gigeCam/
├── gige_camera_server.py      # Main server implementation
├── gvcp_server.py              # GigE Vision Control Protocol handler
├── gvsp_streamer.py            # GigE Vision Stream Protocol handler
├── usb_camera.py               # USB camera capture handler
├── config.py                   # Configuration constants
├── requirements.txt            # Python dependencies
└── README.md                   # Documentation and usage instructions

Implementation Details

  1. gige_camera_server.py - Main entry point

    • Initialize USB camera capture
    • Start GVCP server (UDP port 3956)
    • Start GVSP streamer (UDP)
    • Handle graceful shutdown
    • Command-line arguments for camera selection, resolution, etc.
  2. gvcp_server.py - Control Protocol Server

    • Implement basic GVCP commands:
      • DISCOVERY_CMD (0x0002) - respond to camera discovery
      • READREG_CMD (0x0080) - read register
      • WRITEREG_CMD (0x0082) - write register
    • Maintain virtual register map for camera parameters
    • Handle XML device description requests
    • Support acquisition start/stop commands
  3. gvsp_streamer.py - Stream Protocol Handler

    • Implement GVSP packet structure:
      • Leader packet
      • Image data packets
      • Trailer packet
    • Support common pixel formats (Mono8, RGB8, BGR8)
    • Add frame ID and timestamp
    • Handle packet fragmentation for large frames
    • Configurable packet size (typical: 1500 bytes MTU)
  4. usb_camera.py - USB Camera Handler

    • Use OpenCV (cv2.VideoCapture) for camera access
    • Support camera enumeration
    • Configurable resolution and frame rate
    • Convert frames to requested pixel format
    • Thread-safe frame buffering
  5. config.py - Configuration Constants

    • GVCP/GVSP port numbers
    • Default camera parameters (width, height, fps)
    • Pixel format definitions
    • Register addresses (following GigE Vision standard)
    • Network settings
  6. requirements.txt

    opencv-python>=4.5.0
    numpy>=1.19.0
    
  7. README.md - Documentation

    • Overview of the project
    • Installation instructions
    • Usage examples
    • Command-line options
    • Network configuration tips
    • Troubleshooting guide
    • Testing with GigE Vision clients (e.g., Aravis, Vimba Viewer)

Technical Specifications

  • GigE Vision Compliance: Basic implementation (subset of GigE Vision 2.0)
  • GVCP Protocol: UDP-based control on port 3956
  • GVSP Protocol: UDP-based streaming on configurable port
  • Pixel Formats: Support Mono8, RGB8, BGR8 (expandable)
  • Network: IPv4 unicast streaming
  • Performance: Target 30 fps for 640x480 resolution

Key Features to Implement

  1. Camera discovery response (broadcast response)
  2. Stream channel configuration
  3. Acquisition start/stop
  4. Basic register read/write (width, height, pixel format, etc.)
  5. Frame streaming with proper GVSP packet structure
  6. Heartbeat mechanism
  7. Error handling and logging

Example Usage

# Start with default USB camera (index 0)
python gige_camera_server.py

# Specify camera and resolution
python gige_camera_server.py --camera 0 --width 1920 --height 1080 --fps 30

# Specify network interface
python gige_camera_server.py --interface 192.168.1.100

Testing Notes

The implementation should be testable with standard GigE Vision clients such as:

  • Aravis viewer (Linux)
  • Vimba Viewer (Windows/Linux)
  • eBUS Player
  • Any GenICam-compliant software

Acceptance Criteria

  • All files created in gigeCam/ folder
  • USB camera can be detected and opened
  • GVCP server responds to discovery packets
  • Camera appears in GigE Vision client applications
  • Video stream can be received and displayed
  • Code includes proper error handling
  • README includes clear setup and usage instructions
  • No modifications to existing Java code in the repository

This pull request was created from Copilot chat.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI changed the title [WIP] Create gigeCam folder for USB to GigE Vision streaming Add GigE Vision server for USB camera network streaming Dec 23, 2025
Copilot AI requested a review from DamirTomic December 23, 2025 13:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants