Skip to content

yaoian/cross-platform-camera-control

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

14 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Cross-Platform Video Device Control Tool

A cross-platform video device control tool compatible with v4l2-ctl, supporting Windows, Linux, and macOS.

🌟 Features

  • βœ… Cross-Platform Support: Windows, Linux, macOS
  • βœ… Device Enumeration: List all available video devices
  • βœ… Format Query: Display supported video formats, resolutions, frame rates
  • βœ… Parameter Control: View and set device control parameters (brightness, contrast, etc.)
  • βœ… v4l2-ctl Compatible: Command-line interface compatible with v4l2-ctl
  • βœ… Multiple Backends: DirectShow (Windows), V4L2 (Linux), AVFoundation (macOS), OpenCV (fallback)

πŸš€ Quick Start

Installation

# Install from source
git clone https://github.com/yaoian/cross-platform-camera-control.git
cd cross-platform-camera-control
pip install -r requirements.txt

# Or install as package
pip install cross-platform-camera-control

Basic Usage

# Show help
python v4l2_ctl_cross.py -h

# List all video devices
python v4l2_ctl_cross.py --list-devices

# Show supported formats
python v4l2_ctl_cross.py -d /dev/video0 --list-formats-ext

# Show device controls
python v4l2_ctl_cross.py -d /dev/video0 -L

# Set control parameters
python v4l2_ctl_cross.py -d /dev/video0 -c brightness=50
python v4l2_ctl_cross.py -d /dev/video0 -c brightness=50,contrast=75

πŸ“‹ Example Output

Device List:

USB Camera: (USB\VID_1BCF&PID_2C9A&MI_00\6&33F8E1A6&0&0000):
        /dev/video0

Control Parameters:

User Controls

brightness: 50 (range: 0-100) - Brightness
contrast: 50 (range: 0-100) - Contrast
saturation: 50 (range: 0-100) - Saturation

πŸ—οΈ Architecture

VideoDeviceController (Abstract Base Class)
β”œβ”€β”€ WindowsVideoController (Windows Implementation)
β”‚   β”œβ”€β”€ DirectShow API (Primary)
β”‚   └── OpenCV (Fallback)
β”œβ”€β”€ LinuxVideoController (Linux Implementation)
β”‚   └── V4L2 API
└── MacOSVideoController (macOS Implementation)
    └── AVFoundation API

πŸ“¦ Platform-Specific Dependencies

Windows

pip install pywin32 opencv-python

Linux

pip install v4l2-python opencv-python
# or
sudo apt-get install python3-v4l2

macOS

pip install pyobjc opencv-python pyobjc-framework-AVFoundation

πŸ“ Project Structure

β”œβ”€β”€ video_device_controller.py  # Abstract base class and interfaces
β”œβ”€β”€ windows_directshow.py       # Windows DirectShow implementation
β”œβ”€β”€ opencv_fallback.py          # OpenCV fallback implementation
β”œβ”€β”€ v4l2_ctl_cross.py          # Command-line interface
β”œβ”€β”€ setup.py                   # Package configuration
β”œβ”€β”€ requirements.txt           # Dependencies
└── README.md                  # Project documentation

πŸ”§ Development Status

βœ… Completed Features

  • Project architecture design
  • Windows platform basic implementation
  • OpenCV fallback solution
  • Command-line interface
  • Device enumeration
  • Basic format query
  • Basic parameter control

🚧 In Progress

  • Complete DirectShow implementation
  • Linux V4L2 implementation
  • macOS AVFoundation implementation
  • Advanced parameter control
  • Error handling optimization
  • Unit tests
  • Performance optimization

πŸ“Š Comparison with Original C++ Project

Feature C++ v4w2-ctl Python Version
Platform Support Windows only Windows/Linux/macOS
Device Enumeration βœ… βœ…
Format Query βœ… βœ… (Basic)
Parameter Control βœ… βœ… (Basic)
DirectShow βœ… Complete πŸ”„ In Development
V4L2 Support ❌ πŸ”„ Planned
Installation Requires compilation pip install

πŸ› οΈ Building Original C++ Project

# Using MinGW
g++ -o v4w2-ctl.exe v4w2-ctl.cpp ClsDirectShow.cpp -lole32 -loleaut32 -lstrmiids

# Test
./v4w2-ctl.exe -h
./v4w2-ctl.exe --list-devices

🀝 Contributing

  1. Fork the project
  2. Create a feature branch
  3. Commit your changes
  4. Push to the branch
  5. Open a Pull Request

πŸ“„ License

MIT License - Same as the original project

πŸ™ Acknowledgments

  • Original project author: hry2566
  • OpenCV community
  • Python community library maintainers

πŸ“ž Support

If you encounter any issues or have questions, please open an issue on GitHub.

About

Cross-platform camera control tool compatible with v4l2-ctl, supporting Windows/Linux/macOS with DirectShow, V4L2, and AVFoundation backends

Resources

License

Contributing

Stars

Watchers

Forks

Packages

 
 
 

Contributors