Restructure protobuf/add annotations
All checks were successful
Tests / Tests (pull_request) Successful in 6s

This commit is contained in:
Ivan Malison 2024-05-24 14:28:41 -06:00
parent 044d8fa46d
commit 9ad47848f6
4 changed files with 322 additions and 100 deletions

View File

@ -13,19 +13,23 @@ _sym_db = _symbol_database.Default()
DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\nshot.proto\x12\x0fserialized_shot\",\n\x05Point\x12\t\n\x01x\x18\x01 \x01(\x02\x12\t\n\x01y\x18\x02 \x01(\x02\x12\r\n\x05\x63ount\x18\x03 \x01(\x05\"i\n\x04Path\x12\x13\n\x0bstart_frame\x18\x01 \x01(\x05\x12\x11\n\tend_frame\x18\x02 \x01(\x05\x12\x11\n\tis_static\x18\x03 \x01(\x08\x12&\n\x06points\x18\x04 \x03(\x0b\x32\x16.serialized_shot.Point\"J\n\tBallPaths\x12\x17\n\x0f\x62\x61ll_identifier\x18\x01 \x01(\x05\x12$\n\x05paths\x18\x02 \x03(\x0b\x32\x15.serialized_shot.Path\"^\n\x04Shot\x12\x13\n\x0bstart_frame\x18\x01 \x01(\x05\x12\x11\n\tend_frame\x18\x02 \x01(\x05\x12.\n\nball_paths\x18\x03 \x03(\x0b\x32\x1a.serialized_shot.BallPathsb\x06proto3')
DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\nshot.proto\x12\x0fserialized_shot\"?\n\x03\x42ox\x12\x0c\n\x04left\x18\x01 \x01(\x02\x12\x0b\n\x03top\x18\x02 \x01(\x02\x12\r\n\x05width\x18\x03 \x01(\x02\x12\x0e\n\x06height\x18\x04 \x01(\x02\"\x1d\n\x05Point\x12\t\n\x01x\x18\x01 \x01(\x02\x12\t\n\x01y\x18\x02 \x01(\x02\"\x91\x01\n\x10RLEBallDetection\x12.\n\x0eplane_position\x18\x01 \x01(\x0b\x32\x16.serialized_shot.Point\x12(\n\nannotation\x18\x02 \x01(\x0b\x32\x14.serialized_shot.Box\x12\x14\n\x0cinterpolated\x18\x03 \x01(\x08\x12\r\n\x05\x63ount\x18\x04 \x01(\x05\"I\n\x0cPathMetaData\x12\x13\n\x0bstart_frame\x18\x01 \x01(\x05\x12\x11\n\tend_frame\x18\x02 \x01(\x05\x12\x11\n\tis_static\x18\x03 \x01(\x08\"\x95\x01\n\x10\x44\x65tectionHistory\x12\x17\n\x0f\x62\x61ll_identifier\x18\x01 \x01(\x05\x12\x35\n\ndetections\x18\x02 \x03(\x0b\x32!.serialized_shot.RLEBallDetection\x12\x31\n\nmeta_datas\x18\x03 \x03(\x0b\x32\x1d.serialized_shot.PathMetaData\"n\n\x04Shot\x12\x13\n\x0bstart_frame\x18\x01 \x01(\x05\x12\x11\n\tend_frame\x18\x02 \x01(\x05\x12>\n\x13\x64\x65tection_histories\x18\x03 \x03(\x0b\x32!.serialized_shot.DetectionHistoryb\x06proto3')
_globals = globals()
_builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals)
_builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'shot_pb2', _globals)
if _descriptor._USE_C_DESCRIPTORS == False:
DESCRIPTOR._options = None
_globals['_POINT']._serialized_start=31
_globals['_POINT']._serialized_end=75
_globals['_PATH']._serialized_start=77
_globals['_PATH']._serialized_end=182
_globals['_BALLPATHS']._serialized_start=184
_globals['_BALLPATHS']._serialized_end=258
_globals['_SHOT']._serialized_start=260
_globals['_SHOT']._serialized_end=354
_globals['_BOX']._serialized_start=31
_globals['_BOX']._serialized_end=94
_globals['_POINT']._serialized_start=96
_globals['_POINT']._serialized_end=125
_globals['_RLEBALLDETECTION']._serialized_start=128
_globals['_RLEBALLDETECTION']._serialized_end=273
_globals['_PATHMETADATA']._serialized_start=275
_globals['_PATHMETADATA']._serialized_end=348
_globals['_DETECTIONHISTORY']._serialized_start=351
_globals['_DETECTIONHISTORY']._serialized_end=500
_globals['_SHOT']._serialized_start=502
_globals['_SHOT']._serialized_end=612
# @@protoc_insertion_point(module_scope)

