https://github.com/centralelyon/ntt
Video and image processing tools.
https://github.com/centralelyon/ntt
image-processing sports-analytics video-processing wrapper-library
Last synced: 4 months ago
JSON representation
Video and image processing tools.
- Host: GitHub
- URL: https://github.com/centralelyon/ntt
- Owner: centralelyon
- Created: 2023-04-04T06:44:37.000Z (about 3 years ago)
- Default Branch: dev
- Last Pushed: 2026-02-25T15:10:08.000Z (4 months ago)
- Last Synced: 2026-02-25T16:42:32.228Z (4 months ago)
- Topics: image-processing, sports-analytics, video-processing, wrapper-library
- Language: Python
- Homepage: https://pypi.org/project/ntt/
- Size: 110 MB
- Stars: 2
- Watchers: 2
- Forks: 1
- Open Issues: 13
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
Awesome Lists containing this project
README
# ntt
[](https://dl.circleci.com/status-badge/redirect/gh/centralelyon/ntt/tree/main)
[](https://ntt.readthedocs.io/en/latest/?badge=latest)
`ntt` is a Python module that provides simple and consistent interfaces for common image and video processing tasks. It wraps around popular Python libraries to simplify their usage and make them interchangeable, to build complex pipelines. In particular:
* [**Pillow**](https://python-pillow.org/) – image file handling
* [**OpenCV**](https://opencv.org/) – computer vision, image and video processing
* [**imageio**](https://imageio.github.io/) – read/write images and videos
* [**scikit-image**](https://scikit-image.org/) – scientific image processing
* [**NumPy**](https://numpy.org/) – arrays and calculations
## Installation
### Using `venv` (recommended)
1. **Create a virtual environment:**
```bash
python -m venv venv
```
2. **Activate the environment:**
* On macOS/Linux:
```bash
source venv/bin/activate
```
* On Windows:
```bash
venv\Scripts\activate
```
3. **Install the module:**
The module is available on [Pypi](https://pypi.org/project/ntt/):
```bash
pip install ntt
```
Or install the development version from source:
```bash
git clone
pip install -e .
```
## Tests
```python
import ntt
print(ntt.__version__) # Check the version
```
Assuming you have cloned the repository or installed the source package, you can run tests with `pytest`:
```bash
$ pytest tests
```
## Samples
To download the data samples (videos, images, sounds, etc.) used in tests and examples, clone the repository and update the `.env` file with the path to the cloned folder:
```
git clone https://github.com/centralelyon/ntt-samples.git
```
Alternatively, you can generate fake videos samples by running the following script:
```python
from ntt.videos.video_generation import random_video
video = random_video(320, 240, 10, 2)
```
## Building pipelines
An interesting use of `ntt` is to build complex pipelines for video and image processing. For that, we also built a separate tool, the [Pipeoptz](https://github.com/centralelyon/pipeoptz/) library, which provides a simple way to create and manage pipelines of functions.
The image above is generated using the code below available as a [gist](https://gist.github.com/romsson/5e83ae6dbadf4175e3bbc1454a44a939).
```python
import random
from ntt.frames.frame_generation import random_frame
from ntt.frames.display import display_frame
from pipeoptz import Pipeline, Node
def random_number():
num = random.randint(100, 600)
return num
pipeline = Pipeline("Simple Pipeline", "Generate a random image.")
node_gen_width = Node("GenWidth", random_number)
node_gen_height = Node("GenHeight", random_number)
node_random_frame = Node(
"random_frame", random_frame, fixed_params={"width": 10, "height": 3}
)
pipeline.add_node(node_gen_width)
pipeline.add_node(node_gen_height)
pipeline.add_node(
node_random_frame, predecessors={"width": "GenWidth", "height": "GenHeight"}
)
outputs = pipeline.run()
display_frame(outputs[1][pipeline.static_order()[-1]])
```
## Examples
You may look at the `examples` folder to see how to use `ntt` functions. Also a look a the `tests` folder to see how functions are tested. And of course, the documentation at [https://ntt.readthedocs.io](https://ntt.readthedocs.io).
Assuming you have a `crop.mp4 ` video in a `samples` folder and an `output`
folder, here is how to use `extract_first_frame` function.
```python
import os
from dotenv import load_dotenv
from ntt.frames.frame_extraction import extract_first_frame
if __name__ == "__main__":
load_dotenv()
output = extract_first_frame(
video_path_in=os.environ.get("NTT_SAMPLES_PATH"),
video_name_in="crop.mp4",
frame_path_out=os.environ.get("PATH_OUT"),
frame_name_out="crop-ex.jpg",
)
print(f"Frame successfully extracted at {output}") if output is not None else print(
"Frame extraction failed"
)
```
## CircleCI
The project is configured to run tests on CircleCI. The configuration file is
`.circleci/config.yml`.
## Docker
A Dockerfile is provided to quickly set up an environment with all system dependencies (OpenCV, FFmpeg, etc.) and run tests or scripts.
### Build the image
```bash
docker build -t ntt .
```
### Run tests
By default, running the container executes the `pytest` test suite:
```bash
# Run tests using the code inside the container
docker run --rm ntt
```
During development, you can mount your local directory to run tests on your current code:
```bash
# Linux / macOS / Windows PowerShell
docker run --rm -v ${PWD}:/app ntt
# Windows Command Prompt (cmd)
docker run --rm -v "%cd%:/app" ntt
```
### Run a custom script
You can override the default command to run a specific Python script:
```bash
docker run --rm -v ${PWD}:/app ntt python tests/test_random_strings.py
```
### Run in interactive mode
To explore the container or run multiple commands manually, start a bash shell:
```bash
docker run --rm -it -v ${PWD}:/app ntt bash
```
## Acknowledgments
