Go to the documentation of this file.00001
00006
00007
00008
00009
00010 #include "../../include/mm_vision_msgs/image_pair.hpp"
00011
00012
00013
00014
00015
00016 namespace mm_vision_msgs {
00017
00018 ImagePair::ImagePair(const unsigned char* left_buffer,
00019 const unsigned char *right_buffer,
00020 const unsigned int& size)
00021 : left(left_buffer, left_buffer + size),
00022 right(right_buffer, right_buffer + size),
00023 size(size)
00024 {
00025
00026 if (size == 76800) {
00027 width = 320;
00028 height = 240;
00029 colour = false;
00030 } else if (size == 153600) {
00031 width = 320;
00032 height = 240;
00033 colour = true;
00034 } else if (size == 307200) {
00035 width = 640;
00036 height = 480;
00037 colour = false;
00038 } else if (size == 614400) {
00039 width = 640;
00040 height = 480;
00041 colour = true;
00042 }
00043 }
00044
00045
00046 }
00047
00048
00049
00050
00051
00052 namespace mm_messages {
00053
00054
00055
00056
00068 void Message<mm_vision_msgs::ImagePairPtr>::encode(const mm_vision_msgs::ImagePairPtr& pair, ByteArray& buffer) {
00069
00070
00071 buffer = pair->left;
00072 buffer.insert(buffer.end(), pair->right.begin(), pair->right.end());
00073 }
00074
00082 mm_vision_msgs::ImagePairPtr Message<mm_vision_msgs::ImagePairPtr>::decode(const unsigned char* buffer, const unsigned int& size) {
00083 mm_vision_msgs::ImagePairPtr pair = std::make_shared<mm_vision_msgs::ImagePair>();
00084 pair->left.assign(buffer, buffer + size/2);
00085 pair->right.assign(buffer + size/2, buffer + size);
00086 pair->size = size/2;
00087 if (pair->size == 76800) {
00088 pair->width = 320;
00089 pair->height = 240;
00090 pair->colour = false;
00091 } else if (pair->size == 153600) {
00092 pair->width = 320;
00093 pair->height = 240;
00094 pair->colour = true;
00095 } else if (pair->size == 307200) {
00096 pair->width = 640;
00097 pair->height = 480;
00098 pair->colour = false;
00099 } else if (pair->size == 614400) {
00100 pair->width = 640;
00101 pair->height = 480;
00102 pair->colour = true;
00103 }
00104 return pair;
00105 }
00106
00107
00108 }