Giter VIP home page Giter VIP logo

appbase-cctv's Introduction

appbase-cctv

A CCTV system for the IoT backed on Appbase.

Dependencies

This is the list of libraries required by appbase-cctv, plus the install command for Debian (jessie, derivatives may also apply).

  • libcurl: apt-get install libcurl[3|4]-[gnutls|openssl|...]-dev
  • json-c: apt-get install libjson-c-dev
  • modpbase64: apt-get install libmodpbase64-dev
  • jpeg: apt-get install libjpeg-dev
  • yajl: apt-get install libyajl-dev
  • SDL2_image: apt-get install libsdl2-image-dev
  • pthread: already included in libc

Usage

Compile

You need CMake, version 3.0 at least. On Debian jessie, you would just do:

apt-get install cmake

Make sure you have all the dependencies listed above installed. You should have the development version, as pointed out. Then, it is advisable to run CMake in a separate folder to avoid polluting the source tree with CMake's stuff.

mkdir build && cd build
cmake -G "Unix Makefiles" ..

Verify that a Makefile has been created, and then just run:

make

It should create two executables, namely appbase-cctv-client and appbase-cctv-daemon, and a shared library, libappbase-common.so. This library exports common functions used by both executables.

Run

So the architecture is fairly simple. There are two pieces, a daemon and a client. Choosing appropriate names was tricky, since the daemon is also a client, strictly speaking. The daemon takes pictures from the camera in raw YUYV (also known as YUY2) format, converts them to JPEG if requested, and uploads them to Appbase. The client constantly streams them down and displays them. For this whole system to run, you should have a valid Appbase account beforehand, and have created an application.

You would first run the client:

Usage: ./appbase-cctv-client [OPTIONS] <app name> <username> <password>
Options:
    -d    Display debug messages
    -j    Decode images from JPEG

It takes as arguments, your Appbase application name, username and password. So if your app is "myapp", your username is "foo", and your password is "bar", you would run:

./appbase-cctv-client -j myapp foo bar

You should see a window appearing. As you could see, -j says the images were converted to JPEG and thus have to be decoded. This is kind of mandatory, since in my tests, raw images were >100 KB in size, and were rejected by Appbase backend. JPEG conversion greatly reduces them in size.

Now you would run the daemon in a new console, which takes similar arguments. App name, username and password should be the same.

Usage: ./appbase-cctv-daemon [OPTIONS] <app name> <username> <password>
Options:
    -w secs        Sleep this amount of seconds between shots
    -d             Display debug messages
    -s             Take one single shot and exit
    -j             Convert frames to JPEG
    -S             Stream as fast as possible

Thus:

./appbase-cctv-daemon -jw2 myapp foo bar

And you should see the client's window update every 2 seconds.

Acknowledgements

The author would like to acknowledge the following projects were of great significance during the development of appbase-cctv, and proudly points the reader to them were they interested in learning more about the mechanisms leveraged by the project:

  • uvccapture, for providing a valuable reference on how to interface with UVC cameras via ioctls on Linux.
  • UVC wiki on Ubuntu, for providing documentation about UVC in the first place.
  • LinuxTV. The project that officially develops and maintains the UVC drivers in the kernel (and many more cool stuff ;D).
  • Appbase and its developer program, for letting me hack this out (and for the stipend too ;D).

appbase-cctv's People

Contributors

juaristi avatar

Watchers

 avatar  avatar

Forkers

athiwatp

appbase-cctv's Issues

An expected identifier error while building on an OS X environment

When make'ing on OS X 10.10.5, 64-bit machine, I see the following error messages (2 errors, 3 warnings). The errors seems related to the use of macro and bools.

Scanning dependencies of target appbase-common
[  8%] Building C object CMakeFiles/appbase-common.dir/appbase.c.o
In file included from /Users/siddharthlatest/dev/github/appbase-cctv/appbase.c:13:
/Users/siddharthlatest/dev/github/appbase-cctv/main.h:22:2: error: expected identifier
        false = 0,
        ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/7.0.2/include/stdbool.h:33:15: note: 
      expanded from macro 'false'
#define false 0
              ^
In file included from /Users/siddharthlatest/dev/github/appbase-cctv/appbase.c:13:
/Users/siddharthlatest/dev/github/appbase-cctv/main.h:23:2: error: expected identifier
        true = 1
        ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/7.0.2/include/stdbool.h:32:14: note: 
      expanded from macro 'true'
#define true 1
             ^
/Users/siddharthlatest/dev/github/appbase-cctv/appbase.c:181:4: warning: implicit declaration of function 'free' is invalid in C99
      [-Wimplicit-function-declaration]
                        free(ab->url);
                        ^
/Users/siddharthlatest/dev/github/appbase-cctv/appbase.c:231:47: warning: comparison of constant 1 with expression of type 'Bool'
      is always false [-Wtautological-constant-out-of-range-compare]
        if (ab && ab->curl && (enable == 0 || enable == 1))
                                              ~~~~~~ ^  ~
/Users/siddharthlatest/dev/github/appbase-cctv/appbase.c:237:47: warning: comparison of constant 1 with expression of type 'Bool'
      is always false [-Wtautological-constant-out-of-range-compare]
        if (ab && ab->curl && (enable == 0 || enable == 1)) {
                                              ~~~~~~ ^  ~
3 warnings and 2 errors generated.
make[2]: *** [CMakeFiles/appbase-common.dir/appbase.c.o] Error 1
make[1]: *** [CMakeFiles/appbase-common.dir/all] Error 2
make: *** [all] Error 2

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.