SPBench Applications
====================

.. _applications:

.. contents:: Table of Contents

The current applications set of SPBench comprises four real-world applications: Ferret (from PARSEC), Lane Detection, Person Recognition, and Bzip2.
These applications have been studied and used as benchmarks by many works in the literature. 
This way, we reimplemented them to fit the SPBench API. 
Our plan is to include more stream processing applications in the near future.

Ferret (PARSEC)
---------------

Ferret is a `PARSEC <https://parsec.cs.princeton.edu/>`_ application intended for a content similarity search in data such as video, audio, and images. 
In PARSEC the parallelism is implemented with POSIX Threads using a six-stage Pipeline. 
The first and last ones are source and sink. 
The second stage performs the segmentation, a process that organizes the regions of each image into sets. 
The third stage extracts 14 features from the segmented regions of each image. 
The fourth stage (vectorization) applies an indexing method, which selects possible similar images. 
The fifth stage performs a refined search of the images selected in the fourth stage, ranking the most similar images.

.. figure:: img/ferret_graph.png
   :align: center
   :width: 780
   :alt: Ferret Pipeline Graph

   Ferret Pipeline Graph

.. figure:: img/ferret_workflow.png
   :align: center
   :width: 780
   :alt: Ferret workflow
   
   Ferret illustration

--------------

Lane Detection
--------------

Lane Detection is the task of detecting lanes of a road from a camera device. 
It can be used to keep autonomous cars on track to avoid collisions, for instance. 
This application captures each frame of a input video file and applies three computer vision algorithms. 
It can be divided into a nine-stage Pipeline, as shown in Figure 3.c. 
Through these stages, the detected lanes are marked with straight lines in a new frame. 
This new frame with the marked lanes is then overlaid on the original, and the resulting frame is written to the output file. 
More details about this application can be found in `this link <https://dx.doi.org/10.3233/978-1-61499-843-3-698>`_.

.. figure:: img/lane_example.png
   :align: center
   :width: 480
   :alt: Lane Detection illustration
   
   Lane Detection illustration

.. figure:: img/lane_graph.png
   :align: center
   :width: 740
   :alt: Lane Detection Pipeline Graph

   Lane Detection Pipeline Graph

.. figure:: img/lane_workflow.png
   :align: center
   :width: 780
   :alt: Lane Detection workflow

   Lane Detection workflow

--------------

Person Recognition
------------------

Person Recognition (or Face Recognizer) tries to match human faces from a video frame against a database of faces. 
It could be used to recognize faces in a crowd and compare against a police database to identify wanted criminals, for instance. 
For each video frame it applies a detection algorithm to detect all the faces in it. 
Then, it uses a set of face images and compares each of the detected faces in the frame with the faces on that set. 
The recognized faces are marked with a circle, and then the frames are written to the output file. 
Therefore, this application can be divided into a four-stage Pipeline. 
More details about this application can be found in `this link <https://dx.doi.org/10.3233/978-1-61499-843-3-698>`_.

.. figure:: img/person_example.png
   :align: center
   :width: 480
   :alt: Person Recognition illustration
   
   Person Recognition illustration

.. figure:: img/person_graph.png
   :align: center
   :width: 420
   :alt: Person Recognition Pipeline Graph

   Person Recognition Pipeline Graph

.. figure:: img/face_workflow.png
   :align: center
   :width: 780
   :alt: Person Recognition workflow

   Person Recognition workflow

--------------

Bzip2
-----

`Bzip2 <http://www.bzip.org/>`_ is a free and open-source data compression application. 
It compresses data more effectively than the older LZW (.Z) and Deflate (.zip and .gz) algorithms, but it is considerably slower than them. 
Therefore, parallel implementations that increase compression speed are useful. 
This application can be divided into a three-stage Pipeline (source, compress/decompress, sink) and has two operation modes: compress and decompress.

.. figure:: img/bzip2_graph.png
   :align: center
   :width: 420
   :alt: Bzip2 Pipeline Graph

   Bzip2 Pipeline Graph

.. rst-class:: clear-both
   
