OpenCV 3.4.1 via TinkerBoard

# Install TinkerBoard 
## TinkerOS-Debian (20170417)

- https://www.asus.com/jp/Single-Board-Computer/Tinker-Board/
- https://www.asus.com/Single-Board-Computer/Tinker-Board/

## apt librarie update

```$ sudo apt update -y &&& sudo apt upgrade -y ```

# Download OpenCV Library

- https://opencv.org/releases.html
- https://github.com/opencv/opencv/archive/3.4.1.zip

```$ wget https://github.com/opencv/opencv/archive/3.4.1.zip ```

# Setup cmake utility

```$ sudo apt install cmake```

# unzip opencv

```$ mkdir work && cd work && unzip ../3.4.1.zip "

# Make Makefile using cmake

`$ cd opencv-3.4.1 
$ mkdir build
$ cd build
$ cmake ..`

OpenCV is enable .
'
--   OpenCL:                        YES (no extra features)
--     Include path:                /home/linaro/work/opencv-3.4.1/3rdparty/include/opencl/1.2
--     Link libraries:              Dynamic load
'

# Make and Install

``` $ make -j 8 
  $ sudo make install```

# Enjoy !!

OpenCV 3.4.1 supports on-disk OpenCL kernel binary cache. 
OpenCL supports on-memory OpenCL kernel binary cache(maybe...)

```
inaro@linaro-alip:~/opencvtest$ rm ~/.cache/opencv/3.4.1/opencl_cache/ARM--Mali-T760--1_2/imgproc--cvtcolor_f166e5b037afb65e97f88ff96d02894c.bin
linaro@linaro-alip:~/opencvtest$ ./a.out
[ INFO:0] Initialize OpenCL runtime...
[ INFO:0] Successfully initialized OpenCL cache directory: /home/linaro/.cache/opencv/3.4.1/opencl_cache/
[ INFO:0] Preparing OpenCL cache configuration for context: ARM--Mali-T760--1_2
GPU 304891 micro sec
GPU 329 micro sec
GPU 259 micro sec
GPU 254 micro sec
GPU 249 micro sec
GPU 281 micro sec
GPU 249 micro sec
GPU 260 micro sec
GPU 252 micro sec
GPU 253 micro sec
CPU 3362 micro sec
CPU 3125 micro sec
CPU 2741 micro sec
CPU 2731 micro sec
CPU 2720 micro sec
CPU 2808 micro sec
CPU 2732 micro sec
CPU 2716 micro sec
CPU 2822 micro sec
CPU 2714 micro sec
linaro@linaro-alip:~/opencvtest$ ./a.out
[ INFO:0] Initialize OpenCL runtime...
[ INFO:0] Successfully initialized OpenCL cache directory: /home/linaro/.cache/opencv/3.4.1/opencl_cache/
[ INFO:0] Preparing OpenCL cache configuration for context: ARM--Mali-T760--1_2
GPU 147193 micro sec
GPU 309 micro sec
GPU 249 micro sec
GPU 244 micro sec
GPU 238 micro sec
GPU 270 micro sec
GPU 242 micro sec
GPU 254 micro sec
GPU 244 micro sec
GPU 249 micro sec
CPU 3318 micro sec
CPU 2806 micro sec
CPU 2721 micro sec
CPU 2842 micro sec
CPU 2787 micro sec
CPU 2798 micro sec
CPU 2713 micro sec
CPU 2721 micro sec
CPU 2781 micro sec
CPU 2720 micro sec
linaro@linaro-alip:~/opencvtest$
```

```
#include <iostream>

#include <opencv2/opencv.hpp>
#include <opencv2/core/ocl.hpp>

int trial(int nCount, int bUseOpenCL)
{
        cv::Mat  srcMat = cv::imread("lena.jpg");
        cv::UMat srcUMat;
        cv::UMat dstUMat;
        cv::Mat  dstMat;
        cv::TickMeter meter;
        int *meterList = new int[nCount];

        srcMat.copyTo(srcUMat);

        cv::ocl::setUseOpenCL(bUseOpenCL);

        for ( int i = 0 ; i < nCount ; i ++ ) {
                meter.start();
                cv::cvtColor(srcUMat, dstUMat, cv::COLOR_BGR2HSV);
                meter.stop();
                meterList[i] = meter.getTimeMicro();
                meter.reset();
        }

        for ( int i = 0 ; i < nCount ; i ++ ) {
                std::cout << (bUseOpenCL?"GPU ":"CPU ")
                        << meterList[i] << " micro sec" << std::endl;
        }
        delete meterList;
}

int main()
{
        trial(10, true );
        trial(10, false);
        return 0;
}
```