imutils on MPCam

This document describes the forked imutil Python module for the MPCam.

Table Of Contents


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. 

  1. Clone the siana imutils repository

    git clone git@github.com:siana-systems/imutils.git
  2. 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:

  1. using a built-in HTTP server to stream to a remote browser

  2. 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:

    1. http_output will display a list of images at http://mpcam.local/<device_ip_address>:8080/title

    2. screen_output will open a GTK window on the local screen

Display a Video

  • call the stream(…) method:

    1. http_output will open a MJPG stream on http://mpcam.local:8080/title

    2. 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

Â