IEEE Robotics & Automation Magazine - June 2020 - 155

An example of the benchmarking code for measuring the
execution time is as follows:
1
2
3
4
5
6
7

double ticks = (double)cv::getTickCount();
if (use_gpu) {
gpu_processing(frame, dst);
} else {
cpu_processing(frame, dst);
}
ticks = ((double)cv::getTickCount() - ticks)/cv::getTick
Frequency()*1000;

The OpenCV functions cv::getTickCount() and
cv::getTickFrequency are used to obtain the number
of ticks before and after the processing work, translated into
seconds. A boolean variable indicates whether to use the CPU
or GPU; the value of this variable can be toggled through a
keyboard click.
In a second example, ORB features are detected and
extracted from the image. Such features are very important in
robotics applications, such as, for visual SLAM [9]. The
source code for the CPU version is as follows:
1 cv::Mat src, dst;
2 cv::Mat src_gray, descriptors;
3 std::vector keypoints;
4
5
6
7
8

cv::Ptr detector = cv::ORB::create();
cv::cvtColor( src, src_gray, cv::COLOR_BGR2GRAY );
detector->detect( src_gray, keypoints );
detector->compute( src_gray, keypoints, descriptors ) ;
cv::drawKeypoints( src, keypoints, dst,
cv::Scalar::all(-1), cv::DrawMatchesFlags::DEFAULT );

First, we define the necessary variables for storing the
original and final images, the intermediate gray image, and
the structures for storing the keypoints and descriptors of the
ORB features (lines 1-4). Second, the feature detector is initialized with default parameters in line 4. Finally, the processing steps are performed in lines 5-7; the original color image
is converted into a gray image, the keypoints are detected,
and their descriptors are computed. In line 8, the keypoints
are drawn into the destination image for visualization.
The CUDA version of this example is straightforward:
1
2
3
4

cv::Mat src, dst;
cv::cuda::GpuMat gpu_src, gpu_dst;
cv::cuda::GpuMat src_gray, descriptors;
std::vector keypoints;

5 gpu_src.upload(src);
6 cv::Ptr detector = cv::cuda::ORB::create();
7 cv::cuda::cvtColor( gpu_src, src_gray, cv::COLOR_BGR2GRAY );
8 detector->detect( src_gray, keypoints ) ;
9 detector->compute( src_gray, keypoints, descriptors );
10 cv::drawKeypoints( src, keypoints, dst,
cv::Scalar::all(-1), cv::DrawMatchesFlags::DEFAULT );

As in the previous example, we need to define two GpuMat
variables for the original and destination images (line 2). The
intermediate image is also stored in GPU memory, along with
the descriptors (line 3), but the keypoints are stored in CPU
memory (line 4). After uploading the image in line 5, the feature detector is created, and the processing steps are executed.
One should note that the processing code is basically similar to the previous version; lines 4-7 of the CPU code and
lines 6-9 of the GPU code differ only in the use of the
namespace cv::cuda instead of cv for the class ORB
(line 4/6) and the functions ORB::create
and cvtColor (lines
The usefulness of CUDA in
4/6 and 5/7).
Finally, drawing the
robotics and vision has been
keypoints is done in exactly the same way (line
successfully demonstrated
10 of the GPU code is the
same as line 8 of the CPU
with significant speedups in
code). The output of the
ORB detector is shown
many applications.
in Figure 5.
For debugging purposes, the code examples include visualization, and the corresponding function
calls have been included in the benchmarking. Since the
visualization process uses the same function call in both the
CPU and GPU versions, it should not affect the difference
between them in terms of performance.
The results are shown in Table 3. In this case, the GPUs are
faster than the CPUs due to the increased computational
workload demanded by the ORB algorithm. For simplicity,
this example has not computed the matching of ORB

Figure 5. The output image of the ORB feature detector.

Table 3. The computation times (in milliseconds)
for the ORB feature extraction algorithm (lower,
in bold, is better).
Desktop PC

Laptop PC

Embedded PC

CPU 15.323 ± 0.788 19.281 ± 0.883 101.586 ± 4.112
GPU 10.777 ± 1.246 11.588 ± 0.397 66.697 ± 2.936

JUNE 2020

*

IEEE ROBOTICS & AUTOMATION MAGAZINE

*

155



IEEE Robotics & Automation Magazine - June 2020

