ed
test
test_mask.cpp
Go to the documentation of this file.
1
#include <
ed/mask.h
>
2
3
#include <
profiling/Timer.h
>
4
5
int
main
()
6
{
7
cv::Mat
rgb_image
(480, 640, CV_8UC3, cv::Scalar(1, 0, 255));
8
9
ed::ImageMask
m(
rgb_image
.cols,
rgb_image
.rows);
10
11
for
(
int
y = 0; y < 480; ++y)
12
{
13
for
(
int
x = 0; x < 640; ++x)
14
{
15
m.
addPoint
(x, y);
16
}
17
}
18
19
// cv::Point2i p_min, p_max;
20
// m.boundingRect(p_min, p_max);
21
// std::cout << p_min << " - " << p_max << std::endl;
22
23
int
N = 1;
24
25
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
26
27
{
28
Timer
timer;
29
timer.
start
();
30
31
int
i = 0;
32
for
(
int
n = 0; n < N; ++n)
33
{
34
for
(
int
y = 0; y <
rgb_image
.rows; ++y)
35
{
36
for
(
int
x = 0; x <
rgb_image
.cols; ++x)
37
{
38
i +=
rgb_image
.at<cv::Vec3b>(y, x)[0];
39
}
40
}
41
}
42
43
timer.
stop
();
44
45
std::cout
<<
"Check value: "
<< i <<
std::endl
;
46
std::cout
<< timer.
getElapsedTimeInMilliSec
() / N <<
" ms"
<<
std::endl
;
47
}
48
49
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
50
51
{
52
Timer
timer;
53
timer.
start
();
54
55
int
i = 0;
56
for
(
int
n = 0; n < N; ++n)
57
{
58
for
(
ed::ImageMask::const_iterator
it = m.
begin
(); it != m.
end
(); ++it)
59
{
60
// std::cout << *it << std::endl;
61
i +=
rgb_image
.at<cv::Vec3b>(it())[0];
62
}
63
}
64
65
timer.
stop
();
66
67
std::cout
<<
"Check value: "
<< i <<
std::endl
;
68
std::cout
<< timer.
getElapsedTimeInMilliSec
() / N <<
" ms"
<<
std::endl
;
69
70
}
71
72
return
0;
73
}
ed::ImageMask::const_iterator
Definition:
mask.h:112
rgb_image
cv::Mat rgb_image
Timer
std::cout
Timer::start
void start()
ed::ImageMask::addPoint
void addPoint(const cv::Point2i &p)
Definition:
mask.h:71
Timer.h
mask.h
Timer::getElapsedTimeInMilliSec
double getElapsedTimeInMilliSec() const
std::endl
T endl(T... args)
main
int main()
Definition:
test_mask.cpp:5
ed::ImageMask
Definition:
mask.h:17
ed::ImageMask::begin
const_iterator begin(int width=0) const
Definition:
mask.h:180
ed::ImageMask::end
const_iterator end() const
Definition:
mask.h:188
Timer::stop
void stop()
Generated on Sun Feb 23 2025 04:34:40 for ed by
1.8.17