/
CameraInfo.cs
164 lines (155 loc) · 7.36 KB
/
CameraInfo.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;
//////////////////////////////////////////////////
///// AUTOGENERATED MESSAGE DEFINITION /////
//////////////////////////////////////////////////
///// DO NOT MODIFY BY HAND! /////
//////////////////////////////////////////////////
namespace ROS_CS
{
namespace sensor_msgs
{
public class CameraInfo : ROS_CS.Core.BaseMessage
{
public readonly string typeID = "CameraInfo";
public readonly string md5sum = "c9a58c1b0b154e0e6da7578cb991d214";
public std_msgs.Header header;
public System.UInt32 height;
public System.UInt32 width;
public string distortion_model;
public List<double> D;
public double[] K;
public double[] R;
public double[] P;
public System.UInt32 binning_x;
public System.UInt32 binning_y;
public sensor_msgs.RegionOfInterest roi;
public CameraInfo ()
{
header = new std_msgs.Header();
height = 0;
width = 0;
distortion_model = "";
D = new List<double>();
K = new double[9];
R = new double[9];
P = new double[12];
binning_x = 0;
binning_y = 0;
roi = new sensor_msgs.RegionOfInterest();
}
public override string ToString ()
{
return ROS_CS.Core.PrettyPrinter.PrettyPrint(ToStringRaw());
}
public override string ToStringRaw ()
{
string string_rep = typeID + ":\n";
string_rep += header.ToStringRaw() + "\n";
string_rep += "height: " + Convert.ToString(height) + "\n";
string_rep += "width: " + Convert.ToString(width) + "\n";
string_rep += "distortion_model: " + distortion_model + "\n";
string_rep += "D:\n[";
foreach (double element in D)
{
string_rep += " " + Convert.ToString(element);
}
string_rep += "]\n\n";
string_rep += "K: " + K + "\n";
string_rep += "R: " + R + "\n";
string_rep += "P: " + P + "\n";
string_rep += "binning_x: " + Convert.ToString(binning_x) + "\n";
string_rep += "binning_y: " + Convert.ToString(binning_y) + "\n";
string_rep += roi.ToStringRaw() + "\n";
return string_rep;
}
public override void Serialize(MemoryStream stream)
{
header.Serialize(stream);
System.Byte[] height_bytes = BitConverter.GetBytes(height);
stream.Write(height_bytes, 0, height_bytes.Length);
System.Byte[] width_bytes = BitConverter.GetBytes(width);
stream.Write(width_bytes, 0, width_bytes.Length);
System.Byte[] distortion_model_bytes = System.Text.Encoding.UTF8.GetBytes(distortion_model);
System.Byte[] distortion_model_len_bytes = BitConverter.GetBytes((System.UInt32)distortion_model_bytes.Length);
stream.Write(distortion_model_len_bytes, 0, distortion_model_len_bytes.Length);
stream.Write(distortion_model_bytes, 0, distortion_model_bytes.Length);
System.Byte[] D_len_bytes = BitConverter.GetBytes((System.UInt32)D.Count);
stream.Write(D_len_bytes, 0, D_len_bytes.Length);
foreach(double element in D)
{
System.Byte[] element_bytes = BitConverter.GetBytes(element);
stream.Write(element_bytes, 0, element_bytes.Length);
}
foreach(double element in K)
{
System.Byte[] element_bytes = BitConverter.GetBytes(element);
stream.Write(element_bytes, 0, element_bytes.Length);
}
foreach(double element in R)
{
System.Byte[] element_bytes = BitConverter.GetBytes(element);
stream.Write(element_bytes, 0, element_bytes.Length);
}
foreach(double element in P)
{
System.Byte[] element_bytes = BitConverter.GetBytes(element);
stream.Write(element_bytes, 0, element_bytes.Length);
}
System.Byte[] binning_x_bytes = BitConverter.GetBytes(binning_x);
stream.Write(binning_x_bytes, 0, binning_x_bytes.Length);
System.Byte[] binning_y_bytes = BitConverter.GetBytes(binning_y);
stream.Write(binning_y_bytes, 0, binning_y_bytes.Length);
roi.Serialize(stream);
}
public override int Deserialize(System.Byte[] serialized)
{
return Deserialize(serialized, 0);
}
public override int Deserialize(System.Byte[] serialized, int startIndex)
{
int curIndex = startIndex;
curIndex += header.Deserialize(serialized, curIndex);
height = BitConverter.ToUInt32(serialized, curIndex);
curIndex += BitConverter.GetBytes(height).Length;
width = BitConverter.ToUInt32(serialized, curIndex);
curIndex += BitConverter.GetBytes(width).Length;
System.UInt32 distortion_model_len = BitConverter.ToUInt32(serialized, curIndex);
curIndex += BitConverter.GetBytes(distortion_model_len).Length;
distortion_model = System.Text.Encoding.UTF8.GetString(serialized, curIndex, (int)distortion_model_len);
curIndex += (int)distortion_model_len;
System.UInt32 D_len = BitConverter.ToUInt32(serialized, curIndex);
curIndex += BitConverter.GetBytes(D_len).Length;
for (int i = 0; i < (int)D_len; i++)
{
double element = BitConverter.ToDouble(serialized, curIndex);
curIndex += BitConverter.GetBytes(element).Length;
D.Add(element);
}
for (int i = 0; i < (int)K.Length; i++)
{
K[i] = BitConverter.ToDouble(serialized, curIndex);
curIndex += BitConverter.GetBytes(K[i]).Length;
}
for (int i = 0; i < (int)R.Length; i++)
{
R[i] = BitConverter.ToDouble(serialized, curIndex);
curIndex += BitConverter.GetBytes(R[i]).Length;
}
for (int i = 0; i < (int)P.Length; i++)
{
P[i] = BitConverter.ToDouble(serialized, curIndex);
curIndex += BitConverter.GetBytes(P[i]).Length;
}
binning_x = BitConverter.ToUInt32(serialized, curIndex);
curIndex += BitConverter.GetBytes(binning_x).Length;
binning_y = BitConverter.ToUInt32(serialized, curIndex);
curIndex += BitConverter.GetBytes(binning_y).Length;
curIndex += roi.Deserialize(serialized, curIndex);
return (curIndex - startIndex);
}
}
}
}