Visual Servoing Platform
version 3.6.0
Loading...
Searching...
No Matches
testImageOwnership.cpp
1
/****************************************************************************
2
*
3
* ViSP, open source Visual Servoing Platform software.
4
* Copyright (C) 2005 - 2023 by Inria. All rights reserved.
5
*
6
* This software is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation; either version 2 of the License, or
9
* (at your option) any later version.
10
* See the file LICENSE.txt at the root directory of this source
11
* distribution for additional information about the GNU GPL.
12
*
13
* For using ViSP with software that can not be combined with the GNU
14
* GPL, please contact Inria about acquiring a ViSP Professional
15
* Edition License.
16
*
17
* See https://visp.inria.fr for more information.
18
*
19
* This software was developed at:
20
* Inria Rennes - Bretagne Atlantique
21
* Campus Universitaire de Beaulieu
22
* 35042 Rennes Cedex
23
* France
24
*
25
* If you have questions regarding the use of this file, please contact
26
* Inria at visp@inria.fr
27
*
28
* This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
29
* WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
30
*
31
* Description:
32
* Test vpImage ownership
33
*
34
*****************************************************************************/
35
36
#include <visp3/core/vpImage.h>
37
43
44
int
main(
int
/* argc */
,
const
char
**
/* argv */
)
45
{
46
try
{
47
{
48
unsigned
char
bitmap[4];
49
bitmap[0] = 0;
50
bitmap[1] = 1;
51
bitmap[2] = 2;
52
bitmap[3] = 3;
53
54
vpImage<unsigned char>
I(bitmap, 2, 2,
true
);
55
std::cout <<
"I:\n"
<< I << std::endl;
56
I.destroy();
57
}
58
{
59
unsigned
char
bitmap[4];
60
bitmap[0] = 0;
61
bitmap[1] = 1;
62
bitmap[2] = 2;
63
bitmap[3] = 3;
64
65
vpImage<unsigned char>
I(bitmap, 2, 2,
false
);
66
std::cout <<
"\nI:\n"
<< I << std::endl;
67
}
68
{
69
unsigned
char
bitmap[4];
70
bitmap[0] = 0;
71
bitmap[1] = 1;
72
bitmap[2] = 2;
73
bitmap[3] = 3;
74
75
vpImage<unsigned char>
I(bitmap, 2, 2,
false
);
76
{
77
vpImage<unsigned char>
I2(I);
78
std::cout <<
"\nI2:\n"
<< I2 << std::endl;
79
}
80
{
81
vpImage<unsigned char>
I2 = I;
82
std::cout <<
"I2:\n"
<< I2 << std::endl;
83
}
84
}
85
{
86
unsigned
char
bitmap[12];
87
for
(
unsigned
char
i = 0; i < 12; i++) {
88
bitmap[i] = i;
89
}
90
91
vpImage<unsigned char>
I(bitmap, 3, 4,
false
);
92
std::cout <<
"\nI:\n"
<< I << std::endl;
93
I.init(2, 2, 0);
94
std::cout <<
"I:\n"
<< I << std::endl;
95
}
96
{
97
unsigned
char
bitmap[12];
98
for
(
unsigned
char
i = 0; i < 12; i++) {
99
bitmap[i] = i;
100
}
101
vpImage<unsigned char>
I(bitmap, 3, 4,
false
);
102
std::cout <<
"\nI:\n"
<< I << std::endl;
103
I.init(bitmap, 4, 3,
true
);
104
std::cout <<
"I:\n"
<< I << std::endl;
105
}
106
{
107
unsigned
char
*bitmap =
new
unsigned
char
[12];
108
{
109
vpImage<unsigned char>
I(bitmap, 3, 4,
true
);
110
}
111
delete
[] bitmap;
112
}
113
{
114
unsigned
char
*bitmap =
new
unsigned
char
[12];
115
{
116
vpImage<unsigned char>
I(bitmap, 3, 4,
false
);
117
}
118
vpImage<unsigned char>
I(bitmap, 3, 4,
false
);
119
120
delete
[] bitmap;
121
122
bitmap =
new
unsigned
char
[16];
123
I.init(bitmap, 4, 4,
false
);
124
125
delete
[] bitmap;
126
}
127
{
128
unsigned
char
*bitmap =
new
unsigned
char
[12];
129
vpImage<unsigned char>
I(bitmap, 3, 4,
false
);
130
I.destroy();
131
I.init(bitmap, 3, 4,
false
);
132
133
delete
[] bitmap;
134
135
I.destroy();
136
bitmap =
new
unsigned
char
[16];
137
I.init(bitmap, 4, 4,
false
);
138
139
delete
[] bitmap;
140
}
141
#if (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11)
142
{
143
unsigned
char
*bitmap =
new
unsigned
char
[12];
144
vpImage<unsigned char>
I = std::move(
vpImage<unsigned char>
(bitmap, 3, 4,
false
));
145
if
(bitmap != I.bitmap) {
146
std::cout <<
"std::move(vpImage) failed"
<< std::endl;
147
return
EXIT_FAILURE;
148
}
149
delete
[] bitmap;
150
}
151
{
152
unsigned
char
*bitmap =
new
unsigned
char
[12];
153
vpImage<unsigned char>
I(std::move(
vpImage<unsigned char>
(bitmap, 3, 4,
false
)));
154
if
(bitmap != I.bitmap) {
155
std::cout <<
"vpImage(td::move(vpImage)) failed"
<< std::endl;
156
return
EXIT_FAILURE;
157
}
158
delete
[] bitmap;
159
}
160
#endif
161
}
catch
(
const
std::exception &e) {
162
std::cerr <<
"Exception: "
<< e.what() << std::endl;
163
return
EXIT_FAILURE;
164
}
165
166
std::cout <<
"Test succeed"
<< std::endl;
167
return
EXIT_SUCCESS;
168
}
vpImage
Definition of the vpImage class member functions.
Definition
vpImage.h:135
modules
core
test
image
testImageOwnership.cpp
Generated by
1.15.0