Algorithmenentwicklung mit MATLAB für 2D und 3D ...€¦ · Inhalte Kurze Vorstellung - Austrian...

21
Csaba Beleznai Senior Scientist Video- and Safety Technology Safety & Security Department AIT Austrian Institute of Technology GmbH Vienna, Austria Algorithmenentwicklung mit MATLAB für 2D und 3D Bildanalyse-Systeme Csaba Beleznai Michael Rauter, Christian Zinner, Andreas Zweng, Andreas Zoufal, Julia Simon, Daniel Steininger, Markus Hofstätter und Andreas Kriechbaum Co-Autoren: Research pages: http://ivs.ait.ac.at

Transcript of Algorithmenentwicklung mit MATLAB für 2D und 3D ...€¦ · Inhalte Kurze Vorstellung - Austrian...

Page 1: Algorithmenentwicklung mit MATLAB für 2D und 3D ...€¦ · Inhalte Kurze Vorstellung - Austrian Institute of Technology Motivation - Entwicklung komplexer HW/SW Systeme Konzepte

Csaba Beleznai Senior Scientist Video- and Safety Technology Safety & Security Department AIT Austrian Institute of Technology GmbH Vienna, Austria

Algorithmenentwicklung mit MATLAB für 2D und 3D Bildanalyse-Systeme

Csaba Beleznai Michael Rauter, Christian Zinner, Andreas Zweng, Andreas Zoufal, Julia Simon, Daniel Steininger, Markus Hofstätter und Andreas Kriechbaum

Co-Autoren:

Research pages: http://ivs.ait.ac.at

Page 2: Algorithmenentwicklung mit MATLAB für 2D und 3D ...€¦ · Inhalte Kurze Vorstellung - Austrian Institute of Technology Motivation - Entwicklung komplexer HW/SW Systeme Konzepte

Inhalte Kurze Vorstellung - Austrian Institute of Technology

Motivation - Entwicklung komplexer HW/SW Systeme

Konzepte - Zusammenspiel von Matlab und C/C++ Matlab C++ und C++ Matlab

Anwendungsfall: Personenflusserfassung mittels Bildanalyse

Zusammenfassung

2D

Verfolgung mittels Optischem Fluss

3D

Warteschlangenanalyse (Länge, Wartezeit)

Page 3: Algorithmenentwicklung mit MATLAB für 2D und 3D ...€¦ · Inhalte Kurze Vorstellung - Austrian Institute of Technology Motivation - Entwicklung komplexer HW/SW Systeme Konzepte

IDEE

branch & bound research methodology

PRODUKT ANWENDUNG

RESEARCH DEVELOPMENT

Alg. A

Alg. B

Alg. C

MATLAB C++

Motivation

Einleitung

Herausforderungen im Entwicklungsprozess: Komplexität Bildanalyse-Systeme Nichtlinearer Ablauf der Suche nach einer Lösung

Page 4: Algorithmenentwicklung mit MATLAB für 2D und 3D ...€¦ · Inhalte Kurze Vorstellung - Austrian Institute of Technology Motivation - Entwicklung komplexer HW/SW Systeme Konzepte

4

CPU GPU Embedded

Standard Methoden

Fortgeschrittene Methoden

Products

Innovations

Moving Objects

Advanced Background Model

Person Detection

Person Detection and Tracking

Automatic Calibration

3D Optical Flow

Soft Biometrics

Unser Entwicklungskonzept

Blob based processing

Einleitung

MATLAB C++

Page 5: Algorithmenentwicklung mit MATLAB für 2D und 3D ...€¦ · Inhalte Kurze Vorstellung - Austrian Institute of Technology Motivation - Entwicklung komplexer HW/SW Systeme Konzepte

5

Unser Entwicklungskonzept

MATLAB C/C++

Methode, Prototyp

Produkt

MATLAB: Breites Spektrum von algorithmischen Bibliotheken, Für Bildanalyse sehr gut geeignet, Visualisierung, Debugging, Kurze Entwicklungszeiten Methode, Prototyp, Demonstrator

C/C++ Echtzeitfähigkeit

Portierung

mex

shared library

rechenintensive Methoden

Verifikation

Matlab engine

Datengenerator

Zusammenspiel von Matlab und C/C++

Page 6: Algorithmenentwicklung mit MATLAB für 2D und 3D ...€¦ · Inhalte Kurze Vorstellung - Austrian Institute of Technology Motivation - Entwicklung komplexer HW/SW Systeme Konzepte

Beschleunigtes Prototyping / Verifikation

MATLAB C/C++

algorithmische Kette

berechnungsintensiver Algorithmus oder Algorithmusteil

1. C/C++ Umsetzung beschleunigen und rückführen über ein mex-Interface

2. Portierung von Matlab-Algorithmus unter Zuhilfenahme eines mex-Interfaces zur Verifikation der Implementierungen

Zusammenspiel von Matlab und C/C++

Page 7: Algorithmenentwicklung mit MATLAB für 2D und 3D ...€¦ · Inhalte Kurze Vorstellung - Austrian Institute of Technology Motivation - Entwicklung komplexer HW/SW Systeme Konzepte

