Skip to main content
# Introduction

[![PyPI Version](https://img.shields.io/pypi/v/cvbase.svg)](https://pypi.python.org/pypi/cvbase)
[![Python Version](https://img.shields.io/pypi/pyversions/cvbase.svg)]()
[![Build Status](https://travis-ci.org/hellock/cvbase.svg?branch=master)](https://travis-ci.org/hellock/cvbase)
[![Coverage Status](https://codecov.io/gh/hellock/cvbase/branch/master/graph/badge.svg)](https://codecov.io/gh/hellock/cvbase)


`cvbase` is a miscellaneous set of tools which maybe helpful for computer vision research.
It comprises the following parts.

- IO helpers
- Image/Video operations
- OpenCV wrappers for python2/3 and opencv 2/3
- Timer
- Progress visualization
- Plotting tools
- Object detection utils

Try and start with

```shell
pip install cvbase
```

See [documentation](http://cvbase.readthedocs.io/en/latest) for more features and usage.

## Some popular features
There are some popular features such as progress visualization, timer, video to frames/frames to videos.


- Progress visualization

If you want to apply a method to a list of items and track the progress, `track_progress`
is a good choice. It will display a progress bar to tell the progress and ETA.

```python
import cvbase as cvb

def func(item):
# do something
pass

tasks = [item_1, item_2, ..., item_n]

cvb.track_progress(func, tasks)
```

The output is like the following.
![progress](docs/_static/progress.gif)

There is another method `track_parallel_progress`, which wraps multiprocessing and
progress visualization.

```python
import cvbase as cvb

def func(item):
# do something
pass

tasks = [item_1, item_2, ..., item_n]

cvb.track_parallel_progress(func, tasks, 8)
# 8 workers
```

- Timer

It is convinient to computer the runtime of a code block with `Timer`.

```python
import time

with cvb.Timer():
# simulate some code block
time.sleep(1)
```

Or try a more flexible way.

```python
timer = cvb.Timer()
# code block 1 here
print(timer.since_start())
# code block 2 here
print(timer.since_last_check())
print(timer.since_start())
```

- Video/Frames conversion

To split a video into frames.

```python
video = cvb.VideoReader('video_file.mp4')
video.cvt2frames('frame_dir')
```
Besides `cvt2frames`, `VideoReader` wraps many other useful methods to operate a video like a list object, like

```
video = cvb.VideoReader('video_file.mp4')
len(video) # get total frame number
video[5] # get the 6th frame
for img in video: # iterate over all frames
print(img.shape)
```

To generate a video from frames, use the `frames2video` method.

```python
video = cvb.frames2video('frame_dir', 'out_video_file.avi', fps=30)
```

- Video editing (needs ffmpeg)

To cut a video.

```python
cvb.cut_video('input.mp4', 'output.mp4', start=3, end=10)
```

To join two video clips.

```python
cvb.concat_video(['clip1.mp4', 'clip2.mp4'], 'output.mp4')
```

To resize a video.

```python
cvb.resize_video('input.mp4', 'resized.mp4', (360, 240))
# or
cvb.resize_video('input.mp4', 'resized.mp4', ratio=2)
```

To convert the format of a video.

```python
cvb.convert_video('input.avi', 'output.mp4', vcodec='h264')
```



Release files for cvbase 0.5.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for cvbase 0.5.5
File Size Uploaded
cvbase-0.5.5.tar.gz 39.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for cvbase 0.5.5
File Interpreter ABI Platform
cvbase-0.5.5-py2.py3-none-any.whl Python 2, Python 3 none any Details

Total release size: 85.3 kB

Release files / cvbase-0.5.5.tar.gz

Download URL cvbase-0.5.5.tar.gz
Size 39.8 kB
Tags Source
SHA-256 checksum
How to use checksums
512fc242b4abd0d9d2a81b087b0793b21f4833982c37941f843d18af54c5ac36
BLAKE2b-256 checksum
How to use checksums
828bfb6289cfa92853d67318f5019fb31f07bf9af3649fd2e3f9a43a530c69a2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / cvbase-0.5.5-py2.py3-none-any.whl

Download URL cvbase-0.5.5-py2.py3-none-any.whl
Size 45.5 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
536bda2ae6d3aaec092f2e9045017d24d54513e7572341179bbe03c2d282e665
BLAKE2b-256 checksum
How to use checksums
7408551f262dd4535424b19723f686b84ac30b436d996191f90de42d739db64c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

0.5.5 This release

2 release files

0.5.4

2 release files

0.5.3

2 release files

0.5.2

2 release files

0.5.1

2 release files

0.5.0

2 release files

0.4.0

2 release files

0.3.6

2 release files

0.3.5

2 release files

0.3.4

2 release files

0.3.3

2 release files

0.3.2

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.9

2 release files

0.2.8

2 release files

0.2.7

2 release files

0.2.6

2 release files

0.2.5

2 release files

0.2.4

2 release files

0.2.3

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.9

2 release files

0.1.8

2 release files

0.1.7

2 release files

0.1.6

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

0.0.9

2 release files

0.0.8

2 release files

0.0.7

2 release files

0.0.6

2 release files

0.0.5

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page