31 void renameImg(sensor_msgs::ImagePtr& in, sensor_msgs::ImagePtr& out,
const std::string out_format) {
33 ROS_WARN(
"camera_aravis::renameImg(): no input image given.");
40 out->encoding = out_format;
43 void shift(uint16_t* data,
const size_t length,
const size_t digits) {
44 for (
size_t i=0; i<
length; ++i) {
49 void shiftImg(sensor_msgs::ImagePtr& in, sensor_msgs::ImagePtr& out,
const size_t n_digits,
const std::string out_format)
52 ROS_WARN(
"camera_aravis::shiftImg(): no input image given.");
60 shift(
reinterpret_cast<uint16_t*
>(out->data.data()), out->data.size()/2, n_digits);
61 out->encoding = out_format;
64 void interleaveImg(sensor_msgs::ImagePtr& in, sensor_msgs::ImagePtr& out,
const size_t n_digits,
const std::string out_format)
67 ROS_WARN(
"camera_aravis::interleaveImg(): no input image given.");
72 out.reset(
new sensor_msgs::Image);
73 ROS_INFO(
"camera_aravis::interleaveImg(): no output image given. Reserved a new one.");
76 out->header = in->header;
77 out->height = in->height;
78 out->width = in->width;
79 out->is_bigendian = in->is_bigendian;
81 out->data.resize(in->data.size());
83 const size_t n_bytes = in->data.size() / (3 * in->width * in->height);
84 uint8_t* c0 = in->data.data();
85 uint8_t* c1 = in->data.data() + (in->data.size() / 3);
86 uint8_t* c2 = in->data.data() + (2 * in->data.size() / 3);
87 uint8_t* o = out->data.data();
89 for (uint32_t h=0; h<in->height; ++h) {
90 for (uint32_t w=0; w<in->width; ++w) {
91 for (
size_t i=0; i<n_bytes; ++i) {
94 o[i+2*n_bytes] = c2[i];
104 shift(
reinterpret_cast<uint16_t*
>(out->data.data()), out->data.size()/2, n_digits);
106 out->encoding = out_format;
109 void unpack10p32Img(sensor_msgs::ImagePtr& in, sensor_msgs::ImagePtr& out,
const std::string out_format) {
111 ROS_WARN(
"camera_aravis::unpack10pImg(): no input image given.");
116 out.reset(
new sensor_msgs::Image);
117 ROS_INFO(
"camera_aravis::unpack10pImg(): no output image given. Reserved a new one.");
120 out->header = in->header;
121 out->height = in->height;
122 out->width = in->width;
123 out->is_bigendian = in->is_bigendian;
124 out->step = (3*in->step)/2;
125 out->data.resize((3*in->data.size())/2);
134 uint8_t* from = in->data.data();
135 uint16_t* to =
reinterpret_cast<uint16_t*
>(out->data.data());
137 for (
size_t i=0; i<in->data.size()/4; ++i) {
139 std::memcpy(to, from, 2);
142 std::memcpy(&to[1], &from[1], 2);
144 to[1] &= 0b1111111111000000;
146 std::memcpy(&to[2], &from[2], 2);
148 to[2] &= 0b1111111111000000;
154 out->encoding = out_format;
157 void unpack10PackedImg(sensor_msgs::ImagePtr& in, sensor_msgs::ImagePtr& out,
const std::string out_format) {
159 ROS_WARN(
"camera_aravis::unpack10pImg(): no input image given.");
164 out.reset(
new sensor_msgs::Image);
165 ROS_INFO(
"camera_aravis::unpack10pImg(): no output image given. Reserved a new one.");
168 out->header = in->header;
169 out->height = in->height;
170 out->width = in->width;
171 out->is_bigendian = in->is_bigendian;
172 out->step = (3*in->step)/2;
173 out->data.resize((3*in->data.size())/2);
184 uint8_t* from = in->data.data();
185 uint8_t* to = out->data.data();
187 for (
size_t i=0; i<in->data.size()/4; ++i) {
191 to[2] = (from[0] & 0b00001100)<<4;
193 to[4] = (from[0] & 0b00110000)<<2;
199 out->encoding = out_format;
203 void unpack10pMonoImg(sensor_msgs::ImagePtr& in, sensor_msgs::ImagePtr& out,
const std::string out_format) {
205 ROS_WARN(
"camera_aravis::unpack10pImg(): no input image given.");
210 out.reset(
new sensor_msgs::Image);
211 ROS_INFO(
"camera_aravis::unpack10pImg(): no output image given. Reserved a new one.");
214 out->header = in->header;
215 out->height = in->height;
216 out->width = in->width;
217 out->is_bigendian = in->is_bigendian;
218 out->step = (8*in->step)/5;
219 out->data.resize((8*in->data.size())/5);
228 uint8_t* from = in->data.data();
229 uint16_t* to =
reinterpret_cast<uint16_t*
>(out->data.data());
231 for (
size_t i=0; i<in->data.size()/5; ++i) {
233 std::memcpy(to, from, 2);
236 std::memcpy(&to[1], &from[1], 2);
238 to[1] &= 0b1111111111000000;
240 std::memcpy(&to[2], &from[2], 2);
242 to[2] &= 0b1111111111000000;
244 std::memcpy(&to[3], &from[3], 2);
245 to[3] &= 0b1111111111000000;
250 out->encoding = out_format;
253 void unpack10PackedMonoImg(sensor_msgs::ImagePtr& in, sensor_msgs::ImagePtr& out,
const std::string out_format) {
255 ROS_WARN(
"camera_aravis::unpack10pImg(): no input image given.");
260 out.reset(
new sensor_msgs::Image);
261 ROS_INFO(
"camera_aravis::unpack10pImg(): no output image given. Reserved a new one.");
264 out->header = in->header;
265 out->height = in->height;
266 out->width = in->width;
267 out->is_bigendian = in->is_bigendian;
268 out->step = (4*in->step)/3;
269 out->data.resize((4*in->data.size())/3);
280 uint8_t* from = in->data.data();
281 uint8_t* to = out->data.data();
283 for (
size_t i=0; i<in->data.size()/3; ++i) {
288 to[2] = from[1] & 0b11000000;
294 out->encoding = out_format;
297 void unpack12pImg(sensor_msgs::ImagePtr& in, sensor_msgs::ImagePtr& out,
const std::string out_format) {
299 ROS_WARN(
"camera_aravis::unpack12pImg(): no input image given.");
304 out.reset(
new sensor_msgs::Image);
305 ROS_INFO(
"camera_aravis::unpack12pImg(): no output image given. Reserved a new one.");
308 out->header = in->header;
309 out->height = in->height;
310 out->width = in->width;
311 out->is_bigendian = in->is_bigendian;
312 out->step = (4*in->step)/3;
313 out->data.resize((4*in->data.size())/3);
322 uint8_t* from = in->data.data();
323 uint16_t* to =
reinterpret_cast<uint16_t*
>(out->data.data());
325 for (
size_t i=0; i<in->data.size()/3; ++i) {
327 std::memcpy(to, from, 2);
330 std::memcpy(&to[1], &from[1], 2);
331 to[1] &= 0b1111111111110000;
336 out->encoding = out_format;
339 void unpack12PackedImg(sensor_msgs::ImagePtr& in, sensor_msgs::ImagePtr& out,
const std::string out_format) {
341 ROS_WARN(
"camera_aravis::unpack12pImg(): no input image given.");
346 out.reset(
new sensor_msgs::Image);
347 ROS_INFO(
"camera_aravis::unpack12pImg(): no output image given. Reserved a new one.");
350 out->header = in->header;
351 out->height = in->height;
352 out->width = in->width;
353 out->is_bigendian = in->is_bigendian;
354 out->step = (4*in->step)/3;
355 out->data.resize((4*in->data.size())/3);
366 uint8_t* from = in->data.data();
367 uint8_t* to = out->data.data();
369 for (
size_t i=0; i<in->data.size()/3; ++i) {
374 to[2] = from[1] & 0b11110000;
380 out->encoding = out_format;
383 void unpack565pImg(sensor_msgs::ImagePtr& in, sensor_msgs::ImagePtr& out,
const std::string out_format) {
385 ROS_WARN(
"camera_aravis::unpack565pImg(): no input image given.");
390 out.reset(
new sensor_msgs::Image);
391 ROS_INFO(
"camera_aravis::unpack565pImg(): no output image given. Reserved a new one.");
394 out->header = in->header;
395 out->height = in->height;
396 out->width = in->width;
397 out->is_bigendian = in->is_bigendian;
398 out->step = (3*in->step)/2;
399 out->data.resize((3*in->data.size())/2);
408 uint8_t* from = in->data.data();
409 uint8_t* to = out->data.data();
411 for (
size_t i=0; i<in->data.size()/2; ++i) {
412 to[0] = from[0] << 3;
414 to[1] = from[0] >> 3;
415 to[1] |= (from[1]<<5);
418 to[2] = from[1] & 0b11111000;
423 out->encoding = out_format;