Table of Contents for the Digital Edition of IEEE Robotics & Automation Magazine - June 2020

Contents
IEEE Robotics & Automation Magazine - June 2020 - Cover1
IEEE Robotics & Automation Magazine - June 2020 - Cover2
IEEE Robotics & Automation Magazine - June 2020 - Contents
IEEE Robotics & Automation Magazine - June 2020 - 2
IEEE Robotics & Automation Magazine - June 2020 - 3
IEEE Robotics & Automation Magazine - June 2020 - 4
IEEE Robotics & Automation Magazine - June 2020 - 5
IEEE Robotics & Automation Magazine - June 2020 - 6
IEEE Robotics & Automation Magazine - June 2020 - 7
IEEE Robotics & Automation Magazine - June 2020 - 8
IEEE Robotics & Automation Magazine - June 2020 - 9
IEEE Robotics & Automation Magazine - June 2020 - 10
IEEE Robotics & Automation Magazine - June 2020 - 11
IEEE Robotics & Automation Magazine - June 2020 - 12
IEEE Robotics & Automation Magazine - June 2020 - 13
IEEE Robotics & Automation Magazine - June 2020 - 14
IEEE Robotics & Automation Magazine - June 2020 - 15
IEEE Robotics & Automation Magazine - June 2020 - 16
IEEE Robotics & Automation Magazine - June 2020 - 17
IEEE Robotics & Automation Magazine - June 2020 - 18
IEEE Robotics & Automation Magazine - June 2020 - 19
IEEE Robotics & Automation Magazine - June 2020 - 20
IEEE Robotics & Automation Magazine - June 2020 - 21
IEEE Robotics & Automation Magazine - June 2020 - 22
IEEE Robotics & Automation Magazine - June 2020 - 23
IEEE Robotics & Automation Magazine - June 2020 - 24
IEEE Robotics & Automation Magazine - June 2020 - 25
IEEE Robotics & Automation Magazine - June 2020 - 26
IEEE Robotics & Automation Magazine - June 2020 - 27
IEEE Robotics & Automation Magazine - June 2020 - 28
IEEE Robotics & Automation Magazine - June 2020 - 29
IEEE Robotics & Automation Magazine - June 2020 - 30
IEEE Robotics & Automation Magazine - June 2020 - 31
IEEE Robotics & Automation Magazine - June 2020 - 32
IEEE Robotics & Automation Magazine - June 2020 - 33
IEEE Robotics & Automation Magazine - June 2020 - 34
IEEE Robotics & Automation Magazine - June 2020 - 35
IEEE Robotics & Automation Magazine - June 2020 - 36
IEEE Robotics & Automation Magazine - June 2020 - 37
IEEE Robotics & Automation Magazine - June 2020 - 38
IEEE Robotics & Automation Magazine - June 2020 - 39
IEEE Robotics & Automation Magazine - June 2020 - 40
IEEE Robotics & Automation Magazine - June 2020 - 41
IEEE Robotics & Automation Magazine - June 2020 - 42
IEEE Robotics & Automation Magazine - June 2020 - 43
IEEE Robotics & Automation Magazine - June 2020 - 44
IEEE Robotics & Automation Magazine - June 2020 - 45
IEEE Robotics & Automation Magazine - June 2020 - 46
IEEE Robotics & Automation Magazine - June 2020 - 47
IEEE Robotics & Automation Magazine - June 2020 - 48
IEEE Robotics & Automation Magazine - June 2020 - 49
IEEE Robotics & Automation Magazine - June 2020 - 50
IEEE Robotics & Automation Magazine - June 2020 - 51
IEEE Robotics & Automation Magazine - June 2020 - 52
IEEE Robotics & Automation Magazine - June 2020 - 53
IEEE Robotics & Automation Magazine - June 2020 - 54
IEEE Robotics & Automation Magazine - June 2020 - 55
IEEE Robotics & Automation Magazine - June 2020 - 56
IEEE Robotics & Automation Magazine - June 2020 - 57
IEEE Robotics & Automation Magazine - June 2020 - 58
IEEE Robotics & Automation Magazine - June 2020 - 59
IEEE Robotics & Automation Magazine - June 2020 - 60
IEEE Robotics & Automation Magazine - June 2020 - 61
IEEE Robotics & Automation Magazine - June 2020 - 62
IEEE Robotics & Automation Magazine - June 2020 - 63
IEEE Robotics & Automation Magazine - June 2020 - 64
IEEE Robotics & Automation Magazine - June 2020 - 65
IEEE Robotics & Automation Magazine - June 2020 - 66
IEEE Robotics & Automation Magazine - June 2020 - 67
IEEE Robotics & Automation Magazine - June 2020 - 68
IEEE Robotics & Automation Magazine - June 2020 - 69
IEEE Robotics & Automation Magazine - June 2020 - 70
IEEE Robotics & Automation Magazine - June 2020 - 71
IEEE Robotics & Automation Magazine - June 2020 - 72
IEEE Robotics & Automation Magazine - June 2020 - 73
IEEE Robotics & Automation Magazine - June 2020 - 74
IEEE Robotics & Automation Magazine - June 2020 - 75
IEEE Robotics & Automation Magazine - June 2020 - 76
IEEE Robotics & Automation Magazine - June 2020 - 77
IEEE Robotics & Automation Magazine - June 2020 - 78
IEEE Robotics & Automation Magazine - June 2020 - 79
IEEE Robotics & Automation Magazine - June 2020 - 80
IEEE Robotics & Automation Magazine - June 2020 - 81
IEEE Robotics & Automation Magazine - June 2020 - 82
IEEE Robotics & Automation Magazine - June 2020 - 83
IEEE Robotics & Automation Magazine - June 2020 - 84
IEEE Robotics & Automation Magazine - June 2020 - 85
IEEE Robotics & Automation Magazine - June 2020 - 86
IEEE Robotics & Automation Magazine - June 2020 - 87
IEEE Robotics & Automation Magazine - June 2020 - 88
IEEE Robotics & Automation Magazine - June 2020 - 89
IEEE Robotics & Automation Magazine - June 2020 - 90
IEEE Robotics & Automation Magazine - June 2020 - 91
IEEE Robotics & Automation Magazine - June 2020 - 92
IEEE Robotics & Automation Magazine - June 2020 - 93
IEEE Robotics & Automation Magazine - June 2020 - 94
IEEE Robotics & Automation Magazine - June 2020 - 95
IEEE Robotics & Automation Magazine - June 2020 - 96
IEEE Robotics & Automation Magazine - June 2020 - 97
IEEE Robotics & Automation Magazine - June 2020 - 98
IEEE Robotics & Automation Magazine - June 2020 - 99
IEEE Robotics & Automation Magazine - June 2020 - 100
IEEE Robotics & Automation Magazine - June 2020 - 101
IEEE Robotics & Automation Magazine - June 2020 - 102
IEEE Robotics & Automation Magazine - June 2020 - 103
IEEE Robotics & Automation Magazine - June 2020 - 104
IEEE Robotics & Automation Magazine - June 2020 - 105
IEEE Robotics & Automation Magazine - June 2020 - 106
IEEE Robotics & Automation Magazine - June 2020 - 107
IEEE Robotics & Automation Magazine - June 2020 - 108
IEEE Robotics & Automation Magazine - June 2020 - 109
IEEE Robotics & Automation Magazine - June 2020 - 110
IEEE Robotics & Automation Magazine - June 2020 - 111
IEEE Robotics & Automation Magazine - June 2020 - 112
IEEE Robotics & Automation Magazine - June 2020 - 113
IEEE Robotics & Automation Magazine - June 2020 - 114
IEEE Robotics & Automation Magazine - June 2020 - 115
IEEE Robotics & Automation Magazine - June 2020 - 116
IEEE Robotics & Automation Magazine - June 2020 - 117
IEEE Robotics & Automation Magazine - June 2020 - 118
IEEE Robotics & Automation Magazine - June 2020 - 119
IEEE Robotics & Automation Magazine - June 2020 - 120
IEEE Robotics & Automation Magazine - June 2020 - 121
IEEE Robotics & Automation Magazine - June 2020 - 122
IEEE Robotics & Automation Magazine - June 2020 - 123
IEEE Robotics & Automation Magazine - June 2020 - 124
IEEE Robotics & Automation Magazine - June 2020 - 125
IEEE Robotics & Automation Magazine - June 2020 - 126
IEEE Robotics & Automation Magazine - June 2020 - 127
IEEE Robotics & Automation Magazine - June 2020 - 128
IEEE Robotics & Automation Magazine - June 2020 - 129
IEEE Robotics & Automation Magazine - June 2020 - 130
IEEE Robotics & Automation Magazine - June 2020 - 131
IEEE Robotics & Automation Magazine - June 2020 - 132
IEEE Robotics & Automation Magazine - June 2020 - 133
IEEE Robotics & Automation Magazine - June 2020 - 134
IEEE Robotics & Automation Magazine - June 2020 - 135
IEEE Robotics & Automation Magazine - June 2020 - 136
IEEE Robotics & Automation Magazine - June 2020 - 137
IEEE Robotics & Automation Magazine - June 2020 - 138
IEEE Robotics & Automation Magazine - June 2020 - 139
IEEE Robotics & Automation Magazine - June 2020 - 140
IEEE Robotics & Automation Magazine - June 2020 - 141
IEEE Robotics & Automation Magazine - June 2020 - 142
IEEE Robotics & Automation Magazine - June 2020 - 143
IEEE Robotics & Automation Magazine - June 2020 - 144
IEEE Robotics & Automation Magazine - June 2020 - 145
IEEE Robotics & Automation Magazine - June 2020 - 146
IEEE Robotics & Automation Magazine - June 2020 - 147
IEEE Robotics & Automation Magazine - June 2020 - 148
IEEE Robotics & Automation Magazine - June 2020 - 149
IEEE Robotics & Automation Magazine - June 2020 - 150
IEEE Robotics & Automation Magazine - June 2020 - 151
IEEE Robotics & Automation Magazine - June 2020 - 152
IEEE Robotics & Automation Magazine - June 2020 - 153
IEEE Robotics & Automation Magazine - June 2020 - 154
IEEE Robotics & Automation Magazine - June 2020 - 155
IEEE Robotics & Automation Magazine - June 2020 - 156
IEEE Robotics & Automation Magazine - June 2020 - 157
IEEE Robotics & Automation Magazine - June 2020 - 158
IEEE Robotics & Automation Magazine - June 2020 - 159
IEEE Robotics & Automation Magazine - June 2020 - 160
IEEE Robotics & Automation Magazine - June 2020 - 161
IEEE Robotics & Automation Magazine - June 2020 - 162
IEEE Robotics & Automation Magazine - June 2020 - 163
IEEE Robotics & Automation Magazine - June 2020 - 164
IEEE Robotics & Automation Magazine - June 2020 - 165
IEEE Robotics & Automation Magazine - June 2020 - 166
IEEE Robotics & Automation Magazine - June 2020 - 167
IEEE Robotics & Automation Magazine - June 2020 - 168
IEEE Robotics & Automation Magazine - June 2020 - 169
IEEE Robotics & Automation Magazine - June 2020 - 170
IEEE Robotics & Automation Magazine - June 2020 - 171
IEEE Robotics & Automation Magazine - June 2020 - 172
IEEE Robotics & Automation Magazine - June 2020 - 173
IEEE Robotics & Automation Magazine - June 2020 - 174
IEEE Robotics & Automation Magazine - June 2020 - 175
IEEE Robotics & Automation Magazine - June 2020 - 176
IEEE Robotics & Automation Magazine - June 2020 - 177
IEEE Robotics & Automation Magazine - June 2020 - 178
IEEE Robotics & Automation Magazine - June 2020 - 179
IEEE Robotics & Automation Magazine - June 2020 - 180
IEEE Robotics & Automation Magazine - June 2020 - 181
IEEE Robotics & Automation Magazine - June 2020 - 182
IEEE Robotics & Automation Magazine - June 2020 - 183
IEEE Robotics & Automation Magazine - June 2020 - 184
IEEE Robotics & Automation Magazine - June 2020 - Cover3
IEEE Robotics & Automation Magazine - June 2020 - Cover4
https://www.nxtbook.com/nxtbooks/ieee/roboticsautomation_december2023
https://www.nxtbook.com/nxtbooks/ieee/roboticsautomation_september2023
https://www.nxtbook.com/nxtbooks/ieee/roboticsautomation_june2023
https://www.nxtbook.com/nxtbooks/ieee/roboticsautomation_march2023
https://www.nxtbook.com/nxtbooks/ieee/roboticsautomation_december2022
https://www.nxtbook.com/nxtbooks/ieee/roboticsautomation_september2022
https://www.nxtbook.com/nxtbooks/ieee/roboticsautomation_june2022
https://www.nxtbook.com/nxtbooks/ieee/roboticsautomation_march2022
https://www.nxtbook.com/nxtbooks/ieee/roboticsautomation_december2021
https://www.nxtbook.com/nxtbooks/ieee/roboticsautomation_september2021
https://www.nxtbook.com/nxtbooks/ieee/roboticsautomation_june2021
https://www.nxtbook.com/nxtbooks/ieee/roboticsautomation_march2021
https://www.nxtbook.com/nxtbooks/ieee/roboticsautomation_december2020
https://www.nxtbook.com/nxtbooks/ieee/roboticsautomation_september2020
https://www.nxtbook.com/nxtbooks/ieee/roboticsautomation_june2020
https://www.nxtbook.com/nxtbooks/ieee/roboticsautomation_march2020
https://www.nxtbook.com/nxtbooks/ieee/roboticsautomation_december2019
https://www.nxtbook.com/nxtbooks/ieee/roboticsautomation_september2019
https://www.nxtbook.com/nxtbooks/ieee/roboticsautomation_june2019
https://www.nxtbook.com/nxtbooks/ieee/roboticsautomation_march2019
https://www.nxtbook.com/nxtbooks/ieee/roboticsautomation_december2018
https://www.nxtbook.com/nxtbooks/ieee/roboticsautomation_september2018
https://www.nxtbook.com/nxtbooks/ieee/roboticsautomation_june2018
https://www.nxtbook.com/nxtbooks/ieee/roboticsautomation_march2018
https://www.nxtbook.com/nxtbooks/ieee/roboticsautomation_december2017
https://www.nxtbook.com/nxtbooks/ieee/roboticsautomation_september2017
https://www.nxtbook.com/nxtbooks/ieee/roboticsautomation_june2017
https://www.nxtbook.com/nxtbooks/ieee/roboticsautomation_march2017
https://www.nxtbook.com/nxtbooks/ieee/roboticsautomation_december2016
https://www.nxtbook.com/nxtbooks/ieee/roboticsautomation_september2016
https://www.nxtbook.com/nxtbooks/ieee/roboticsautomation_june2016
https://www.nxtbook.com/nxtbooks/ieee/roboticsautomation_march2016
https://www.nxtbook.com/nxtbooks/ieee/roboticsautomation_december2015
https://www.nxtbook.com/nxtbooks/ieee/roboticsautomation_september2015
https://www.nxtbook.com/nxtbooks/ieee/roboticsautomation_june2015
https://www.nxtbook.com/nxtbooks/ieee/roboticsautomation_march2015
https://www.nxtbook.com/nxtbooks/ieee/roboticsautomation_december2014
https://www.nxtbook.com/nxtbooks/ieee/roboticsautomation_september2014
https://www.nxtbook.com/nxtbooks/ieee/roboticsautomation_june2014
https://www.nxtbook.com/nxtbooks/ieee/roboticsautomation_march2014
https://www.nxtbook.com/nxtbooks/ieee/roboticsautomation_december2013
https://www.nxtbook.com/nxtbooks/ieee/roboticsautomation_september2013
https://www.nxtbook.com/nxtbooks/ieee/roboticsautomation_june2013
https://www.nxtbook.com/nxtbooks/ieee/roboticsautomation_march2013
https://www.nxtbook.com/nxtbooks/ieee/roboticsautomation_december2012
https://www.nxtbook.com/nxtbooks/ieee/roboticsautomation_september2012
https://www.nxtbook.com/nxtbooks/ieee/roboticsautomation_june2012
https://www.nxtbook.com/nxtbooks/ieee/roboticsautomation_march2012
https://www.nxtbook.com/nxtbooks/ieee/roboticsautomation_december2011
https://www.nxtbook.com/nxtbooks/ieee/roboticsautomation_september2011
https://www.nxtbook.com/nxtbooks/ieee/roboticsautomation_june2011
https://www.nxtbook.com/nxtbooks/ieee/roboticsautomation_march2011
https://www.nxtbook.com/nxtbooks/ieee/roboticsautomation_december2010
https://www.nxtbook.com/nxtbooks/ieee/roboticsautomation_september2010
https://www.nxtbookmedia.com