imutils on MPCam
This document describes the forked imutil Python module for the MPCam.
Table Of Contents
- 1 References
- 2 Intro
- 2.1 Local Install
- 3 ImageOutput
- 3.1 HTTP Output
- 3.2 Local Output
- 3.3 Display an Image
- 3.4 Display a Video
- 3.5 Miscellaneous
- 3.5.1 Clear display
- 3.5.2 Wait for Key press
References
Intro
The MPCam image comes preloaded with the imutils Python module.Â
The MPCam imutils is a fork from PyImageSearch's imutils which provides convenient utilities when working with OpenCV. Check the PyImageSearch blog for more details:
Note that you can use the imutils on both your host station or a remote MPCam.
Local Install
If you want to run your scripts on your local host (vs. the MPCam), you'll need to install the imutils on your local development environment.Â
Clone the siana imutils repository
git clone git@github.com:siana-systems/imutils.git
Install the siana imutils module
cd imutils sudo python3 setup.py install
Ensure that you have all of the imutils dependencies installed (see: PyImageSearch imutils)
ImageOutput
PyImageSearch demos & examples often use OpenCV (GTK) to display images or frames on the local screen. For devices that don't include a screen, this is obviously not going to work.
Our first add-on to imutils is a frame-streamer, e.g. ImageOutput, that uses an HTTP server. This extension makes it a lot easier to develop remotely as it allows viewing frames on the local development station.
To use ImageOutput in your code:
Import the ImageOutput class:
from imutils.video import ImageOutput
You then have 2 output options:
using a built-in HTTP server to stream to a remote browser
using gstreamer to open a window on the local host.
HTTP Output
Create a frame-streamer instance using HTTP on port 8080 (default):
Local Output
Create a frame-streamer instance using GStreamer:
You can use both at the same time using 2 separate frame-streamer instances
You can then use the frame-streamer to:
display an image, or
stream a video
Display an Image
Call the show(...) method for each image you want to display:
http_output will display a list of images at http://mpcam.local/<device_ip_address>:8080/title
screen_output will open a GTK window on the local screen
Display a Video
call the stream(…) method:
http_output will open a MJPG stream on http://mpcam.local:8080/title
screen_output will open a GTK window on the local screen
Miscellaneous
Clear display
http_output will remove all images from the local site
screen_output will close all windows
Wait for Key press
Â