View File

@ -5,42 +5,64 @@ from typing import ClassVar as _ClassVar, Iterable as _Iterable, Mapping as _Map
DESCRIPTOR: _descriptor.FileDescriptor
class Box(_message.Message):
__slots__ = ["left", "top", "width", "height"]
LEFT_FIELD_NUMBER: _ClassVar[int]
TOP_FIELD_NUMBER: _ClassVar[int]
WIDTH_FIELD_NUMBER: _ClassVar[int]
HEIGHT_FIELD_NUMBER: _ClassVar[int]
left: float
top: float
width: float
height: float
def __init__(self, left: _Optional[float] = ..., top: _Optional[float] = ..., width: _Optional[float] = ..., height: _Optional[float] = ...) -> None: ...
class Point(_message.Message):
__slots__ = ["x", "y", "count"]
__slots__ = ["x", "y"]
X_FIELD_NUMBER: _ClassVar[int]
Y_FIELD_NUMBER: _ClassVar[int]
COUNT_FIELD_NUMBER: _ClassVar[int]
x: float
y: float
count: int
def __init__(self, x: _Optional[float] = ..., y: _Optional[float] = ..., count: _Optional[int] = ...) -> None: ...
def __init__(self, x: _Optional[float] = ..., y: _Optional[float] = ...) -> None: ...
class Path(_message.Message):
__slots__ = ["start_frame", "end_frame", "is_static", "points"]
class RLEBallDetection(_message.Message):
__slots__ = ["plane_position", "annotation", "interpolated", "count"]
PLANE_POSITION_FIELD_NUMBER: _ClassVar[int]
ANNOTATION_FIELD_NUMBER: _ClassVar[int]
INTERPOLATED_FIELD_NUMBER: _ClassVar[int]
COUNT_FIELD_NUMBER: _ClassVar[int]
plane_position: Point
annotation: Box
interpolated: bool
count: int
def __init__(self, plane_position: _Optional[_Union[Point, _Mapping]] = ..., annotation: _Optional[_Union[Box, _Mapping]] = ..., interpolated: bool = ..., count: _Optional[int] = ...) -> None: ...
class PathMetaData(_message.Message):
__slots__ = ["start_frame", "end_frame", "is_static"]
START_FRAME_FIELD_NUMBER: _ClassVar[int]
END_FRAME_FIELD_NUMBER: _ClassVar[int]
IS_STATIC_FIELD_NUMBER: _ClassVar[int]
POINTS_FIELD_NUMBER: _ClassVar[int]
start_frame: int
end_frame: int
is_static: bool
points: _containers.RepeatedCompositeFieldContainer[Point]
def __init__(self, start_frame: _Optional[int] = ..., end_frame: _Optional[int] = ..., is_static: bool = ..., points: _Optional[_Iterable[_Union[Point, _Mapping]]] = ...) -> None: ...
def __init__(self, start_frame: _Optional[int] = ..., end_frame: _Optional[int] = ..., is_static: bool = ...) -> None: ...
class BallPaths(_message.Message):
__slots__ = ["ball_identifier", "paths"]
class DetectionHistory(_message.Message):
__slots__ = ["ball_identifier", "detections", "meta_datas"]
BALL_IDENTIFIER_FIELD_NUMBER: _ClassVar[int]
PATHS_FIELD_NUMBER: _ClassVar[int]
DETECTIONS_FIELD_NUMBER: _ClassVar[int]
META_DATAS_FIELD_NUMBER: _ClassVar[int]
ball_identifier: int
paths: _containers.RepeatedCompositeFieldContainer[Path]
def __init__(self, ball_identifier: _Optional[int] = ..., paths: _Optional[_Iterable[_Union[Path, _Mapping]]] = ...) -> None: ...
detections: _containers.RepeatedCompositeFieldContainer[RLEBallDetection]
meta_datas: _containers.RepeatedCompositeFieldContainer[PathMetaData]
def __init__(self, ball_identifier: _Optional[int] = ..., detections: _Optional[_Iterable[_Union[RLEBallDetection, _Mapping]]] = ..., meta_datas: _Optional[_Iterable[_Union[PathMetaData, _Mapping]]] = ...) -> None: ...
class Shot(_message.Message):
__slots__ = ["start_frame", "end_frame", "ball_paths"]
__slots__ = ["start_frame", "end_frame", "detection_histories"]
START_FRAME_FIELD_NUMBER: _ClassVar[int]
END_FRAME_FIELD_NUMBER: _ClassVar[int]
BALL_PATHS_FIELD_NUMBER: _ClassVar[int]
DETECTION_HISTORIES_FIELD_NUMBER: _ClassVar[int]
start_frame: int
end_frame: int
ball_paths: _containers.RepeatedCompositeFieldContainer[BallPaths]
def __init__(self, start_frame: _Optional[int] = ..., end_frame: _Optional[int] = ..., ball_paths: _Optional[_Iterable[_Union[BallPaths, _Mapping]]] = ...) -> None: ...
detection_histories: _containers.RepeatedCompositeFieldContainer[DetectionHistory]
def __init__(self, start_frame: _Optional[int] = ..., end_frame: _Optional[int] = ..., detection_histories: _Optional[_Iterable[_Union[DetectionHistory, _Mapping]]] = ...) -> None: ...

