Skip to main content

Python bindings for P2/Tiny1C thermal camera SDK

Project description

Tiny Thermal Camera Python Bindings

Cross-platform Python bindings for the AC010_256 thermal camera SDK, supporting P2/Tiny1C thermal cameras on Windows, Linux (x86, ARM, MIPS), and macOS.

Features

  • Cross-Platform Support: Windows, Linux (x86, ARM, MIPS), and macOS
  • Camera Control: Open/close camera, start/stop streaming
  • Temperature Measurement: Point, line, and area temperature analysis
  • Real-time Data: Get temperature and image frames as NumPy arrays
  • Easy Integration: Simple Python API with context manager support
  • Self-Contained: Automatic DLL/library management - no manual setup required
  • Architecture Support: Multiple ARM and MIPS variants for embedded systems
  • Comprehensive Examples: Demo scripts and utilities included

Installation

Simple Installation (Recommended)

# Install pre-compiled wheel from PyPI
pip install tiny-thermal-camera

Pre-compiled wheels available for:

  • Windows: Python 3.8-3.12 (x64) - No build tools required!
  • Linux: Python 3.8-3.12 (x86_64, aarch64)

Benefits:

  • No C++ compiler or build tools needed
  • Instant installation
  • All libraries bundled automatically
  • Works out of the box

Alternative: Install from Source

# Install from source (requires build tools)
pip install .

Note: Building from source requires:

After installation, the package automatically:

  • Detects your platform (Windows/Linux/macOS) and architecture (x86/ARM/MIPS)
  • Includes all necessary libraries and DLLs
  • Sets up runtime library loading
  • No manual library management required!

Platform-Specific Notes

Windows

  • Pre-compiled wheels available - no build tools needed!
  • All required DLLs are automatically included and loaded
  • No additional Visual C++ Redistributable installation needed
  • For build-from-source instructions, see WINDOWS_INSTALL.md

Linux

  • Static library linking used by default (no runtime dependencies)
  • Supports x86, ARM (various variants), and MIPS architectures
  • Cross-compilation supported via environment variables

Cross-Compilation (Advanced)

# Example: Cross-compile for ARM
export CROSS_COMPILE=arm-linux-gnueabihf
export TARGET_ARCH=arm
pip install .

Development Installation

# Development install with editable mode
pip install -e .

# Build in-place for development
python setup.py build_ext --inplace

Usage

Quick Start

import tiny_thermal_camera

# Context manager automatically handles initialization, open, and cleanup
with tiny_thermal_camera.ThermalCamera() as camera:
    # Start streaming (waits 5s for P2 series stabilization)
    if camera.start_streaming():
        # Capture a frame
        temp_frame, image_frame = camera.capture_frame()
        
        if temp_frame is not None:
            # Get temperature statistics
            stats = camera.get_temperature_stats(temp_frame)
            print(f"Temperature range: {stats['min']:.1f}°C - {stats['max']:.1f}°C")
            
            # Find hottest point
            hot_pos, hot_temp = camera.find_hotspot(temp_frame)
            print(f"Hotspot: {hot_temp:.1f}°C at position {hot_pos}")

Advanced Usage (Manual Resource Management)

import tiny_thermal_camera
import numpy as np

# Direct API access with manual resource management
camera = tiny_thermal_camera.ThermalCamera()
# Note: TemperatureProcessor is a static class, don't instantiate

try:
    # Manual initialization and open
    camera.initialize()
    if camera.open():
        camera.start_stream()
        
        # Get camera info
        width, height, fps = camera.get_camera_info()
        
        # Get raw temperature frame
        temp_frame = camera.get_raw_frame()
        
        # Point temperature
        success, temp = tiny_thermal_camera.TemperatureProcessor.get_point_temp(temp_frame, 128, 96)
        if success:
            print(f"Temperature at center: {temp:.1f}°C")
        
        # Area temperature
        success, max_t, min_t, avg_t = tiny_thermal_camera.TemperatureProcessor.get_rect_temp(
            temp_frame, 100, 80, 50, 50)
        if success:
            print(f"Area stats - Max: {max_t:.1f}°C, Min: {min_t:.1f}°C, Avg: {avg_t:.1f}°C")
finally:
    # Manual cleanup
    camera.close()

Demo Scripts