Schnelle Integration neuer Algorithmen (1)

algorithmische Kette

neue algorithmische Methode

Zusammenspiel von Matlab und C/C++

MATLAB C/C++

Matlab Engine

Page 8: Algorithmenentwicklung mit MATLAB für 2D und 3D ...€¦ · Inhalte Kurze Vorstellung - Austrian Institute of Technology Motivation - Entwicklung komplexer HW/SW Systeme Konzepte

Schnelle Integration neuer Algorithmen (2)

algorithmische Kette

Eine oder mehrere neue algorithmische Methoden

Zusammenspiel von Matlab und C/C++

MATLAB C/C++

Matlab Compiler

Methoden als shared lib

Page 9: Algorithmenentwicklung mit MATLAB für 2D und 3D ...€¦ · Inhalte Kurze Vorstellung - Austrian Institute of Technology Motivation - Entwicklung komplexer HW/SW Systeme Konzepte

Matlab Engine als Unterstützung für C/C++ Debugging

algorithmische Kette

komplexe Variablen

Zusammenspiel von Matlab und C/C++

MATLAB C/C++

Matlab Engine Abfrage / Visualisierung von

Variablen

Interaktive Matlab Session

Page 10: Algorithmenentwicklung mit MATLAB für 2D und 3D ...€¦ · Inhalte Kurze Vorstellung - Austrian Institute of Technology Motivation - Entwicklung komplexer HW/SW Systeme Konzepte

Bildanalyse im Bereich der digitalen Videoüberwachung

Algorithmen:

Typisches Überwachungsszenario: Wer Personen, Fahrzeuge, Objekte, … Wo befinden sie sich? Welche Aktivität? Wann passiert es?

Objektdetektion und Klassifikation

Zählen, Dichte, Overcrowding Abgestellte Objekte Eindringlinge

Verfolgung

Vereinzelte Objekte Flußanalyse

Erkennung von Aktivitäten

Nahbereich (Artikulation) Entfernung (Bewegungspfad)

Was ist Bildanalyse in unserem Kontext?

Page 11: Algorithmenentwicklung mit MATLAB für 2D und 3D ...€¦ · Inhalte Kurze Vorstellung - Austrian Institute of Technology Motivation - Entwicklung komplexer HW/SW Systeme Konzepte

Matlab C++: Matlab-Engine

Zusammenspiel von Matlab und C/C++

MATLAB arbeitet im Hintergrund als eine mächtige und programmierbare mathematische Algorithmenbibliothek

Beispiel für eine Berechnung:

Bildausschnitt +

Parameter Signatur (z.B. Histogramm) Eingabe: Ausgabe:

function [DescrTempl] = ComputeDescr(iminTempl, Params)

MATLAB Funktion

#include "engine.h" // including the Matlab engine Engine *ep; // instancing the Matlab engine //======== 1. Initializing the Matlab engine ============================== if (!(ep = engOpen("\0"))) return STATUS_MATLAB_INIT_ERROR; // otherwise return error code engPutVariable(ep, "Params", mxParams); // Place variable Params into the MATLAB workspace engPutVariable(ep, "iminTempl", mxImT); // Inserting image data into Matlab // Evaluating the expression in Matlab engEvalString(ep, "DescrTempl = ComputeDescr(iminTempl, Params);"); // Deallocating Matlab-specific C-variables mxDestroyArray(mxParams); mxParams = NULL; mxDestroyArray(mxImT); mxImT = NULL; // closing the Matlab engine engClose(ep);

Offizielles Beispiel: engdemo.c

Page 12: Algorithmenentwicklung mit MATLAB für 2D und 3D ...€¦ · Inhalte Kurze Vorstellung - Austrian Institute of Technology Motivation - Entwicklung komplexer HW/SW Systeme Konzepte

Matlab C++: shared library Zusammenspiel von Matlab und C/C++

Shared Library: Funktionssammlung die in einer C/C++ Anwendung während der Laufzeit dynamisch geladen wird.

MATLAB code MATLAB compiler shared library mcc -W lib:matchlib -T link:lib ComputeDescr.m

Compiler Aufruf:

#include "matchlib.h" // Compiled interface of Matlab code //============= 1. MCR and library initialization functions ======== if( !mclInitializeApplication(NULL, 0) ) { fprintf(stderr, "Could not initialize the application.\n"); exit(1); } if (!matchlibInitialize()) { fprintf(stderr, "Could not initialize the library.\n"); exit(1); } // compiled function call mlfComputeDescr(1, &mxDescrT, mxImT, mxParams);// first argument is the number of outputs matchlibTerminate(); // library termination mclTerminateApplication(); // application-level resource termination

Page 13: Algorithmenentwicklung mit MATLAB für 2D und 3D ...€¦ · Inhalte Kurze Vorstellung - Austrian Institute of Technology Motivation - Entwicklung komplexer HW/SW Systeme Konzepte

Personenflussanalyse in 2D

Public dataset: Grand Central Station, NYC: 720x480 pixels, Rechengeschwindigkeit 35 fps (C++)

