I have the following classes:
namespace Message;
struct BBox {
xmin:float;
xmax:float;
ymin:float;
ymax:float;
}
table msg {
key:string;
boxes: [BBox];
}
root_type Message;
To create the object I do something such as
b = flatbuffers.Builder(0)
msg.msgStart(b)
msg.msgAddKey(b, b.CreateString(key))
v = flatbuffers.Builder(0)
size = len(boxes)
msg.msgBoxesVector(v, size)
for elem in boxes:
xmin, ymin, xmax, ymax = elem
BBox.CreateBBox(v, xmin, xmax, ymin, ymax)
boxes = v.EndVector(size)
msg.msgAddBoxes(b, boxes)
obj = msg.msgEnd(b)
b.Finish(obj)
and no error is thrown
However when I try to display the results, the key is good but the size of the vector and the content is wrong
rep = msg.msg.GetRootAsmsg(bytearray(b.Output()), 0)
print rep.BoxesLength() # give me 4 instead of 1
for i in range(rep.BoxesLength()):
print rep.Boxes(i).Xmin(), rep.Boxes(i).Ymin()
print rep.Boxes(i).Xmax(), rep.Boxes(i).Ymax()