Skip to main content

Don't reinvent the wheel every time! This library offers a curated collection of commonly used image manipulation functions for computer vision projects.

Project description

Common Image Tools

Latest Stable Version PyPI - Downloads

Poetry Ruff Coverage Status example workflow

Description

common_image_tools is a repository containing a curated collection of commonly used image manipulation functions for computer vision projects. These tools provide a set of handy functions for performing various image processing tasks, such as resizing, cropping, filtering, and more.

Features

  • Resizing: Easily resize images to desired dimensions.
  • Cropping: Crop images to focus on specific regions.
  • Filtering: Apply various filters to enhance or modify images.
  • Conversion: Convert images between different formats.
  • Visualization: Tools for visualizing image data.
  • Video Source: Flexible interface for handling different types of video inputs.

Installation

To install common_image_tools, run the following command:

pip install common-image-tools

or using poetry:

poetry add common-image-tools

Usage

Video Source

The VideoSource class provides a flexible interface for handling different types of video inputs with support for various OpenCV backends and hardware acceleration on Jetson devices.

Features

  • Support for multiple video source types:
    • RTSP streams
    • Video files (MP4)
    • Webcam devices
  • Configurable frame dimensions and FPS
  • Multiple backend options:
    • OpenCV default
    • GStreamer
    • GStreamer with Jetson hardware acceleration
  • Automatic backend selection based on system capabilities

Basic Usage

from common_image_tools import VideoSource
import cv2

# Create a video source
source = VideoSource(
    "video.mp4",
    target_frame_height=720,
    target_frame_width=1280,
    target_fps=30
)

# Use with OpenCV
cap = cv2.VideoCapture(source.parsed_source)

Different Source Types

# RTSP Stream
rtsp_source = VideoSource("rtsp://example.com/stream")

# Video File
file_source = VideoSource("path/to/video.mp4")

# Webcam
webcam_source = VideoSource("/dev/video0")

# Webcam
webcam_source = VideoSource(0)

Backend Selection

from common_image_tools import VideoSource, OpencvBackendMode

# Auto backend selection (default)
source = VideoSource("video.mp4")

# Force OpenCV default backend
source = VideoSource(
    "video.mp4",
    opencv_backend=OpencvBackendMode.OPENCV_DEFAULT
)

# Force GStreamer backend
source = VideoSource(
    "video.mp4",
    opencv_backend=OpencvBackendMode.OPENCV_GSTREAMER
)

# Use Jetson-optimized GStreamer backend
source = VideoSource(
    "video.mp4",
    opencv_backend=OpencvBackendMode.OPENCV_GSTREAMER_JETSON
)

API Reference

VideoSource
VideoSource(
    source,
    target_frame_height: int = None,
    target_frame_width: int = None,
    target_fps: int = None,
    opencv_backend: OpencvBackendMode = OpencvBackendMode.AUTO
)

Conversion

Operation

Tool

Verification

Visualization

Contributing

Contributions are welcome! If you have any suggestions, improvements, or new features to add, please open an issue or submit a pull request. Make sure to follow the existing coding style and include appropriate tests.

License

This project is licensed under the MIT License - see the LICENSE file for details.

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

common_image_tools-0.5.18.tar.gz (11.1 kB view details)

Uploaded Source

Built Distribution

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

common_image_tools-0.5.18-py3-none-any.whl (12.7 kB view details)

Uploaded Python 3

File details

Details for the file common_image_tools-0.5.18.tar.gz.

File metadata

  • Download URL: common_image_tools-0.5.18.tar.gz
  • Upload date:
  • Size: 11.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.0.1 CPython/3.12.8

File hashes

Hashes for common_image_tools-0.5.18.tar.gz
Algorithm Hash digest
SHA256 006d1040a872cc53d95c320dcd4b206f2ac1eee4b10f9a8e447c206922f28591
MD5 f9e03a0716df12f75a1c323932a9f3fe
BLAKE2b-256 a397c5d4e0ecf7dc5efae128098ee1b001c0819ef9dcc750d1721ee7a5b2acf3

See more details on using hashes here.

Provenance

The following attestation bundles were made for common_image_tools-0.5.18.tar.gz:

Publisher: release.yml on lanzani/common-image-tools

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

File details

Details for the file common_image_tools-0.5.18-py3-none-any.whl.

File metadata

File hashes

Hashes for common_image_tools-0.5.18-py3-none-any.whl
Algorithm Hash digest
SHA256 5e86aaf0e651c62cd11d3e29ce31fc8735c9c8479ae83e84322e3bf79fe8a966
MD5 3506792194036c3805fd4f51aab78a0a
BLAKE2b-256 81cab2afc970f900d8deaa6213bfc9ce1ca291e4b78f8bca9b12c3f578673ba9

See more details on using hashes here.

Provenance

The following attestation bundles were made for common_image_tools-0.5.18-py3-none-any.whl:

Publisher: release.yml on lanzani/common-image-tools

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