Interactive Demo

python3 thermal_camera_demo.py

Features:

  • Camera initialization and streaming
  • Single frame capture and analysis
  • Temperature visualization with matplotlib/OpenCV
  • Continuous monitoring mode
  • Point, line, and area temperature measurement

Simple Tests

# Basic functionality test
python3 test_simple.py

# Continuous monitoring
python3 test_continuous.py

# Context manager test
python3 test.py

# Context manager persistence test
python3 test_context_persistence.py

API Reference

tiny_thermal_camera.ThermalCamera Class

Context Manager Support

import tiny_thermal_camera

# Context manager handles initialization and opening
with tiny_thermal_camera.ThermalCamera() as camera:
    # Camera is initialized and opened
    camera.start_streaming()  # User controls streaming

# Camera and stream remain active after context manager exits!
# This allows for continuous monitoring beyond the 'with' block
temp_frame, _ = camera.capture_frame()  # Still works!

# User explicitly controls cleanup when ready
camera.stop_stream()
camera.close()

Core Methods

  • initialize() - Initialize camera system
  • open(vid=0x0BDA, pid=0x5840) - Open the thermal camera
  • close() - Close the camera
  • start_stream(enable_temperature_mode=True, wait_seconds=5) - Start streaming with temperature mode
  • start_streaming(enable_temperature_mode=True, wait_seconds=5) - Alias for start_stream
  • stop_stream() - Stop streaming
  • get_camera_info() - Get (width, height, fps)
  • get_raw_frame() - Get raw temperature data as uint16 numpy array
  • get_device_list() - Get available USB devices
  • is_open() - Check if camera is open
  • is_streaming() - Check if streaming

Convenience Methods

  • capture_frame() - Get (temp_frame, image_frame) tuple
  • get_temperature_stats(temp_frame) - Get comprehensive statistics dict
  • find_hotspot(temp_frame) - Find hottest point and temperature

tiny_thermal_camera.TemperatureProcessor Class

Static Methods

  • tiny_thermal_camera.temp_to_celsius(raw_value) - Convert raw temperature to Celsius
  • TemperatureProcessor.get_point_temp(frame, x, y) - Get temperature at point
  • TemperatureProcessor.get_rect_temp(frame, x, y, w, h) - Get area temperature stats
  • TemperatureProcessor.get_line_temp(frame, x1, y1, x2, y2) - Get line temperature stats

Usage Examples

Simple Temperature Reading

import tiny_thermal_camera

with tiny_thermal_camera.ThermalCamera() as camera:
    if camera.start_streaming():
        temp_frame, _ = camera.capture_frame()
        if temp_frame is not None:
            stats = camera.get_temperature_stats(temp_frame)
            print(f"Average temperature: {stats['mean']:.1f}°C")

Finding Hot and Cold Spots

import tiny_thermal_camera

with tiny_thermal_camera.ThermalCamera() as camera:
    if camera.start_streaming():
        temp_frame, _ = camera.capture_frame()
        if temp_frame is not None:
            hot_pos, hot_temp = camera.find_hotspot(temp_frame)
            print(f"Hottest point: {hot_temp:.1f}°C at {hot_pos}")

Continuous Temperature Monitoring

import tiny_thermal_camera
import time

# Initialize camera with context manager
with tiny_thermal_camera.ThermalCamera() as camera:
    camera.start_streaming()

# Stream persists beyond context manager - continuous monitoring
print("Starting continuous temperature monitoring...")
print("Press Ctrl+C to stop")

try:
    frame_count = 0
    while True:
        temp_frame, _ = camera.capture_frame()
        if temp_frame is not None:
            frame_count += 1
            
            # Get temperature statistics
            stats = camera.get_temperature_stats(temp_frame)
            hot_pos, hot_temp = camera.find_hotspot(temp_frame)
            
            # Print status every 10 frames
            if frame_count % 10 == 0:
                print(f"Frame {frame_count}: "
                      f"Avg: {stats['mean']:.1f}°C, "
                      f"Range: {stats['min']:.1f}-{stats['max']:.1f}°C, "
                      f"Hotspot: {hot_temp:.1f}°C at {hot_pos}")
        
        time.sleep(0.1)  # ~10 FPS

except KeyboardInterrupt:
    print("\nStopping monitoring...")
