Skip to main content

Simple OpenCV 3.x image processing functions

Project description

OpenCV Utilities
===================

.. image:: https://travis-ci.org/MomsFriendlyRobotCompany/opencvutils.svg?branch=master
:target: https://travis-ci.org/MomsFriendlyRobotCompany/opencvutils
:alt: Travis-ci
.. image:: https://img.shields.io/pypi/v/opencvutils.svg
:target: https://pypi.python.org/pypi/opencvutils/
:alt: Latest Version
.. image:: https://img.shields.io/pypi/l/opencvutils.svg
:target: https://pypi.python.org/pypi/opencvutils/
:alt: License


This is a set of OpenCV utilities that should make working with OpenCV a little
easier.

**Original Author:** Adrian Rosebrock

**Original Name:** `imutils <https://github.com/jrosebr1/imutils>`_


Install
--------

The preferred way to install is using ``pip``::

pip install opencvutils

Other Libraries
~~~~~~~~~~~~~~~~~

You will need both ``numpy`` and ``opencv3`` for this to work. Use your os package
manager to install. Unfortunately this is not fast, ``numpy`` install involves
compiling things, so go grab a coffee or something while you wait.

for macOS::

pip install numpy
brew install opencv3 --with-ffmpeg --with-tbb --without-numpy
brew link -f opencv3

there are other options that would work too.

Development
------------

To submit git pulls, clone the repository and set it up as follows::

git clone https://github.com/walchko/opencvutils
cd opencvutils
pip install -e .

Documentation
---------------

See the `Jupyter Notebooks <https://github.com/walchko/opencvutils/tree/master/docs>`_
for examples of how to use this library. It contains a lot of common image manipulations.

Video
~~~~~~~

You can make a video like this:

.. code-block:: python

import cv2
from opencvutils.Camera import SaveVideo

shape = (240,320) # rows (height), cols (width)
sv = SaveVideo()

# you can change the default encoder using a four_cc string
# sv.encoder('H264')
# sv.encoder('MP4V')
# sv.encoder('x264')

sv.open(filename, shape[1], shape[0]) # order is backwards from opencv!!!!

for i in range(100):
ret, img = camera.read() # grab image
sv.write(img)

sv.release()

Scripts
~~~~~~~~~

.. code-block:: bash

pi@raspberry ~ $ mjpeg_server.py -h
usage: mjpeg_server.py [-h] [-v] [-p PORT] [-c CAMERA] [-t TYPE]
[-s SIZE SIZE]

A simple mjpeg server Example: mjpeg-server -p 8080 --camera 4

optional arguments:
-h, --help show this help message and exit
-v, --version show program's version number and exit
-p PORT, --port PORT mjpeg publisher port, default is 9000
-c CAMERA, --camera CAMERA
set opencv camera number, ex. -c 1
-t TYPE, --type TYPE set camera type, either pi or cv, ex. -t pi
-s SIZE SIZE, --size SIZE SIZE
set size
Then you could do::

pi@raspberry ~ $ mjpeg_server.py -t pi -s 640 480

now navigate to your computer (hostname:9000) and you should see the mjpg stream.
Note, if you changed the port number with the ``-p`` arg, then use that port
number.

Change Log
-------------

========== ======= =============================
2017-10-29 0.9.3 bug fixes
2017-04-09 0.9.0 initial python 3 support
2017-03-31 0.7.0 refactored and got rid of things I don't need
2017-01-29 0.6.0 added video capture (video and images) program
2016-12-30 0.5.3 typo fix
2016-12-30 0.5.1 refactored
2016-12-11 0.5.0 published to PyPi
========== ======= =============================

MIT License
----------------

Copyright (c) 2016 Kevin J. Walchko

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.


Project details


Release history Release notifications

This version
History Node

0.9.3

History Node

0.9.2

History Node

0.9.1

History Node

0.9.0

History Node

0.8.0

History Node

0.7.0

History Node

0.5.8

History Node

0.5.7

History Node

0.5.6

History Node

0.5.5

History Node

0.5.4

History Node

0.5.3

History Node

0.5.2

History Node

0.5.1

History Node

0.5.0

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, size & hash SHA256 hash help File type Python version Upload date
opencvutils-0.9.3-py2-none-any.whl (23.1 kB) Copy SHA256 hash SHA256 Wheel py2 Oct 29, 2017
opencvutils-0.9.3-py3-none-any.whl (23.1 kB) Copy SHA256 hash SHA256 Wheel py3 Oct 29, 2017
opencvutils-0.9.3.tar.gz (15.1 kB) Copy SHA256 hash SHA256 Source None Oct 29, 2017

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging CloudAMQP CloudAMQP RabbitMQ AWS AWS Cloud computing Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page