elsampsa / valkka-core

Valkka - Create video surveillance, management and analysis programs with PyQt
GNU Lesser General Public License v3.0
181 stars 35 forks source link

Valkka - OpenSource Video Surveillance and Management for Linux

For the VERY impatient

Looking for an OpenSource video surveillance program with object detection? Just go here.

Main Page

LibValkka main page and documentation is in here. Please start from there.

Synopsis

The goal of this project is to provide a library for creating open source video surveillance, management and analysis systems (VMAs) in Linux environment. The idea is create VMA systems with graphical user interfaces (GUIs) using the combination of python3 and Qt (i.e. PyQt).

For the impatient

For a demo program that uses libValkka, see Valkka Live.

Installation instructions, demo programs and API tutorial are available here (you should read that first)

If you just want to use the API, no need to go further.

If you are interested in compiling Valkka yourself or even help us with the core development, keep on reading.

Why this library?

Most of the people nowadays have a concentration span of milliseconds (because of mobile devices). Thank you for keep on reading! :)

Lets take a look at a typical video management system architecture problem. This goes for desktop / Qt-based programs and for web-based apps as well:

You might try to tackle this with some available stock media player libraries, but I'll promise, you wont get far.

Consider further that in a typical VMA system you may have up to 60+ ip cameras plugged into the same server. Servers should also work as a proxies, re-streaming the ip cameras to other servers.

Using Valkka, you can instantiate threads, and define how media streams are branched and pipelined between those threads. The underlying threads and mutex-protected queues are hidden from the developer that controls everything using a python3 API. The process topology of the example case would look like this:

[LiveThread]->|                        +-----> [AnalyzerProcess]
              |                        | (branch 1)
              +--> [DecoderThread] --->| 
              |                        | (branch 2)  
              +--> Filesystem          +------> [OpenGLThread] -- > X window system

Some key features of the Valkka library are:

Versions and Features

Newest version is 1.6.1

Older versions

1.5.4

1.5.3

1.5.2

1.5.1

1.5.0

1.4.0

1.3.6

1.3.5

1.3.4

1.3.3

1.3.1

1.3.0

1.2.2

1.2.1

1.2.0

1.0.3

1.0.2

1.0.1

1.0.0

For more, see CHANGELOG

Long term goals

Very long term goals

Installing

Binary packages and their Python3 bindings are provided for latest Ubuntu distributions. Subscribe to our repository with:

sudo apt-add-repository ppa:sampsa-riikonen/valkka

and then do:

sudo apt-get update
sudo apt-get install valkka

For more detailed instructions, please visit here

Compile yourself

Dependencies

You need (at least):

sudo apt-get install python3 mesa-utils glew-utils python3-numpy v4l-utils python3-pip openssl build-essential yasm cmake pkg-config swig libglew-dev mesa-common-dev python3-dev python3-numpy libasound2-dev libssl-dev coreutils freeglut3-dev i965-va-driver libva-dev intel-gpu-tools

If you are in an architecture (arm) that doesn't support VAAPI, do not include the vaapi dependencies (i965-va-driver libva-dev intel-gpu-tools) in the above command

If you have upgraded your python interpreter, you might need to define the version, say python3.7-dev

Compile

The same CMake file is used to compile the library, generate python wrappings and to compile the wrappings (no more python setup scripts)

Valkka uses numerical python (numpy) C API and needs the numpy C headers at the build process. Be aware of the numpy version and header files being used in your setup. You can check this with:

./pythoncheck.bash

We recommend that you use a "globally" installed numpy (from the debian python3-numpy package) instead of a "locally" installed one (installed with pip3 install). When using your compiled Valkka distribution, the numpy version you're loading at runtime must match the version that was used at the build time.

First, download ffmpeg source code:

cd ext
./download_ffmpeg.bash
cd ..

Then, just

./easy_build.bash

Finally, create a debian package with

make -f debian/rules package

You can install the package to your system with

cd build_dir
dpkg -i Valkka-*.deb
sudo apt-get -fy install

Development environment

If you need more fine-grained control over the build process, create a separate build directory and copy the contents of the directory tools/build there. Read and edit run_cmake.bash and README_BUILD. Now you can toggle various debug/verbosity switches, define custom location for live555 and ffmpeg, etc. After creating the custom build, you should run

source test_env.bash

in your custom build directory. You still need to inform the python interpreter about the location of the bindings. In the main valkka directory, do:

cd python
source test_env.bash

And you're all set. Now you have a terminal that finds both libValkka and the python3 bindings

Semi-automated testing

After having set up your development environment, made changes to the code and succesfully built Valkka, you should run the testsuite. Valkka is tested by a series of small executables that are using the library, running under valgrind. For some of the tests, valgrind can't be used, due to the GPU direct memory access. For these tests, you should (i) run them without valgrind and see if you get video on-screen or (ii) compile valkka with the VALGRIND_DEBUG switch enabled and only after that, run them with valgrind.

In your build directory, refer to the bash script run_tests.bash. Its self-explanatory.

Before running run_tests.bash" you should edit and run the set_test_streams.bash* that sets up your test cameras.

Resources

  1. Discussion threads:

  2. Doxygen generated documentation

  3. The examples repository

Authors

Sampsa Riikonen (core programming, opengl shader programming, python programming)

Petri Eranko (financing, testing)

Marco Eranko (testing)

Markus Kaukonen (opengl shader programming, testing)

Acknowledgements

Ross Finlayson

Dark Photon

GClements

XactAI for sponsorship

Copyright

Copyright (c) 2017-2022 Valkka Security Ltd. and Sampsa Riikonen Copyright (c) 2023 Sampsa Riikonen

Open Source Licenses

License

GNU Lesser General Public License v3 or later.

(if you need something else, please contact us)