ReFlex Logo
ReFlex (Title)
Documentation
Navigation

ReFlex.Library

Core Library for Development of applications for Elastic Displays. Created in context of research project ZELASTO (EFRE-project no. 100376687) in cooperation with HTW Dresden.

Table of contents

  1. Project setup
  2. Project Structure
  3. Sensor Modules
  4. Specific components
  5. Code Examples
  6. Configurable Clients (TCP/WebSockets)

Project setup

Frameworks

IDEs

nuget Packages

general

Library Version Description
Prism.Core 8.1.97 Dedpendency Injection / Commanding / Event Aggregation utilities
Newtonsoft.Json 13.0.3 JSON-Serializer
NLog 5.1.3 Universal logging framework for .NET
SixLabors.ImageSharp 2.1.3 platform-independent graphics library
MathNet.Filtering 0.7.0 filter algorithms
MathNet.Numerics 5.0.0 matrix operations

Connectivity

Library Version Description
websocketsharp.core 1.0.0 .net standard library for using web sockets
CoreOSC 1.0.0 .net Core library for OSC messages (TUIO)
Grpc.AspNetCore 2.52.0 ASP.NET plugin for gRPC Calls
WatsonTcp 5.0.11 Library for Tcp communication

Development

Library Version Description
BenchmarkDotNet 0.13.5 performance analysis used for emulator and point cloud
Moq 4.18.4 .NET mocking library
NUnit 3.13.3 .NET Testing framework
coverlet.collector 6.0.0 necessary for generating test reports (platform independent)
Microsoft.CodeCoverage 17.8.0 Code coverage

Project Structure

Group Project Description
Core   Contains base functionality of DepthSensing Framework. Platform-independent .NET libraries
  ReFlex.Core.Calibration Implementation of semi-automatic mapping algorithm. Based on three linear-independent reference points the associated points in the depth image have to be specified. From this relative transformation a linear transformation in XY-Plane (Translate, scale, rotate, shear) is computed and stored as sparse 4x4 matrix.
  ReFlex.Core.Common Definitions of base data types used in the framework
  ReFlex.Core.Events Generic events used in the framework
  ReFlex.Core.Filtering Depth Image filter implementations. Filters can be applied in any order.
  ReFlex.Core.Graphics Definitions of base data types used in the framework
  ReFlex.Core.Implementation Manager classes for the relevant Processing stages (Calibration, Tracking, Filtering, InteractionProcessing, Networking)
  ReFlex.Core.Interactivity Defines Base Type for Interaction. Implementations for Single- and Multi-Touch Detection
  ReFlex.Core.Networking common interfaces for client / server for network broadcasting and receiving Interactions, Reference implementations for Tcp client/server, Websocket communication
  ReFlex.Core.Tracking common interface (IDepthCamera) for different Camera Types (description, current state, initialization, query configurations, start/stop streaming, events for frame updates)
  ReFlex.Core.Tuio Implementation of TUIO Protocol
  ReFlex.Core.Util .NET specific utility functions (Logging/Threading)
Sensor   IDepthCamera implementations for specific Depth sensors
  ReFlex.Sensor.TrackingImplementation projects for specific sensors (see Sensor Modules)
Legacy Apps   legacy applications for development (deprecated)
  ReFlex.Utilities.ConsoleClientDemo Tutorial console app for showcasing network communication.
  ReFlex.Utilities.ConsoleServerDemo Tutorial console app simulating a TCP-Server Instance sending Interactions for showcasing network communication
  ReFlex.Utilities.MouseInputConverter Converts interactions to mouse events for controlling normal apps/controls with DepthTouch (Windows only)
  ReFlex.Frontend.ServerWPF Server app for controlling sensor properties, calibration, filtering and broadcasting Interactions. (WPF, Windows only).

Sensor Modules

implemented Sensor-Hardware

Software-Emulator:

Specific components

Filter

Algorithms to process raw depth image for smoothing and mapping.

BoxFilter

Smoothing depth image based on Box-Filter algorithm.
Parameters:

CalibrationFilter

Map depth coordinates (x,y) to screen coordinates based on given calibration matrix. (simnplke transfomation: scale + translate)
Parameters:

GaussianFilter

Separated two pass (X, then Y) smoothing algorithm based on gaussian blur.
Parameters:

LimitationFilter

removes tracking values outside of desirted viewing frame (e.g. interactive surface)
Parameters:

ThresholdFilter

Filters values which inner z-values are greater than a specified threshold. (== Limitation Filter in z-direction)
Parameters:

ValueFilter

removes depth values with specific value from depth image (e.g. remove all zeros) Parameters:

Code Examples

TCP-Client

Basic code example to create a tcp-based client and listen to events from server (cf. ReFlex.Utilities.ConsoleClientDemo/Client.cs)


public class Client
{ 
    // create new TCP-Client
    private readonly IClient _client = new TcpClient();

    public Client()
    {
        // attach to DataReceivedEvent and start listening to address 
        _client.NewDataReceived += HandleDataReceived;
        Run("localhost", 8080);
    }

    // handle events and parse messages from tracking server
    private void HandleDataReceived(object sender, Message message)
    {
        if (message?.MessageString == null)
            return;

        // retrieve list of interactions
        var interactions = SerializationUtils.DeserializeFromJson<List<Interaction>>(message.MessageString);
        
        // iterate over interactions
        interactions.ForEach(interaction =>
        {
            // get time of interaction
            var timeString = DateTime.FromFileTimeUtc(interaction.Time).ToShortTimeString();

            // ... do something        
        });
    }

    public void Run(string address, int port)
    {
        // connect if client is properly initialized
        _client?.Connect(address, port);  
    }

    public void Stop()
    {
        _client?.Disconnect();
    }
}

Configurable Clients (TCP/WebSockets)

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <appSettings>
    <add key="NetworkInterface" value="Http"/>
    <add key="Address" value="127.0.0.1"/>
    <add key="Port" value="40000"/>
    <add key="Endpoint" value="/ReFlex"/>

    <!-- values for TCP -->
    <!--<add key="NetworkInterface" value="tcp"/>
    <add key="Address" value="127.0.0.1"/>
    <add key="Port" value="8080"/>
    <add key="Endpoint" value=""/>-->
  </appSettings>
</configuration>