View File

@ -2,26 +2,39 @@ syntax = "proto3";
package serialized_shot;
message Box {
float left = 1;
float top = 2;
float width = 3;
float height = 4;
}
message Point {
float x = 1;
float y = 2;
int32 count = 3;
}
message Path {
message RLEBallDetection {
Point plane_position = 1;
Box annotation = 2;
bool interpolated = 3;
int32 count = 4;
}
message PathMetaData {
int32 start_frame = 1;
int32 end_frame = 2;
bool is_static = 3;
repeated Point points = 4;
}
message BallPaths {
message DetectionHistory {
int32 ball_identifier = 1;
repeated Path paths = 2;
repeated RLEBallDetection detections = 2;
repeated PathMetaData meta_datas = 3;
}
message Shot {
int32 start_frame = 1;
int32 end_frame = 2;
repeated BallPaths ball_paths = 3;
}
repeated DetectionHistory detection_histories = 3;
}

View File

@ -1,7 +1,95 @@
export interface Box {
left?: number;
top?: number;
width?: number;
height?: number;
}
export function encodeBox(message: Box): Uint8Array {
let bb = popByteBuffer();
_encodeBox(message, bb);
return toUint8Array(bb);
}
function _encodeBox(message: Box, bb: ByteBuffer): void {
// optional float left = 1;
let $left = message.left;
if ($left !== undefined) {
writeVarint32(bb, 13);
writeFloat(bb, $left);
}
// optional float top = 2;
let $top = message.top;
if ($top !== undefined) {
writeVarint32(bb, 21);
writeFloat(bb, $top);
}
// optional float width = 3;
let $width = message.width;
if ($width !== undefined) {
writeVarint32(bb, 29);
writeFloat(bb, $width);
}
// optional float height = 4;
let $height = message.height;
if ($height !== undefined) {
writeVarint32(bb, 37);
writeFloat(bb, $height);
}
}
export function decodeBox(binary: Uint8Array): Box {
return _decodeBox(wrapByteBuffer(binary));
}
function _decodeBox(bb: ByteBuffer): Box {
let message: Box = {} as any;
end_of_message: while (!isAtEnd(bb)) {
let tag = readVarint32(bb);
switch (tag >>> 3) {
case 0:
break end_of_message;
// optional float left = 1;
case 1: {
message.left = readFloat(bb);
break;
}
// optional float top = 2;
case 2: {
message.top = readFloat(bb);
break;
}
// optional float width = 3;
case 3: {
message.width = readFloat(bb);
break;
}
// optional float height = 4;
case 4: {
message.height = readFloat(bb);
break;
}
default:
skipUnknownField(bb, tag & 7);
}
}
return message;
}
export interface Point {
x?: number;
y?: number;
count?: number;
}
export function encodePoint(message: Point): Uint8Array {
@ -24,13 +112,6 @@ function _encodePoint(message: Point, bb: ByteBuffer): void {
writeVarint32(bb, 21);
writeFloat(bb, $y);
}
// optional int32 count = 3;
let $count = message.count;
if ($count !== undefined) {
writeVarint32(bb, 24);
writeVarint64(bb, intToLong($count));
}
}
export function decodePoint(binary: Uint8Array): Point {
@ -59,8 +140,106 @@ function _decodePoint(bb: ByteBuffer): Point {
break;
}
// optional int32 count = 3;
default:
skipUnknownField(bb, tag & 7);
}
}
return message;
}
export interface RLEBallDetection {
plane_position?: Point;
annotation?: Box;
interpolated?: boolean;
count?: number;
}
export function encodeRLEBallDetection(message: RLEBallDetection): Uint8Array {
let bb = popByteBuffer();
_encodeRLEBallDetection(message, bb);
return toUint8Array(bb);
}
function _encodeRLEBallDetection(
message: RLEBallDetection,
bb: ByteBuffer,
): void {
// optional Point plane_position = 1;
let $plane_position = message.plane_position;
if ($plane_position !== undefined) {
writeVarint32(bb, 10);
let nested = popByteBuffer();
_encodePoint($plane_position, nested);
writeVarint32(bb, nested.limit);
writeByteBuffer(bb, nested);
pushByteBuffer(nested);
}
// optional Box annotation = 2;
let $annotation = message.annotation;
if ($annotation !== undefined) {
writeVarint32(bb, 18);
let nested = popByteBuffer();
_encodeBox($annotation, nested);
writeVarint32(bb, nested.limit);
writeByteBuffer(bb, nested);
pushByteBuffer(nested);
}
// optional bool interpolated = 3;
let $interpolated = message.interpolated;
if ($interpolated !== undefined) {
writeVarint32(bb, 24);
writeByte(bb, $interpolated ? 1 : 0);
}
// optional int32 count = 4;
let $count = message.count;
if ($count !== undefined) {
writeVarint32(bb, 32);
writeVarint64(bb, intToLong($count));
}
}
export function decodeRLEBallDetection(binary: Uint8Array): RLEBallDetection {
return _decodeRLEBallDetection(wrapByteBuffer(binary));
}
function _decodeRLEBallDetection(bb: ByteBuffer): RLEBallDetection {
let message: RLEBallDetection = {} as any;
end_of_message: while (!isAtEnd(bb)) {
let tag = readVarint32(bb);
switch (tag >>> 3) {
case 0:
break end_of_message;
// optional Point plane_position = 1;
case 1: {
let limit = pushTemporaryLength(bb);
message.plane_position = _decodePoint(bb);
bb.limit = limit;
break;
}
// optional Box annotation = 2;
case 2: {
let limit = pushTemporaryLength(bb);
message.annotation = _decodeBox(bb);
bb.limit = limit;
break;
}
// optional bool interpolated = 3;
case 3: {
message.interpolated = !!readByte(bb);
break;
}
// optional int32 count = 4;
case 4: {
message.count = readVarint32(bb);
break;
}
@ -73,20 +252,19 @@ function _decodePoint(bb: ByteBuffer): Point {
return message;
}
export interface Path {
export interface PathMetaData {
start_frame?: number;
end_frame?: number;
is_static?: boolean;
points?: Point[];
}
export function encodePath(message: Path): Uint8Array {
export function encodePathMetaData(message: PathMetaData): Uint8Array {
let bb = popByteBuffer();
_encodePath(message, bb);
_encodePathMetaData(message, bb);
return toUint8Array(bb);
}
function _encodePath(message: Path, bb: ByteBuffer): void {
function _encodePathMetaData(message: PathMetaData, bb: ByteBuffer): void {
// optional int32 start_frame = 1;
let $start_frame = message.start_frame;
if ($start_frame !== undefined) {
@ -107,27 +285,14 @@ function _encodePath(message: Path, bb: ByteBuffer): void {
writeVarint32(bb, 24);
writeByte(bb, $is_static ? 1 : 0);
}
// repeated Point points = 4;
let array$points = message.points;
if (array$points !== undefined) {
for (let value of array$points) {
writeVarint32(bb, 34);
let nested = popByteBuffer();
_encodePoint(value, nested);
writeVarint32(bb, nested.limit);
writeByteBuffer(bb, nested);
pushByteBuffer(nested);
}
}
}
export function decodePath(binary: Uint8Array): Path {
return _decodePath(wrapByteBuffer(binary));
export function decodePathMetaData(binary: Uint8Array): PathMetaData {
return _decodePathMetaData(wrapByteBuffer(binary));
}
function _decodePath(bb: ByteBuffer): Path {
let message: Path = {} as any;
function _decodePathMetaData(bb: ByteBuffer): PathMetaData {
let message: PathMetaData = {} as any;
end_of_message: while (!isAtEnd(bb)) {
let tag = readVarint32(bb);
@ -154,15 +319,6 @@ function _decodePath(bb: ByteBuffer): Path {
break;
}
// repeated Point points = 4;
case 4: {
let limit = pushTemporaryLength(bb);
let values = message.points || (message.points = []);
values.push(_decodePoint(bb));
bb.limit = limit;
break;
}
default:
skipUnknownField(bb, tag & 7);
}
@ -171,18 +327,22 @@ function _decodePath(bb: ByteBuffer): Path {
return message;
}
export interface BallPaths {
export interface DetectionHistory {
ball_identifier?: number;
paths?: Path[];
detections?: RLEBallDetection[];
meta_datas?: PathMetaData[];
}
export function encodeBallPaths(message: BallPaths): Uint8Array {
export function encodeDetectionHistory(message: DetectionHistory): Uint8Array {
let bb = popByteBuffer();
_encodeBallPaths(message, bb);
_encodeDetectionHistory(message, bb);
return toUint8Array(bb);
}
function _encodeBallPaths(message: BallPaths, bb: ByteBuffer): void {
function _encodeDetectionHistory(
message: DetectionHistory,
bb: ByteBuffer,
): void {
// optional int32 ball_identifier = 1;
let $ball_identifier = message.ball_identifier;
if ($ball_identifier !== undefined) {
@ -190,13 +350,26 @@ function _encodeBallPaths(message: BallPaths, bb: ByteBuffer): void {
writeVarint64(bb, intToLong($ball_identifier));
}
// repeated Path paths = 2;
let array$paths = message.paths;
if (array$paths !== undefined) {
for (let value of array$paths) {
// repeated RLEBallDetection detections = 2;
let array$detections = message.detections;
if (array$detections !== undefined) {
for (let value of array$detections) {
writeVarint32(bb, 18);
let nested = popByteBuffer();
_encodePath(value, nested);
_encodeRLEBallDetection(value, nested);
writeVarint32(bb, nested.limit);
writeByteBuffer(bb, nested);
pushByteBuffer(nested);
}
}
// repeated PathMetaData meta_datas = 3;
let array$meta_datas = message.meta_datas;
if (array$meta_datas !== undefined) {
for (let value of array$meta_datas) {
writeVarint32(bb, 26);
let nested = popByteBuffer();
_encodePathMetaData(value, nested);
writeVarint32(bb, nested.limit);
writeByteBuffer(bb, nested);
pushByteBuffer(nested);
@ -204,12 +377,12 @@ function _encodeBallPaths(message: BallPaths, bb: ByteBuffer): void {
}
}
export function decodeBallPaths(binary: Uint8Array): BallPaths {
return _decodeBallPaths(wrapByteBuffer(binary));
export function decodeDetectionHistory(binary: Uint8Array): DetectionHistory {
return _decodeDetectionHistory(wrapByteBuffer(binary));
}
function _decodeBallPaths(bb: ByteBuffer): BallPaths {
let message: BallPaths = {} as any;
function _decodeDetectionHistory(bb: ByteBuffer): DetectionHistory {
let message: DetectionHistory = {} as any;
end_of_message: while (!isAtEnd(bb)) {
let tag = readVarint32(bb);
@ -224,11 +397,20 @@ function _decodeBallPaths(bb: ByteBuffer): BallPaths {
break;
}
// repeated Path paths = 2;
// repeated RLEBallDetection detections = 2;
case 2: {
let limit = pushTemporaryLength(bb);
let values = message.paths || (message.paths = []);
values.push(_decodePath(bb));
let values = message.detections || (message.detections = []);
values.push(_decodeRLEBallDetection(bb));
bb.limit = limit;
break;
}
// repeated PathMetaData meta_datas = 3;
case 3: {
let limit = pushTemporaryLength(bb);
let values = message.meta_datas || (message.meta_datas = []);
values.push(_decodePathMetaData(bb));
bb.limit = limit;
break;
}
@ -244,7 +426,7 @@ function _decodeBallPaths(bb: ByteBuffer): BallPaths {
export interface Shot {
start_frame?: number;
end_frame?: number;
ball_paths?: BallPaths[];
detection_histories?: DetectionHistory[];
}
export function encodeShot(message: Shot): Uint8Array {
@ -268,13 +450,13 @@ function _encodeShot(message: Shot, bb: ByteBuffer): void {
writeVarint64(bb, intToLong($end_frame));
}
// repeated BallPaths ball_paths = 3;
let array$ball_paths = message.ball_paths;
if (array$ball_paths !== undefined) {
for (let value of array$ball_paths) {
// repeated DetectionHistory detection_histories = 3;
let array$detection_histories = message.detection_histories;
if (array$detection_histories !== undefined) {
for (let value of array$detection_histories) {
writeVarint32(bb, 26);
let nested = popByteBuffer();
_encodeBallPaths(value, nested);
_encodeDetectionHistory(value, nested);
writeVarint32(bb, nested.limit);
writeByteBuffer(bb, nested);
pushByteBuffer(nested);
@ -308,11 +490,12 @@ function _decodeShot(bb: ByteBuffer): Shot {
break;
}
// repeated BallPaths ball_paths = 3;
// repeated DetectionHistory detection_histories = 3;
case 3: {
let limit = pushTemporaryLength(bb);
let values = message.ball_paths || (message.ball_paths = []);
values.push(_decodeBallPaths(bb));
let values =
message.detection_histories || (message.detection_histories = []);
values.push(_decodeDetectionHistory(bb));
bb.limit = limit;
break;
}