Extending edgertronic capabilities - Extending edgertronic camera functionality

From edgertronic high speed video camera
Jump to navigation Jump to search


Extending the functions

Replace with the IP address being used by your camera.

This is an experimental camera feature first supported in version 2.1. If you are familiar with the python programming language, the edgertronic camera offers an easy way to add code that runs when the camera powers on and also allows you to add URLs such that your code executes when the added URL is retrieved.

The unreleased camera software version 2.2 supports a more powerful interface to allow multiple application extension files to be added. The version 2.1 app_ext.py will need to be slightly modified to work with 2.2 and later software releases.

Example uses:

  • Multishot auto save - Automatic save of multi-shot videos if the camera is idle for more than a specified timeout value.
  • Hardware watchdog timer - Enable the DM368 hardware watchdog timer to reboot the camera if the python code stops responding.
  • USB serial support - Control a RS-232 serial device, such as a uninterruptible power supply, over the network using the camera by using an USB serial dongle.
  • Auto download videos - After the camera is finished saving the video file, copy the file over the network using ftp or scp.
  • Email alert - Send an email when the storage device starts getting full.
  • Extending the web user interface - add your own configuration and status information to the browser UI presented to the user.

Quick start

  1. Store a file named app_ext.py on the SD card root directory and power cycle the camera. An example app_ext.py file can be found on the camera at
  2. Power cycle the camera
  3. If you used the example app_ext.py as your starting point, browse to camera URL to verify the new URLs were properly registered
  4. If the URLs were not registered, browser to the camera URL and look in the log file for the message No app_ext.py found or the message Loading app_ext.py.


When the camera is starting, the lighttpd web server loads /home/root/ss-web/app.fcgi, which creates a python process to handle CAMAPI that come though the embedded web server. app.fcgi loads app.py, which is the code that exports all the CAMAPI methods as URLs. As a developer, you can consider app.py as an example showing how to properly use CAMAPI. The source code to app.py can be found at .

To support developer added URLs and code that runs when the camera is powered on, app.py imports app_ext.py if that file exists in the SD card root directory.

Very simple app_ext.py

Here is the bare bones recommended app_ext.py framework. If you excel at python, you can turn URLs into a constant structure instead of it being defined in a method. If you are familiar with flash, you can likely do a much better job with the HTML. Given all that, the following code works and is mostly sane.

# Expose the URL /check
# This file is imported by app.py.
# Copyright 2014 by Sansteak Corp.

class AppExt(object):
    # Class variables
    app = None
    cam = None
    ci = None

    def _return_urls(self):
        URLS = [
            ( '/check', self.check, "Verify This page" ),
        return URLS

    def __init__(self, _app, _cam, _ci):
        self.app = _app
        self.cam = _cam
        self.ci = _ci

        for (url, func, desc) in self._return_urls():
            _app.add_url_rule(url, view_func=func)

    def check(self):
        Simply way to see if the external URLs have been successfully loaded.
        Provides a clickable link to all the user added URLs.
        html = "<!DOCTYPE html>\n<html><head>\n" + \
               "<title>User added edgertronic URLs</title></head>\n" + \
        for (url, func, desc) in self._return_urls():
            html += "<li><a href=" + url + ">" + desc + "</a>\n"
        html += "</ul></body></html>"
        return html

app_ext.py code comments:

  • Must define the AppExt class
  • The __init__ method accepts three parameters
    • app - flask object that allows you to add URLs
    • cam - CAMAPI object that allows you to make CAMAPI calls
    • ci - camera information object - see the caminfo pydoc for details
  • For the Sanstreak created a app_ext.py examples, we have a /check URL that provides a clickable link to all the user added URLs. To make this easier to follow, the URLs, description, and method that gets called are define in the _return_urls() method.

You can see how app, cam, and ci are used by examining the app.py source.


Extending the functions