Python Sample Program Collection
This section contains a collection of sample programs for controlling the INFINICAM GbE-2 (Ethernet model) from Python (calling the C API via ctypes) and integrating it with NumPy and various image-processing and AI libraries. Each sample works by importing the common module puclib.py (created in HelloWorld).
Basics and Environment Setup
Section titled “Basics and Environment Setup”Steps for building the common module (puclib.py) and saving images in various formats (PGM / PNG / PPM).
Image Processing and Library Integration
Section titled “Image Processing and Library Integration”Practical samples that process, display, and save a captured SingleImage using various image-processing and machine-learning libraries.
Advanced and High-Speed Processing Samples
Section titled “Advanced and High-Speed Processing Samples”Implementation examples of real-time streaming and high-speed decoding that take advantage of fixed-length compression.
Parameter Control and Special Features
Section titled “Parameter Control and Special Features”Samples for changing frame rate and image size settings, and for synchronizing capture with external signals.
Sample List by Feature
Section titled “Sample List by Feature”| Sample | Target Feature / Main Library | Difficulty | Key Learning Points |
|---|---|---|---|
| HelloWorld | puclib.py / ctypes |
Beginner | Creating a common wrapper module, GbE-2 detection, retrieving device information |
| SingleImage (PGM) | NumPy |
Beginner | Single-frame capture, decoding, PGM saving |
| SingleImage (PNG) | OpenCV / Pillow |
Beginner | Encoding and saving a NumPy array as PNG |
| SingleImage (Color) | NumPy / OpenCV |
Beginner | White balance setup, Bayer conversion decoding, PPM/PNG saving |
| OpenCV Image Processing | cv2 (OpenCV) |
Intermediate | Canny edge detection, Gaussian filtering, display, and saving |
| scikit-image Analysis | skimage / matplotlib |
Intermediate | Otsu thresholding, region labeling, contour display and saving |
| torchvision Preprocessing | torch / torchvision |
Intermediate | PyTorch Tensor conversion, resizing, normalization, saving |
| OpenCV LiveView | cv2 / ctypes.CFUNCTYPE |
Intermediate | Receiving callbacks and real-time rendering with OpenCV |
| Continuous High-Speed Capture | threading / queue |
Advanced | Python callbacks, inter-thread queuing |
| ROI Decoding | PUC_DecodeData |
Intermediate | Limited decoding of a specific region (in 8x8 block units) |
| DC Component Extraction | PUC_DecodeDCData |
Intermediate | Extremely fast generation of a 1/8-scale preview image |
| Changing Capture Settings | PUC_SetResolution |
Beginner | Changing resolution, frame rate, and shutter speed |
| External Device Synchronization | PUC_SetSyncInMode |
Intermediate | Capturing in sync with an external signal (SYNC IN) and timeout handling |
