OpenCV and Universal Windows Platform UWP

To get OpenCV running on Windows 10 via an UWP project you have to do the following steps:

  • Download and install
    latest Microsoft Visual Studio 2015 Community (or an earlier version, must support UWP)
    latest OpenCV (this tutorial with 3.4.1)
    latest CMake (this tutorial with 3.1)
  • Open CMake
    CMakeGUI OpenCV
    Press configure and select Visual Studio 2015 x64. After that generate the project by pressing ‘Generate’. (If you plan to compile the ARM Version, only static libraries can be build, simply uncheck BUILD_SHARED_LIBS).
  • Open the user defined CMake project folder and open the created project solution (*.sln) file. Build both – the debug and the release version. This should work without and problems. After I built OpenCV I copied the debug and release dlls in a separate bin folder and the libs also in a separate libs folder. Because of the OpenCV separation with the suffix d for debug both (debug and release) can exist in one directory.
  • Create a new Visual Studio 2015 Project and select ‘Blank App (Universal Windows)’Visual Studio 2015 OpenCV Project
  • Download and modify the paths inside the file with your favorite text editor: Visual Studio User Defined Properties. This separate properties file can be modified very easily and can be shared with other projects too.
  • Add the properties file to your current Visual Studio 2015 project.
    Visual Studio 2015 Property Window
    Visual Studio 2015 Properties
    You can do this again for the Debug | x64 too. Simply right click on the build type and select ‘Add Existing Property Sheet’. Choose the opencv_x64.probs file again. A macro inside the file will switch between debug and release configuration automatically.
  • Here is the content of my MainPage.cpp
    // MainPage.xaml.cpp
    // Implementation of the MainPage class.
    #include “pch.h”
    #include “MainPage.xaml.h”
    #include <opencv2\core.hpp>
    #include <opencv2\imgcodecs.hpp>
    #include <opencv2\imgproc.hpp>
    #include <robuffer.h>
    using namespace CVProj;
    using namespace Platform;
    using namespace Windows::Foundation;
    using namespace Windows::Foundation::Collections;
    using namespace Windows::UI::Xaml;
    using namespace Windows::UI::Xaml::Controls;
    using namespace Windows::UI::Xaml::Controls::Primitives;
    using namespace Windows::UI::Xaml::Data;
    using namespace Windows::UI::Xaml::Input;
    using namespace Windows::UI::Xaml::Media;
    using namespace Windows::UI::Xaml::Navigation;
    using namespace Windows::UI::Xaml::Media::Imaging;
    using namespace Windows::Storage::Streams;
    using namespace Microsoft::WRL;
     cv::Mat input;
    input = cv::imread(“Image file from the ‘Assets’ folder of your project.“);
     cv::Mat img = cv::Mat(input.rows, input.cols, CV_8UC4);
    cv::cvtColor(input, img, CV_BGR2BGRA);
     cv::resize(img, img, cv::Size(640, 480));
     BitmapImage ^bitImg = ref new BitmapImage();
    WriteableBitmap^ wbmp = ref new WriteableBitmap(img.cols, img.rows);
    IBuffer^ buffer = wbmp->PixelBuffer;
    unsigned char* dstPixels;
    ComPtr<IBufferByteAccess> pBufferByteAccess;
    ComPtr<IInspectable> pBuffer((IInspectable*)buffer);
    memcpy(dstPixels,, img.step.buf[1] * img.cols * img.rows);
    cvImg->Source = wbmp;
  • Add this entry to your MainPage.xaml file
    <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
        <Image Name="cvImg"></Image>
  • Now it should compile without any problems otherwise you do have to check your properties file.
  • You successfully created a Universal Windows Application with OpenCV support!


I added a new menu entry: University. There you can perhaps find some useful helpers and information for your studies.

Gitlab and Apache

Using Gitlab with Apache server isn’t quite difficult to manage but it costs me some time to find the right resources and hints. To avoid this search again, here are some useful steps to get it work.

