anchor.diff:  
   Doing this in MATLAB unfortunately requires some workarounds due to the language's single threaded nature, i.e., background threads need to run in another language. Out of the box there are two supported interfaces: https://www.mathworks.com/help/matlab/matlab_external/introducing-mex-files.html[MEX] for calling C/C++ code, and the https://www.mathworks.com/help/matlab/matlab_external/product-overview.html[Java Interface] for calling Java code.
   
  -While both interfaces have strengths and weaknesses, either one can be used for solving practically any use case. Since this project had to work on all major operating systens, we chose to use the Java interface for its built-in cross-platform support and simplified deployment. The diagram below shows an overview of the resulting system.
  -
  -////
  -Since our projects almost always have to work on all major platforms, we tend to favor the Java interface for its simplified deployment and  built-in cross-platform support. However, one of the weaknesses is that the overhead of calling Java methods from MATLAB is higher than the overhead of calling MEX functions. This difference is usually negligible, but it unfortunately becomes noticeable when translating large amounts of data such as high resolution images. 
  -
  -
  -although the internal performance differences between Java and C++ rarely matter, the overhead of calling Java methods from MATLAB is higher than the overhead of calling MEX functions. This difference is usually negligible, but it unfortunately becomes noticeable when translating large amounts of data such as high resolution images.
  -////
  +While both interfaces have strengths and weaknesses, practically all use cases can be solved using either one. For this project we chose to use the Java interface because it needed to support all major operating systems, and Java greatly simplifies cross-platform support as well as the deployment of binaries. The diagram below shows an overview of the resulting system.
   
   [.text-center]
   .System overview for a stereo vision setup
  
positive.code: 
  The Java interface automatically converts between Java and MATLAB types by following a set of link:https://www.mathworks.com/help/matlab/matlab_external/handling-data-returned-from-java-methods.html[rules]. This makes it much simpler to develop for than the MEX interface, but it does cause additional overhead when calling Java functions. Most of the time this overhead is negligible. However, for certain types of data, such as large and multi-dimensional matrices, the default rules are very inefficient and can become prohibitively expensive. For example, a `1080x1920x3` MATLAB image matrix gets translated to a `byte[1080][1920][3]` Java array, which means that every single pixel in the image gets stored as a separate array.
  
  As an additional complication, Java images use a different memory layout than MATLAB image matrices. While Java stores pixels in row-major order, MATLAB stores them transposed and in column-major order. For example, if the pixels for a Java image would be laid out as `[RGB][RGB][RGB]...`, the same image would be laid out as `[RRR...][GGG...][BBB...]` in MATLAB.  (`R`, `G`, `B` correspond to red, green, and blue values for one pixel)
  
  In order to process images at a frame rate of 30 fps in real-time, the total time budget of the main MATLAB thread is 33ms per cycle. Thus, the aquisition overhead imposed on the main thread needs to be sufficiently low, i.e., a low number of milliseconds, to leave enough time for the actual processing.
  
  
  ////
  * Acquiring video on a background thread
  * Transferring data across the language barrier
  * Converting to a MATLAB readable format
  * Using the image in MATLAB
  
  Getting images in has to happen within max a few ms, otherwise it's impossible to do any actual work on the images. Since decoding can take an entire thread by itself, background threading is required. However, there is too much data to transfer through the standard language barriers.
  ////
  
  == Data Translation
  
  
negative.code: 
  *4. MATLAB Layout as 1D Pixel Array*
  
  The fourth approach also copies a single pixel array, but this time the pixels are already stored in the MATLAB convention.
  
  [source,matlab]
  ----
  