Processors Module¶
This module provides classes and functions for processing images and videos using semantic segmentation models.
It includes processors for handling individual files (images or videos) and directories containing multiple video files. The module also manages caching of segmentation results, generation of output visualizations, and analysis of segmentation statistics.
ImageProcessor
¶
Processes individual images using semantic segmentation models.
This class handles the segmentation of single images, including saving results and analyzing the segmentation output.
| ATTRIBUTE | DESCRIPTION |
|---|---|
config |
Configuration object containing processing parameters.
TYPE:
|
pipeline |
Segmentation pipeline for processing images.
|
file_handler |
Handles file operations.
TYPE:
|
visualizer |
Handles visualization of segmentation results.
TYPE:
|
analyzer |
Analyzes segmentation results.
TYPE:
|
Initializes the ImageProcessor with the given configuration.
| PARAMETER | DESCRIPTION |
|---|---|
config |
Configuration object for the processor.
TYPE:
|
Source code in cityseg/processors.py
process
¶
Processes the input image according to the configuration.
This method handles the entire image processing pipeline, including segmentation, result saving, and analysis.
| RAISES | DESCRIPTION |
|---|---|
ProcessingError
|
If an error occurs during image processing. |
Source code in cityseg/processors.py
VideoProcessor
¶
Processes video files using semantic segmentation models.
This class handles the segmentation of video frames, including saving results, generating output videos, and analyzing the segmentation output.
| ATTRIBUTE | DESCRIPTION |
|---|---|
config |
Configuration object containing processing parameters.
TYPE:
|
pipeline |
Segmentation pipeline for processing video frames.
|
processing_plan |
Plan for video processing steps.
TYPE:
|
file_handler |
Handles file operations.
TYPE:
|
visualizer |
Handles visualization of segmentation results.
TYPE:
|
analyzer |
Analyzes segmentation results.
TYPE:
|
Initializes the VideoProcessor with the given configuration.
| PARAMETER | DESCRIPTION |
|---|---|
config |
Configuration object for the processor.
TYPE:
|
Source code in cityseg/processors.py
process
¶
Processes the input video according to the configuration and processing plan.
This method handles the entire video processing pipeline, including frame segmentation, result saving, video generation, and analysis.
| RAISES | DESCRIPTION |
|---|---|
ProcessingError
|
If an error occurs during video processing. |
Source code in cityseg/processors.py
generate_videos
¶
Generates output videos based on the processing plan, using batched processing.
| PARAMETER | DESCRIPTION |
|---|---|
segmentation_data |
The segmentation data for all frames.
TYPE:
|
metadata |
Metadata about the video and segmentation.
TYPE:
|
Source code in cityseg/processors.py
SegmentationProcessor
¶
Handles segmentation processing for both images and videos.
This class serves as a facade for ImageProcessor and VideoProcessor, delegating the processing based on the input type.
| ATTRIBUTE | DESCRIPTION |
|---|---|
config |
Configuration object containing processing parameters.
TYPE:
|
image_processor |
Processor for handling image inputs.
TYPE:
|
video_processor |
Processor for handling video inputs.
TYPE:
|
Initializes the SegmentationProcessor with the given configuration.
| PARAMETER | DESCRIPTION |
|---|---|
config |
Configuration object for the processor.
TYPE:
|
Source code in cityseg/processors.py
process
¶
Processes the input based on its type (image or video).
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If the input type is not supported. |
Source code in cityseg/processors.py
DirectoryProcessor
¶
Processes multiple video files in a directory.
This class handles the batch processing of video files found in a specified directory.
| ATTRIBUTE | DESCRIPTION |
|---|---|
config |
Configuration object containing processing parameters.
TYPE:
|
video_iterator |
Iterator for video files in the directory.
TYPE:
|
logger |
Logger instance for this processor.
|
Initializes the DirectoryProcessor with the given configuration.
| PARAMETER | DESCRIPTION |
|---|---|
config |
Configuration object for the processor.
TYPE:
|
Source code in cityseg/processors.py
process
¶
Processes all video files in the specified directory.
This method iterates through all video files, processing each one according to the configuration.
| RAISES | DESCRIPTION |
|---|---|
InputError
|
If no video files are found in the directory. |
Source code in cityseg/processors.py
create_processor
¶
Creates and returns the appropriate processor based on the input type.
| PARAMETER | DESCRIPTION |
|---|---|
config |
Configuration object containing processing parameters.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Union[SegmentationProcessor, DirectoryProcessor]
|
Union[SegmentationProcessor, DirectoryProcessor]: The appropriate processor instance. |
Source code in cityseg/processors.py
ProcessingPlan
¶
A class to create and manage the processing plan for video segmentation tasks.
This class determines which processing steps need to be executed based on the configuration and the existence of previously generated outputs.
| ATTRIBUTE | DESCRIPTION |
|---|---|
config |
Configuration object containing processing parameters.
TYPE:
|
plan |
A dictionary indicating which processing steps to execute.
TYPE:
|
Initializes the ProcessingPlan with the given configuration.
| PARAMETER | DESCRIPTION |
|---|---|
config |
Configuration object for the processing plan.
TYPE:
|
Source code in cityseg/processing_plan.py
VideoFileIterator
¶
An iterator class for iterating over video files in a specified directory.
This class retrieves and stores video files from the given input path and provides an iterator interface to access these files.
| ATTRIBUTE | DESCRIPTION |
|---|---|
input_path |
The path to the directory containing video files.
TYPE:
|
video_files |
A list of video file paths found in the input directory.
TYPE:
|
Initializes the VideoFileIterator with the specified input path.
| PARAMETER | DESCRIPTION |
|---|---|
input_path |
The path to the directory containing video files.
TYPE:
|
Source code in cityseg/video_file_iterator.py
__iter__
¶
Returns an iterator over the video files.
This method allows the VideoFileIterator to be used in a for-loop or any context that requires an iterable.
| RETURNS | DESCRIPTION |
|---|---|
Iterator[Path]
|
Iterator[Path]: An iterator over the video file paths. |