First of all this is my configuration:


  • Download the following configuration files from the Gitlab Apache Server Configuration Files site:gitlab-omnibus-ssl-apache24.conf
    gitlab-omnibus-apache24.confCopy them to /etc/apache2/sites-available and create a system link to /etc/apache2/sites-enabled

    >> ln -s /etc/apache2/sites-available/gitlab-omnibus-ssl-apache24.conf /etc/apache2/sites-enabled/gitlab-omnibus-ssl-apache24.conf
    >> ln -s /etc/apache2/sites-available/gitlab-omnibus-apache24.conf /etc/apache2/sites-enabled/gitlab-omnibus-apache24.conf
  • Install missing mod and enable dependencies for Apache (listed in the *.conf files)
    >> apt-get install libapache2-mod-proxy-html
    >> a2enmod rewrite
    >> a2enmod ssl
    >> a2enmod proxy
    >> a2enmod proxy_http
    >> a2enmod headers


  • Add new domain to your /etc/hosts configuration
  • If you do have a static IP, configure your DNS on your domain hoster website for correct redirection
  • Change in the configuration files (*.conf) the YOUR_SERVER_FQDN entries to your domain name, e.g.
  • For the Gitlab configuration follow these steps:
    gitlab_workhorse['listen_network'] = "tcp"
    gitlab_workhorse['listen_addr'] = ""
    nginx['enable'] = false
    web_server['external_users'] = ['www-data']
    >> gitlab-ctl reconfigure
  • Restart Apache server
    >> service apache2 restart | systemctl status apache2.service


If you are using Letsencrypt for SSL then change the following lines in the gitlab-omnibus-ssl-apache24.conf file

SSLEngine on
#strong encryption ciphers only
#see ciphers(1)
#SSLProtocol all -SSLv2
#SSLHonorCipherOrder on
#Header add Strict-Transport-Security: "max-age=15768000;includeSubdomains"
#SSLCompression Off
SSLCertificateFile /etc/letsencrypt/live/
SSLCertificateKeyFile /etc/letsencrypt/live/
Include /etc/letsencrypt/options-ssl-apache.conf
#SSLCACertificateFile /etc/httpd/ssl.crt/your-ca.crt

Free HTTPS Certificate from Let’s Encrypt

If you want to secure the connection of your server with a valid and free certificate – that also modern browser will recognise – you should go to this website and follow the instructions there. Currently big companies like Akamai, Cisco, Mozilla and Facebook are supporting Let’s Encrypt so I guess there is no argument not encrypting the communication to your server. Additional this tool configures your existing Apache server so that your HTTPS connection is set up in less than 5 minutes.

Here is the link:

After that you can test your website on security issues:

Hint: non www to www
Now if you have a certificate for your and you want to redirect to you have to add the following commands to your default-ssl.conf located in /etc/apache2/sites-available directory:

<VirtualHost *:443>
RewriteEngine on
#RewriteCond %{HTTP_HOST} !^localservername -->used for local access
RewriteCond %{HTTP_HOST} !^www\. -->check if www is missing
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}$1 [R=301,L] -->add www.

Your default.conf located in /etc/apache2/sites-available should be modified as shown below:

<VirtualHost *:80>
	# redirect all http queries to https
	Redirect permanent / 
<VirtualHost *:80>
  RewriteEngine On
  RewriteCond %{SERVER_PORT} ^80$
  RewriteRule .* https://%{SERVER_NAME}%{REQUEST_URI} [R=301,L]

Raspbian Upgrade Wheezy to Jessie

I upgraded my current version of Raspbian Wheezy to Raspbian Jessie. If you want to upgrade your Raspberry Pi too than follow these steps:

deb jessie main contrib non-free rpi

After that upgrade and restart your device:

>> apt-get update && sudo apt-get dist-upgrade
>> reboot

C++11 Hints

Life long learning is it called, isn’t it? So I decided to improve and extend my knowlegde by reading some extra material concerning this topic. Below you will find a link to the main developer of C++ – Bjarne Stroustrup. He has some interesting literature references and shares some of his ebooks on his webpage: