Created
February 5, 2019 10:23
-
-
Save alexcpn/e817f029ad3d6f75f8867936cf2cf5bf to your computer and use it in GitHub Desktop.
Python Protobuffer GRPC assign to nested type and assign to repeated types
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
obj1 = proto.Object.Detection() | |
obj1.classname= classname | |
bbox = proto.BoundingBox() | |
bbox.X1 =1 | |
# Use CopyFrom to assign to nested element | |
obj1.boundingbox.CopyFrom(bbox) | |
obj1.object_id = random.randint(1, 6) | |
callback = proto.Object() | |
# use Extend to add to repeated elements | |
callback.Objects.extend([obj1,]) | |
callback.media_id = int(id) | |
callback.frame_id = int(id) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
message Object { | |
message Detection { | |
string classname = 1 ; | |
BoundingBox boundingbox =2 ; | |
int32 object_id =5; | |
} | |
repeated Detection Objects = 2 ; | |
double detected_time =3 ; | |
int32 media_id = 4 ; | |
int32 frame_id = 5 ; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment