Giter Club home page Giter Club logo

cordova-cameraserver's Introduction

#CameraServer Plugin For Cordova

Supported platform:

  • iOS
  • Android

Provides Live Camera images over HTTP (over Wifi or locally to a Cordova Application):

Why over HTTP ?

  • A known memory leak problem occurs when retrieving data/result in Cordova (see CameraPlus)
  • It's faster and purely in native code so it was suitable for our application Netcam Studio Smart Camera

#How to use CameraServer?

Add the plugin to your cordova project:

cordova plugin add https://github.com/Moonware/cordova-cameraserver   

Removing the plugin to your cordova project:

cordova plugin rm cordova-plugin-cameraserver      

Dependency

Since Cordova 4.0, it may be required to install the cordova-plugin-whitelist to allow calls to 127.0.0.1 and localhost

Without this step, your application may not be allowed to pull and display images from the camera server plugin.

Please follow installation and setup instructions here: cordova-plugin-whitelist

#Javascript APIs

startServer( options, success_callback, error_callback );

stopServer( success_callback, error_callback );

getURL( success_callback, error_callback );

getLocalPath( success_callback, error_callback );

getNumRequests( success_callback, error_callback );

startCamera( success_callback, error_callback );

stopCamera( success_callback, error_callback );

/* Just for testing, do not use this since it leaks */
getJpegImage( success_callback, error_callback );

#Quick Start

Start the Web Server

cordova.plugins.CameraServer.startServer({
    'www_root' : '/',
    'port' : 8080,
    'localhost_only' : false,
    'json_info': []
}, function( url ){
    // if server is up, it will return the url of http://<server ip>:port/
    // the ip is the active network connection
    // if no wifi or no cell, "127.0.0.1" will be returned.
    console.log('CameraServer Started @ ' + url); 
}, function( error ){
    console.log('CameraServer Start failed: ' + error);
});

Start the Camera Capture (will act on demand when a HTTP request arrives)

cordova.plugins.CameraServer.startCamera(function(){
      console.log('Capture Started');
  },function( error ){
      console.log('CameraServer StartCapture failed: ' + error);
  });

Downloading a Live Image in Javascript (AngluarJS / Ionic)

var localImg = 'http://localhost:8080/live.jpg';

$http.get(localImg).
    success(function(data, status, headers, config) {
        console.log("Image Downloaded");
    }).
    error(function(data, status, headers, config) {
        console.log("Image Download failed");
    });

Displaying a Live Image in a Cordova App is as simple as:

<img src='http://localhost:8080/live.jpg'>

#Usage in applications

This plugin was developped for the needs of Netcam Studio Smart Camera:

Netcam Studio Smart Camera iOS

Netcam Studio Smart Camera Android

#Credits

This Cordova plugin is based on CorHttpd, thanks to the authors:

Which is itself based on:

  • NanoHTTPD, written in java, for java / android, by psh.
  • CocoaHTTPServer, written in Obj-C, for iOS / Mac OS X, by robbiehanson.

You can use this plugin for FREE.

Feel free to fork, improve and send pull request.

We will of course appreciate if you share any improvement or addition made to the plugin.

cordova-cameraserver's People

Contributors

tarun1793 avatar w3t avatar

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.