Anwendungsfall

Page 14: Algorithmenentwicklung mit MATLAB für 2D und 3D ...€¦ · Inhalte Kurze Vorstellung - Austrian Institute of Technology Motivation - Entwicklung komplexer HW/SW Systeme Konzepte

Warteschlangenanalyse: Schätzung der Länge und Wartezeit

Was ist die Wartezeit bei einer Warteschlange?

Checkpoint

Wartezeit

Benötigte Zeit für die hinterste Person von A nach B zu gelangen.

Beispiel: Automatische Erfassung von Wartezeiten (App) Kundenzufriedenheit Warum ist diese Problemstellung relevant?

Beispiel: Infrastrukturbetreiber load balancing

A B

Anwendungsfall

Stereokamera

Page 15: Algorithmenentwicklung mit MATLAB für 2D und 3D ...€¦ · Inhalte Kurze Vorstellung - Austrian Institute of Technology Motivation - Entwicklung komplexer HW/SW Systeme Konzepte

15

Analyse von Warteschlangen (Länge, Dynamik)

Anwendungsfall

Rechengeschwindigkeit: 6 fps inkl. Stereo-Tiefenberechnung (C++)

Geradlinig

Page 16: Algorithmenentwicklung mit MATLAB für 2D und 3D ...€¦ · Inhalte Kurze Vorstellung - Austrian Institute of Technology Motivation - Entwicklung komplexer HW/SW Systeme Konzepte

16

Analyse von Warteschlangen (Länge, Dynamik)

Anwendungsfall

Rechengeschwindigkeit: 6 fps inkl. Stereo-Tiefenberechnung (C++)

Gebogen

Page 17: Algorithmenentwicklung mit MATLAB für 2D und 3D ...€¦ · Inhalte Kurze Vorstellung - Austrian Institute of Technology Motivation - Entwicklung komplexer HW/SW Systeme Konzepte

Visuelle Analyse von Warteschlangen Herausforderndes Problem

Wartezeit =

Form

Kein vordefinierbarer Verlauf (Situationsabhängig und zeitlich variabel)

Bewegung keine reine Translation

Propagierendes Stop-and-Go Verhalten Entfernung (Kopplung mit Bewegungspfad)

Länge Geschwindigkeit

1. Wie verläuft die Warteschlange?

2. Wie groß ist die Fortschrittsgeschwindigkeit?

Anwendungsfall: Warteschlangenanalyse

DEFINITION: Zielorientierte Bewegung von Personen mit räumlicher und zeitlicher Kohärenz

Page 18: Algorithmenentwicklung mit MATLAB für 2D und 3D ...€¦ · Inhalte Kurze Vorstellung - Austrian Institute of Technology Motivation - Entwicklung komplexer HW/SW Systeme Konzepte

18

MATLAB Simulationstool Daten mit großer Variabilität Einige Konfigurationen:

Zwei Simulationsbeispiele in Matlab:

Anwendungsfall: Warteschlangenanalyse

Page 19: Algorithmenentwicklung mit MATLAB für 2D und 3D ...€¦ · Inhalte Kurze Vorstellung - Austrian Institute of Technology Motivation - Entwicklung komplexer HW/SW Systeme Konzepte

Geschätzte Warteschlangenkonfiguration (top-view) Detektionsergebnisse

Adaptive Schätzung der räumlichen Konfiguration

Linke Bildhälfte ist aus datenschutzrechtlichen Gründen ausgeblendet

Anwendungsfall: Warteschlangenanalyse

Page 20: Algorithmenentwicklung mit MATLAB für 2D und 3D ...€¦ · Inhalte Kurze Vorstellung - Austrian Institute of Technology Motivation - Entwicklung komplexer HW/SW Systeme Konzepte

20

Zusammenfassung

MATLAB unterstützt die Entwicklung komplexer Algorithmik

Entwicklung von Algorithmen gleicher Komplexität sind in C/C++ mit hohem Aufwand verbunden

Ein technisches Problem hat oft mehrere Lösungswege: Schnelle Erprobung mehrerer Alternativen durch Integration in eine

bestehende Algorithmenkette.

Unerwähnte nützliche Aspekte

Befehl pcode – Schutz eigener Matlabskripten Versionsverwaltung (Git, SVN) – 2014b User Interfaces mit Tab-Panels – 2014b MatlabCentral und FileExchange

MATLAB C++

Page 21: Algorithmenentwicklung mit MATLAB für 2D und 3D ...€¦ · Inhalte Kurze Vorstellung - Austrian Institute of Technology Motivation - Entwicklung komplexer HW/SW Systeme Konzepte

Vielen Dank!

CSABA BELEZNAI Senior Scientist Digital Safety & Security Department Video- and Security Technology AIT Austrian Institute of Technology GmbH Donau-City-Straße 1 | 1220 Vienna | Austria T +43(0) 664 825 1257 | F +43(0) 50550-4170 [email protected] | http://www.ait.ac.at

http://www.d-sens.eu/

Research pages: http://ivs.ait.ac.at