Git Product home page Git Product logo

cctvweb's Introduction

CCTVweb

Browse and manage JPEG images written to FTP by IQinvision IQeye IP cameras, in a nice web-based app!

JPEGs are grouped together into events, and events can be replayed in real-time or by mouse movement. The player is a still-frame player based on open web technologies.

Architecture

CCTVweb currently depends on the JPEG comment (COM) fields written by IQinvision IQeye network cameras. Cameras are responsible for FTP'ing images, but no further intelligence is needed from them, the indexing, management, and playback is handled by CCTVweb.

Implemented Features

  • Completely web-based viewer, no plugins required
    • Play events forwards/backwards
  • Scroll through events frame-by-frame
  • Fast JPEG indexing
  • AngularJS frontend
  • Fast backend engine for returning image data
  • Nice graphs of camera activity
  • CORS support and static file serving

Planned Features

  • Preview all events for a single day
  • Play events sequentially
  • Support for live viewer and "popping" interesting cameras to foreground
  • Set alert thresholds
    • ie. if camera is recording over 25% more motion today than yesterday, send an email
  • Excellent support for small/cheap computers (CHiP, Raspberry Pi)
  • Support for Google Cloud Storage
  • Image recognition capability using Google Machine Vision
  • Support for relays (for door locks), HTTP triggers
  • Camera settings query and management

Requirements

  • Linux server
  • nginx/lighttpd
  • python2
    • virtualenv
    • flask
    • Flask-RESTful
  • sqlite3
  • nodejs

Installation

  1. git clone the source
  2. Install prereqs
  3. Import sample data from .csv into DB
  4. Config app and nginx/lighttpd
  5. Copy static files to your webserver or CDN
  6. Run the backend
  7. Open the frontend in a browser

Python2

  1. Install Python2, virtualenv
  2. Create virtualenv and activate it
    • virtualenv -p /usr/bin/python2 ./new-environment
    • source ./new-environment/bin/activate
  3. Install the pip packages (the other dependencies will be automatically pulled)
    • pip install -r requirements.txt

Camera FTP configuration

  1. Update your cameras to the latest firmware IQinvision.
  2. Under the Trigger tab, set up FTP to write images, recommended to save each camera to its own directory and limit per-directory contents to less than 10,000 JPEGs
    • See docs/iqinvision.md

cctvweb's People

Contributors

jaygoldberg avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

cctvweb's Issues

Create README.md

Need to document what the scope of the project is, such as Requirements, Installation, Architecture.

Figure out how to remove virtualenv from repo

Virtualenv environment is tied to the system that you instantiated it on. There are paths that are unique in that generated environment that make it impossible to move from one machine to another, and security implications as well. It is advised not to include your virtualenv in your GitHub repo.

Now I just have to figure out how to do that!

Work around 6 concurrent HTTP request limit

By default, a browser will only run 6 concurrent requests to a single IP or CNAME. This is probably limiting the concurrency that is possible with powerful clients/servers and especially with object-stores like Amazon S3, OpenStack Swift (which I plan on supporting in CCTVweb). I do believe in those cases however, that those services explicitly distribute the URIs for resources over randomly generated CNAMES.

Ways to get around:

  1. Make a config option that allows you to specify a pool of CNAMES to "load balance" requests for JPEG frames from the event viewer.
  2. Tell the user to use DNS LB or somesuch? (bad practice though, DNS is not meant for LB)
  3. Wildcard ephemeral/imaginary domains in DNS

Implement frame "deletion"

Should go under a DELETE method, specify start and end frame in milliseconds since epoch. On the backend this just adds a field in each record "isDeleted: True".

Then, subsequent queries will not return those records.

Later implement a prune function that actually deletes the JPEGs to free space.

allow static asset serving from root

index.html and static content serving from Flask. Gotta figure out if we can define routes both for API and for render_template in the same app.py file.

Make config file

Create a config file for the Flask application:

serve_static_assets=True
domainname=domain.com
max-return-size= #max number of records to return in a single operation
debug=True
mongo_server=localhost
mongo_username=user
mongo_password=password
mongo_collection=images

Get and store camera settings

using http://[ip of camera]/get.oid?TR3.4 style (IQeye API)

Place in a table called oids or camsettings.

How to do it on a schedule?

  • Can also be used to graph things like image gain values, etc.

scraper.bash is too complicated

I've made this dependent on the folder structure that the images are saved to, and this is not good practice because

  1. the user may have their own file structure and ideas already
  2. it is fragile in general
  3. the code looks nasty

Instead, we should use find, which should be on all platforms anyway.

Auto-deletion script

Script to delete JPEGs from storage on a recurring basis. Either driven by crontab or external HTTP trigger. Need to clear the image_delete SQL table when completed.

Enable nginx static file caching

Make sure to tell the client which resources can be cached and for how long. Since this isn't a single page application and .js must be loaded every time a page is opened, we can hopefully speed this up by taking advantage of browser caching.

Scraper script writes filename even if reading the comment fails (not a JPEG, corruption, etc)

result is like so:

/share/Recordings/iq/m32n/04-13/14/14_51_22.trig-1.jpg,{"IQimage":{"sequence":141767,"time":1397400676692,"imgjdbg":"448/000:00/119/008:100/100/01/4/45/80/15/08/00/00/00:3f"}}
/share/Recordings/iq/m32n/04-13/14/14_51_22.trig-2.jpg,/share/Recordings/iq/m32n/04-13/14/14_51_43.trig+0.jpg,{"IQimage":{"sequence":142079,"time":1397400701464,"imgjdbg":"483/000:00/119/024:100/100/01/4/45/80/15/08/00/00/00:41"}}
/share/Recordings/iq/m32n/04-13/14/14_51_43.trig+1.jpg,{"IQimage":{"sequence":142090,"time":1397400701500,"imgjdbg":"483/000:00/119/024:100/100/01/4/45/80/15/08/00/00/00:41"}}
/share/Recordings/iq/m32n/04-13/14/14_51_43.trig-1.jpg,{"IQimage":{"sequence":142077,"time":1397400697390,"imgjdbg":"456/000:00/119/012:100/100/01/4/45/80/15/08/00/00/00:40"}}

either commit the entire line, or nothing.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.