# Performance Optimization of Object Tracking Algorithms in OpenCV on GPUs
## 5 Evaluation
### Discussion  
Our schemes improved the performance of the object tracking algorithms through the following methods. First, hardware utilization and algorithm performance were improved through the remapping of variables to another hardware resource. Next, the algorithm's performance was improved by configuring the global work size based on the number of work-items available in the hardware. Finally, the algorithm's performance was improved  
\begin{table}
\begin{tabular}{l c c c c} \hline \hline  & \multicolumn{2}{c}{**\# of Calls**} & \multicolumn{2}{c}{**Execution Time (ms)**} \\
**Kernel Name** & **Baseline** & **Merge** & **Baseline** & **Merge** \\ \hline boxFilter5 & 1092 & 1092 & 1515.54 & 1504.72 \\ gaussianBlur & 728 & 728 & 1022.40 & 1020.15 \\ polynomialExpansion & 728 & 728 & 253.71 & 252.71 \\ split & 90 & 90 & 49.77 & 49.86 \\ merge & 91 & 91 & 46.99 & 47.27 \\ convertTo & 182 & 182 & 31.49 & 31.50 \\ RGB2 Gray & 92 & 92 & 16.28 & 16.23 \\ set & 182 & 182 & 1.06 & 1.06 \\ updateFlow & 1092 & 364 & 352.79 & 120.08 \\ updateMatrices & 1092 & 364 & 1023.37 & 340.51 \\ updateFM & 0 & 728 & 0.00 & 800.23 \\ resizeLN & 1274 & 1274 & 154.98 & 154.72 \\ KF & 546 & 0 & 59.25 & 0.00 \\
**Total** & 7189 & 5915 & 4527.61 & 4339.03 \\ \hline \hline \end{tabular}
\end{table}
Table 10: The number of calls and execution time of the kernels of Farneback optical flow.  
Figure 12: The throughput of the optical flow algorithm, values normalized to the baseline.  
\begin{table}
\begin{tabular}{l c c} \hline \hline
**API Name** & **Baseline (ms)** & **Merge (ms)** \\ \hline clEnqueueMapBuffer & 2234.95 & 2116.45 \\ clEnqueueWriteBuffer & 1907.73 & 1827.59 \\ clReleaseMemObject & 699.57 & 719.62 \\ clEnqueueNDRangeKernel & 254.17 & 237.53 \\ clEnqueueReadBuffer & 128.10 & 125.74 \\ clFinish & 27.02 & 14.94 \\ clSetEventCallback & 13.33 & 11.21 \\ clSetKernelArg & 12.65 & 12.76 \\ clCreateKernel & 11.14 & 10.73 \\ clEnqueueUmapMemObject & 6.69 & 6.48 \\ clCreateBuffer & 5.58 & 5.71 \\ clReleaseEvent & 1.89 & 1.80 \\ clReleaseKernel & 1.78 & 1.69 \\ clGetDeviceInfo & 1.75 & 2.17 \\
**Total** & 5306.34 & 5094.41 \\ \hline \hline \end{tabular}
\end{table}
Table 9: The execution time of OpenCL APIs with Farneback optical flow.  
by eliminating preprocessing in the host program, which is redundant for GPU kernel launch.  
Those results can provide insights to the computer vision community as follows. First, the algorithm's performance can be improved without optimizing the algorithm's flow or supplying hardware resources. For this, we propose three schemes: distribution of hardware usage by remapping variables, maximizing computing resource utilization by increasing global work size, and reducing the host's computing time by kernel merging for minimizing the parallel computing device's idle time. Next, all of the above schemes can be automated. For example, variable remapping is already a common technique in the compiler community [42; 43], and kernel merging can be performed through work size detection at the compiler level. Furthermore, fixing the global work size is possible through the information of parallel computing devices. Optimizing object tracking algorithms automatically through device and kernel profiling is our future work.