Python Sample Program Collection
This section introduces sample programs that run the INFINICAM GbE-2 from Python. Every sample uses pypuclib, the dedicated INFINICAM library. Captured images come out as NumPy arrays, so you can pass them straight to libraries such as OpenCV and PyTorch.
Basics (connecting, capturing, and saving)
Section titled “Basics (connecting, capturing, and saving)”The most basic samples: connect to the camera, then capture and save one image. Try them from the top down.
HelloWorld (connecting to the camera)Connects to the GbE-2 and displays its serial number, resolution, and frame rate.
SingleImage (saving as PGM)Captures and decodes one image and saves it as PGM using only NumPy.
SingleImage (saving as PNG)Saves a captured image as PNG using OpenCV.
SingleImage (color)Captures one image with a color model and saves it as a color image.
Image processing and library integration
Section titled “Image processing and library integration”Samples that process captured images with image processing and machine learning libraries.
OpenCV image processing & displayBlurs a captured image, detects edges, and shows and saves the result in an OpenCV window.
torchvision tensor conversion & preprocessingConverts a captured image into a PyTorch tensor and applies the preprocessing used as AI model input.
Advanced and high-speed processing
Section titled “Advanced and high-speed processing”Samples for live display, continuous capture at 1,000 fps, and fast decoding that takes advantage of INFINICAM’s compression.
OpenCV LiveViewShows the camera feed in an OpenCV window in real time.
Continuous high-speed captureReceives 1,000 fps images without missing any, and counts received and dropped frames.
SingleImage + ROI decodingDecodes only the region you need (ROI) instead of the whole image.
SingleImage + DC component extractionExtracts only the DC components from the compressed data to build a 1/8-scale image quickly.
Changing capture settings and external sync
Section titled “Changing capture settings and external sync”Samples that change the frame rate or image size, or capture in step with an external signal.
Changing capture settings + SingleImageChanges the resolution, frame rate, and shutter speed, then captures one image.
External device synchronizationSets up capture in sync with an external signal, and checks what happens when there is no signal.
Sample list
Section titled “Sample list”| Sample | Program | Main libraries | Level | What you learn |
|---|---|---|---|---|
| HelloWorld | hello_camera.py |
pypuclib |
Beginner | Connecting to the camera, reading camera information |
| SingleImage (PGM) | single_image.py |
NumPy |
Beginner | Capturing one frame, decoding, saving as PGM |
| SingleImage (PNG) | single_image_png.py |
OpenCV |
Beginner | Saving a NumPy array as PNG |
| SingleImage (color) | single_image_color.py |
OpenCV |
Beginner | Detecting a color model, saving a color image |
| OpenCV image processing | opencv_process.py |
OpenCV |
Intermediate | Blur and edge detection, showing a window |
| torchvision preprocessing | torchvision_process.py |
torch / torchvision |
Intermediate | Converting to a tensor, resizing and normalizing |
| OpenCV LiveView | opencv_live.py |
OpenCV |
Intermediate | Continuous transfer and real-time display |
| Continuous high-speed capture | continuous_capture.py |
threading / queue |
Advanced | Receiving 1,000 fps, decoding in parallel with threads |
| ROI decoding | single_image_roi.py |
pypuclib |
Intermediate | Decoding only part of the image (in multiples of 8) |
| DC component extraction | single_image_dc.py |
pypuclib |
Intermediate | Building a 1/8-scale image quickly |
| Changing capture settings | single_image_settings.py |
pypuclib |
Beginner | Changing resolution, frame rate, and shutter speed |
| External sync | external_sync.py |
pypuclib |
Intermediate | Setting up external sync, handling a missing signal |
