Skip to main content

A library for applying realistic camera occlusion effects like rain and dust for computer vision data augmentation.

Project description

Realistic Camera Occlusion Effects for Computer Vision

This project provides a Python library and tools for applying realistic, parameterized camera occlusion effects like rain and dust to images. It's designed for data augmentation in computer vision tasks, such as training a traffic sign classifier to be more robust against adverse conditions.

Example noise image

Quick Start

pip install ...
obscure-image GTSRB_dataset/GTSRB/Final_Training/Images/00000/00000_00000.ppm  out.ppm --effect rain

Features

  • Rain Effect: Simulates raindrops on a camera lens with distortion, shading, and highlights.
  • Dust Effect: Simulates fine dust specks, scratches, and semi-transparent grime splotches.
  • PyTorch Integration: Includes a Dataset class for on-the-fly data augmentation during model training.
  • Command-Line Tools: Apply effects to single images or train a model directly from the command line.

Installation

  1. Clone the repository:

    git clone [https://github.com/your-username/german_signs.git](https://github.com/your-username/german_signs.git)
    cd german_signs
    
  2. Create and activate a virtual environment (recommended):

    python3 -m venv venv
    source venv/bin/activate
    
  3. Install the required packages:

    pip install -r requirements.txt
    

Usage

There are three main ways to use this project:

1. As a Python Library

You can easily import and use the Rain and Dust effect classes in your own scripts.

import imageio.v2 as imageio
from camera_occlusion import Rain

# Load an image
image = imageio.imread("path/to/your/image.jpg")

# Apply a heavy rain effect
heavy_rain = Rain(num_drops=100, radius_range=(4, 8))
augmented_image = heavy_rain(image)

# Save or display the result
imageio.imwrite("rainy_image.jpg", augmented_image)

2. Gallery Demonstration

To see a gallery of all available effects and presets, run the example script. This will generate a plot showing various levels of rain and dust.

python examples/run_gallery.py

3. Training a Model

The train_model.py script trains a simple CNN on the German Traffic Sign Recognition Benchmark (GTSRB) dataset. You can specify different augmentation effects for the training and validation sets.

  1. Download the data: You must first download the GTSRB dataset and place the training images in a GTSRB/ directory. You can find the data here: GTSRB Dataset. Your structure should look like GTSRB/Final_Training/Images/00000/....

  2. Run training: The following command trains a model on images with "heavy dust" and evaluates it on images with "light rain".

    python train_model.py \
        --data-dir GTSRB/Final_Training/Images/ \
        --epochs 15 \
        --train-effect heavy_dust \
        --eval-effect light_rain \
        --save-path models/dusty_model.pth
    

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

camera_occlusion-0.1.0.tar.gz (7.0 kB view details)

Uploaded Source

Built Distribution

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

camera_occlusion-0.1.0-py3-none-any.whl (8.0 kB view details)

Uploaded Python 3

File details

Details for the file camera_occlusion-0.1.0.tar.gz.

File metadata

  • Download URL: camera_occlusion-0.1.0.tar.gz
  • Upload date:
  • Size: 7.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for camera_occlusion-0.1.0.tar.gz
Algorithm Hash digest
SHA256 0c8f133d2d5460e5aa61d67a0284c0dcb42b7e61fa67ccd27a9f96195baf6ac4
MD5 b13afe848d640e775590f42873ab70fb
BLAKE2b-256 5276e018dd2a3a092f07113e80b0667637d6c6d2cefc718020c10eb3a6b40314

See more details on using hashes here.

Provenance

The following attestation bundles were made for camera_occlusion-0.1.0.tar.gz:

Publisher: publish.yml on kilojoules/camera_occlusion

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

File details

Details for the file camera_occlusion-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for camera_occlusion-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b5a7191172268ae622d55bf7e1e638dff0eb5f39e6291d3c092224271c938d63
MD5 e44257fc344115ab24ff15d9beb40265
BLAKE2b-256 4c226ded4cc984ba49064817188984833101adea7078af2590991cfe6afaa2f9

See more details on using hashes here.

Provenance

The following attestation bundles were made for camera_occlusion-0.1.0-py3-none-any.whl:

Publisher: publish.yml on kilojoules/camera_occlusion

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