finally:
    # Clean up when done
    camera.stop_stream()
    camera.close()
    print("Cleanup completed.")

Troubleshooting

Installation Issues

Import Errors

# Test basic import
python -c "import tiny_thermal_camera; print('SUCCESS: Package installed correctly')"

# If import fails, try reinstalling
pip uninstall tiny-thermal-camera
pip install tiny-thermal-camera --force-reinstall

Windows DLL Issues

  • All required DLLs are automatically included
  • If you see "DLL load failed", ensure you're importing the installed package:
# This should work from any directory
import tiny_thermal_camera

Camera Issues

Camera Not Detected

# Check for connected devices
import tiny_thermal_camera
camera = tiny_thermal_camera.ThermalCamera()
success, devices = camera.get_device_list()
print(f'Found {len(devices)} devices: {devices}')

Linux USB Permissions

# Check USB connection and device presence  
lsusb | grep 0bda:5840

# Fix USB permissions if needed
sudo chmod 666 /dev/bus/usb/*/*

Windows Device Access

  • Ensure camera drivers are installed
  • Check Device Manager for USB devices
  • Try different USB ports

Build Issues (Development)

Missing Dependencies

# Linux: Install build tools
sudo apt install build-essential python3-dev pkg-config

# Install from source
pip install . --verbose  # Shows detailed build output

Clean Rebuild

# Clean previous builds
python setup.py clean --all
pip install . --force-reinstall

Runtime Issues

# Test basic functionality
import tiny_thermal_camera

with tiny_thermal_camera.ThermalCamera() as camera:
    if camera.start_streaming():
        temp_frame, _ = camera.capture_frame()
        if temp_frame is not None:
            print("Camera working correctly!")
        else:
            print("Failed to capture frame")
    else:
        print("Failed to start streaming")

Hardware Requirements

  • Compatible Cameras: P2 series, Tiny1C, AC010_256
  • Connection: USB interface (VID: 0x0BDA, PID: 0x5840)
  • Operating Systems:
    • Windows (32-bit and 64-bit)
    • Linux (x86, ARM, MIPS architectures)
    • macOS (basic support)
  • Dependencies: All libraries automatically included - no manual installation
  • Permissions: USB device access required

Notes for P2 Series Cameras

  • Default resolution: 256×192 pixels
  • Temperature data requires y16_preview_start command (handled automatically)
  • 5-second stabilization wait recommended after starting stream
  • Temperature mode is enabled automatically when using start_stream()
  • All thermal camera libraries are automatically managed - no runtime dependency issues

Package Information

  • Package Name: tiny-thermal-camera
  • Module Name: tiny_thermal_camera
  • Version: 1.0.0
  • Build System: Cross-platform setuptools with pybind11
  • Context Manager: Built-in (no separate wrapper needed)
  • Library Management: Automatic DLL/library loading for all platforms
  • Architectures Supported:
    • Windows: x86, x64
    • Linux: x86, ARM (multiple variants), MIPS
    • Cross-compilation: Full toolchain support

Supported Linux Architectures

  • x86: Standard Intel/AMD processors
  • ARM 64-bit: aarch64-linux-gnu, aarch64-none-linux-gnu
  • ARM 32-bit: arm-linux-gnueabi, arm-linux-gnueabihf
  • Embedded ARM: arm-himix100-linux, arm-himix200-linux, arm-hisiv300/500-linux
  • MIPS: mips-linux-gnu (limited library support)
  • Custom: Support for buildroot and musl toolchains

Building Wheels & Releasing

For Maintainers

Quick local wheel build:

# Windows
build_wheel.bat

# Linux
./build_wheel.sh

Automated release process via GitHub Actions:

  1. Update version in pyproject.toml
  2. Create and push tag: git tag v1.x.x && git push origin v1.x.x
  3. GitHub Actions automatically builds and publishes wheels to PyPI

See RELEASING.md for detailed release instructions.

Contributing

Contributions are welcome! Please ensure:

  • Code follows existing style
  • Tests pass (if applicable)
  • Documentation is updated
  • Pre-compiled wheels build successfully

License

MIT License - This software is provided as-is for educational and development purposes.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tiny_thermal_camera-1.0.0.tar.gz (2.0 MB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

tiny_thermal_camera-1.0.0-cp312-cp312-win_amd64.whl (846.4 kB view details)

Uploaded CPython 3.12Windows x86-64

tiny_thermal_camera-1.0.0-cp312-cp312-manylinux_2_28_x86_64.whl (1.2 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ x86-64

tiny_thermal_camera-1.0.0-cp311-cp311-win_amd64.whl (846.2 kB view details)

Uploaded CPython 3.11Windows x86-64

tiny_thermal_camera-1.0.0-cp311-cp311-manylinux_2_28_x86_64.whl (1.2 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ x86-64

tiny_thermal_camera-1.0.0-cp310-cp310-win_amd64.whl (846.3 kB view details)

Uploaded CPython 3.10Windows x86-64

tiny_thermal_camera-1.0.0-cp310-cp310-manylinux_2_28_x86_64.whl (1.2 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.28+ x86-64

tiny_thermal_camera-1.0.0-cp39-cp39-win_amd64.whl (845.2 kB view details)

Uploaded CPython 3.9Windows x86-64

tiny_thermal_camera-1.0.0-cp39-cp39-manylinux_2_28_x86_64.whl (1.2 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.28+ x86-64

tiny_thermal_camera-1.0.0-cp38-cp38-win_amd64.whl (860.6 kB view details)

Uploaded CPython 3.8Windows x86-64

tiny_thermal_camera-1.0.0-cp38-cp38-manylinux_2_28_x86_64.whl (1.2 MB view details)

Uploaded CPython 3.8manylinux: glibc 2.28+ x86-64

File details

Details for the file tiny_thermal_camera-1.0.0.tar.gz.

File metadata

  • Download URL: tiny_thermal_camera-1.0.0.tar.gz
  • Upload date:
  • Size: 2.0 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for tiny_thermal_camera-1.0.0.tar.gz
Algorithm Hash digest
SHA256 92a713c513c73636e574732641be93f74aceb9979ee01c448cafa89ea53a0ad7
MD5 7c7f3244567839df85b9af7117967c01
BLAKE2b-256 c843f9013bb52d18d664455624eefd8100b89a4c76882df9c90769d7de5378a2

See more details on using hashes here.

Provenance

The following attestation bundles were made for tiny_thermal_camera-1.0.0.tar.gz:

Publisher: build-wheels.yml on matbeedotcom/Tiny-1C-Python-Bindings

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file tiny_thermal_camera-1.0.0-cp312-cp312-win_amd64.whl.

File metadata

File hashes

Hashes for tiny_thermal_camera-1.0.0-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 bf62ade02658e64c3057e8660cc7bf20f669455256e0725241d39bc3d3bbe178
MD5 ef4b973c687fc0ead9e80a0e44c86f8d
BLAKE2b-256 b141192b612607a6cff065aa4d436142195030f1c5f9f7710caae44c7c8ef87c

See more details on using hashes here.

File details

Details for the file tiny_thermal_camera-1.0.0-cp312-cp312-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for tiny_thermal_camera-1.0.0-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 cc0bfcd4a1269f273e86a826f013993477e6b7b5b9e948ba6e8268c630446b02
MD5 0ca04d5497e730501a2e4f8e1f39a256
BLAKE2b-256 fff643a8a3cbefb0992567b0003f419009c3887048431bf58d9e90e4474f1a11

See more details on using hashes here.

Provenance

The following attestation bundles were made for tiny_thermal_camera-1.0.0-cp312-cp312-manylinux_2_28_x86_64.whl:

Publisher: build-wheels.yml on matbeedotcom/Tiny-1C-Python-Bindings

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file tiny_thermal_camera-1.0.0-cp311-cp311-win_amd64.whl.

File metadata

File hashes

Hashes for tiny_thermal_camera-1.0.0-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 cf600cf744e4c4af5cb9bcd183854578e291c3018d6fd3d3717a9bc79fdecf7b
MD5 ce6a222ce62bfddad2b799c7e752f945
BLAKE2b-256 e963e5ca98da5392fc7d565cf7122229048da998118fc49ce8acdc763726cec3

See more details on using hashes here.

File details

Details for the file tiny_thermal_camera-1.0.0-cp311-cp311-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for tiny_thermal_camera-1.0.0-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 0dba4931e05b96581022f3f4f932a8e7e5048ea99b90d870a52ab7779dfb1081
MD5 d544ab3b846264601fdef5fed1c5b9ae
BLAKE2b-256 d3ec3d5b6bf36599b003b78a7d01291d696126c42f7f13b4cb7646b21700f41f

See more details on using hashes here.

Provenance

The following attestation bundles were made for tiny_thermal_camera-1.0.0-cp311-cp311-manylinux_2_28_x86_64.whl:

Publisher: build-wheels.yml on matbeedotcom/Tiny-1C-Python-Bindings

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file tiny_thermal_camera-1.0.0-cp310-cp310-win_amd64.whl.

File metadata

File hashes

Hashes for tiny_thermal_camera-1.0.0-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 667b5ff3221721e18f99781452db63121c96df72689c76e982298248a50c195b
MD5 c4ae82b715d48b13cefb220c26db5e50
BLAKE2b-256 97dd3382e5cf32d4f03b77a2c17e74823bfd9550d2eaece295db19cc2c5e5c08

See more details on using hashes here.

File details

Details for the file tiny_thermal_camera-1.0.0-cp310-cp310-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for tiny_thermal_camera-1.0.0-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 520216af384da946e325784e6d0bb8641a28a8743dd0777600406f6c6183b8ab
MD5 9203c707973f4de3d173c5f79999ace4
BLAKE2b-256 5eaa7a5ccfb47fb7b779b17c847e86c166ce84d11b732f803dabc226fcfa493a

See more details on using hashes here.

Provenance

The following attestation bundles were made for tiny_thermal_camera-1.0.0-cp310-cp310-manylinux_2_28_x86_64.whl:

Publisher: build-wheels.yml on matbeedotcom/Tiny-1C-Python-Bindings

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file tiny_thermal_camera-1.0.0-cp39-cp39-win_amd64.whl.

File metadata

File hashes

Hashes for tiny_thermal_camera-1.0.0-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 93a495edc341a6820bbea10b9acd2e5bd15b17914a79b4e9de5c2522c84dd06c
MD5 faeccb371eb114359a104f724df9d720
BLAKE2b-256 f739fcf3778b839290dd04a0a2681b826c0b6da2a3ab2e4d031d85ef4d9bd340

See more details on using hashes here.

File details

Details for the file tiny_thermal_camera-1.0.0-cp39-cp39-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for tiny_thermal_camera-1.0.0-cp39-cp39-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 69395a5f3131994897aea993156d6b735c2979ddf8ea967c5a61875c444574bb
MD5 6561a36198130fd9de79f2d13f01c1fa
BLAKE2b-256 8591ac55afc9cb7fd2805d0c19047782a2409de77318e233dc7ab02416743671

See more details on using hashes here.

Provenance

The following attestation bundles were made for tiny_thermal_camera-1.0.0-cp39-cp39-manylinux_2_28_x86_64.whl:

Publisher: build-wheels.yml on matbeedotcom/Tiny-1C-Python-Bindings

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file tiny_thermal_camera-1.0.0-cp38-cp38-win_amd64.whl.

File metadata

File hashes

Hashes for tiny_thermal_camera-1.0.0-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 370502400066a6588dcc934e5ad178d2e69bf3146d64ad82f42e67f6ac07c325
MD5 e831dc7abddb303a3149f2aa8578c997
BLAKE2b-256 d7e7acd6194f6f2497aabe2202a6680eeb375b2ae3f9b47bb569eaa4e099e66f

See more details on using hashes here.

File details

Details for the file tiny_thermal_camera-1.0.0-cp38-cp38-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for tiny_thermal_camera-1.0.0-cp38-cp38-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 0c7eb12d7d42e753bedb2d9da21a788acb4d666aa871401a097c4efe86d5792a
MD5 68e0377e80d5fb9aba811331ecff3915
BLAKE2b-256 d924a410a3524619fbbc8f814bd4c423b8fc0b8bb0ee26947a9ce86e9cce459b

See more details on using hashes here.

Provenance

The following attestation bundles were made for tiny_thermal_camera-1.0.0-cp38-cp38-manylinux_2_28_x86_64.whl:

Publisher: build-wheels.yml on matbeedotcom/Tiny-1C-Python-Bindings

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page