YARP
Yet Another Robot Platform
rosPixelCode.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2006-2020 Istituto Italiano di Tecnologia (IIT)
3  * All rights reserved.
4  *
5  * This software may be modified and distributed under the terms of the
6  * BSD-3-Clause license. See the accompanying LICENSE file for details.
7  */
8 
9 #include "rosPixelCode.h"
10 
11 namespace yarp {
12  namespace dev {
13  namespace ROSPixelCode {
14 
15 std::string yarp2RosPixelCode(int code)
16 {
17  switch (code)
18  {
19  case VOCAB_PIXEL_BGR:
20  return BGR8;
21  case VOCAB_PIXEL_BGRA:
22  return BGRA8;
24  return BAYER_BGGR16;
26  return BAYER_BGGR8;
28  return BAYER_GBRG16;
30  return BAYER_GBRG8;
32  return BAYER_GRBG16;
34  return BAYER_GRBG8;
36  return BAYER_RGGB16;
38  return BAYER_RGGB8;
39  case VOCAB_PIXEL_MONO:
40  return MONO8;
41  case VOCAB_PIXEL_MONO16:
42  return MONO16;
43  case VOCAB_PIXEL_RGB:
44  return RGB8;
45  case VOCAB_PIXEL_RGBA:
46  return RGBA8;
48  return TYPE_32FC1;
49  default:
50  return RGB8;
51  }
52 }
53 
54 int Ros2YarpPixelCode(const std::string& roscode)
55 {
56  if (roscode == BGR8)
57  return VOCAB_PIXEL_BGR;
58  else if (roscode == BGRA8)
59  return VOCAB_PIXEL_BGRA;
60  else if (roscode == BAYER_BGGR8)
62  else if (roscode == BAYER_GBRG16)
64  else if (roscode == BAYER_GBRG8)
66  else if (roscode == BAYER_GRBG16)
68  else if (roscode == BAYER_GRBG8)
70  else if (roscode == BAYER_RGGB16)
72  else if (roscode == BAYER_RGGB8)
74  else if (roscode == MONO8)
75  return VOCAB_PIXEL_MONO;
76  else if (roscode == MONO16)
77  return VOCAB_PIXEL_MONO16;
78  else if (roscode == RGB8)
79  return VOCAB_PIXEL_RGB;
80  else if (roscode == RGBA8)
81  return VOCAB_PIXEL_RGBA;
82  else if (roscode == TYPE_32FC1)
84  else
85  return VOCAB_PIXEL_INVALID;
86 }
87 
88 }}}
yarp::dev::ROSPixelCode::yarp2RosPixelCode
std::string yarp2RosPixelCode(int code)
Definition: rosPixelCode.cpp:15
BGR8
#define BGR8
Definition: rosPixelCode.h:28
VOCAB_PIXEL_ENCODING_BAYER_BGGR16
@ VOCAB_PIXEL_ENCODING_BAYER_BGGR16
Definition: Image.h:65
BGRA8
#define BGRA8
Definition: rosPixelCode.h:30
MONO8
#define MONO8
Definition: rosPixelCode.h:32
rosPixelCode.h
BAYER_BGGR16
#define BAYER_BGGR16
Definition: rosPixelCode.h:19
MONO16
#define MONO16
Definition: rosPixelCode.h:31
VOCAB_PIXEL_ENCODING_BAYER_RGGB8
@ VOCAB_PIXEL_ENCODING_BAYER_RGGB8
Definition: Image.h:68
VOCAB_PIXEL_RGBA
@ VOCAB_PIXEL_RGBA
Definition: Image.h:51
BAYER_GBRG16
#define BAYER_GBRG16
Definition: rosPixelCode.h:21
RGB8
#define RGB8
Definition: rosPixelCode.h:34
BAYER_GRBG16
#define BAYER_GRBG16
Definition: rosPixelCode.h:23
VOCAB_PIXEL_ENCODING_BAYER_RGGB16
@ VOCAB_PIXEL_ENCODING_BAYER_RGGB16
Definition: Image.h:69
VOCAB_PIXEL_ENCODING_BAYER_GBRG16
@ VOCAB_PIXEL_ENCODING_BAYER_GBRG16
Definition: Image.h:67
VOCAB_PIXEL_BGRA
@ VOCAB_PIXEL_BGRA
Definition: Image.h:52
RGBA8
#define RGBA8
Definition: rosPixelCode.h:36
VOCAB_PIXEL_ENCODING_BAYER_GRBG16
@ VOCAB_PIXEL_ENCODING_BAYER_GRBG16
Definition: Image.h:63
VOCAB_PIXEL_ENCODING_BAYER_GBRG8
@ VOCAB_PIXEL_ENCODING_BAYER_GBRG8
Definition: Image.h:66
VOCAB_PIXEL_INVALID
@ VOCAB_PIXEL_INVALID
Definition: Image.h:47
TYPE_32FC1
#define TYPE_32FC1
Definition: rosPixelCode.h:45
VOCAB_PIXEL_MONO
@ VOCAB_PIXEL_MONO
Definition: Image.h:48
yarp
The main, catch-all namespace for YARP.
Definition: environment.h:18
VOCAB_PIXEL_RGB
@ VOCAB_PIXEL_RGB
Definition: Image.h:50
VOCAB_PIXEL_ENCODING_BAYER_BGGR8
@ VOCAB_PIXEL_ENCODING_BAYER_BGGR8
Definition: Image.h:64
BAYER_GRBG8
#define BAYER_GRBG8
Definition: rosPixelCode.h:24
BAYER_RGGB8
#define BAYER_RGGB8
Definition: rosPixelCode.h:26
VOCAB_PIXEL_MONO16
@ VOCAB_PIXEL_MONO16
Definition: Image.h:49
BAYER_BGGR8
#define BAYER_BGGR8
Definition: rosPixelCode.h:20
VOCAB_PIXEL_BGR
@ VOCAB_PIXEL_BGR
Definition: Image.h:55
BAYER_RGGB16
#define BAYER_RGGB16
Definition: rosPixelCode.h:25
yarp::dev::ROSPixelCode::Ros2YarpPixelCode
int Ros2YarpPixelCode(const std::string &roscode)
Definition: rosPixelCode.cpp:54
BAYER_GBRG8
#define BAYER_GBRG8
Definition: rosPixelCode.h:22
VOCAB_PIXEL_ENCODING_BAYER_GRBG8
@ VOCAB_PIXEL_ENCODING_BAYER_GRBG8
Definition: Image.h:62
VOCAB_PIXEL_MONO_FLOAT
@ VOCAB_PIXEL_MONO_FLOAT
Definition: Image.h:59