Skip to content

Commit 3176c8c

Browse files
authored
[RSDK-10140] add relative bounding box coordinates to detections (#640)
Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com> I changed the comment from what was in Jira. I'm willing to change it back if you want, though personally I think this is more useful (making the comment say they're normalized doesn't add anything I didn't already get from the field names). The scope doc is in RSDK-10082.
1 parent 3fadd6b commit 3176c8c

File tree

4 files changed

+277
-6
lines changed

4 files changed

+277
-6
lines changed

gen/js/service/vision/v1/vision_pb.d.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,26 @@ export class Detection extends jspb.Message {
152152
getClassName(): string;
153153
setClassName(value: string): void;
154154

155+
hasXMinNormalized(): boolean;
156+
clearXMinNormalized(): void;
157+
getXMinNormalized(): number;
158+
setXMinNormalized(value: number): void;
159+
160+
hasYMinNormalized(): boolean;
161+
clearYMinNormalized(): void;
162+
getYMinNormalized(): number;
163+
setYMinNormalized(value: number): void;
164+
165+
hasXMaxNormalized(): boolean;
166+
clearXMaxNormalized(): void;
167+
getXMaxNormalized(): number;
168+
setXMaxNormalized(value: number): void;
169+
170+
hasYMaxNormalized(): boolean;
171+
clearYMaxNormalized(): void;
172+
getYMaxNormalized(): number;
173+
setYMaxNormalized(value: number): void;
174+
155175
serializeBinary(): Uint8Array;
156176
toObject(includeInstance?: boolean): Detection.AsObject;
157177
static toObject(includeInstance: boolean, msg: Detection): Detection.AsObject;
@@ -170,6 +190,10 @@ export namespace Detection {
170190
yMax: number,
171191
confidence: number,
172192
className: string,
193+
xMinNormalized: number,
194+
yMinNormalized: number,
195+
xMaxNormalized: number,
196+
yMaxNormalized: number,
173197
}
174198
}
175199

gen/js/service/vision/v1/vision_pb.js

Lines changed: 193 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1268,7 +1268,11 @@ proto.viam.service.vision.v1.Detection.toObject = function(includeInstance, msg)
12681268
xMax: jspb.Message.getFieldWithDefault(msg, 3, 0),
12691269
yMax: jspb.Message.getFieldWithDefault(msg, 4, 0),
12701270
confidence: jspb.Message.getFloatingPointFieldWithDefault(msg, 5, 0.0),
1271-
className: jspb.Message.getFieldWithDefault(msg, 6, "")
1271+
className: jspb.Message.getFieldWithDefault(msg, 6, ""),
1272+
xMinNormalized: jspb.Message.getFloatingPointFieldWithDefault(msg, 7, 0.0),
1273+
yMinNormalized: jspb.Message.getFloatingPointFieldWithDefault(msg, 8, 0.0),
1274+
xMaxNormalized: jspb.Message.getFloatingPointFieldWithDefault(msg, 9, 0.0),
1275+
yMaxNormalized: jspb.Message.getFloatingPointFieldWithDefault(msg, 10, 0.0)
12721276
};
12731277

12741278
if (includeInstance) {
@@ -1329,6 +1333,22 @@ proto.viam.service.vision.v1.Detection.deserializeBinaryFromReader = function(ms
13291333
var value = /** @type {string} */ (reader.readString());
13301334
msg.setClassName(value);
13311335
break;
1336+
case 7:
1337+
var value = /** @type {number} */ (reader.readDouble());
1338+
msg.setXMinNormalized(value);
1339+
break;
1340+
case 8:
1341+
var value = /** @type {number} */ (reader.readDouble());
1342+
msg.setYMinNormalized(value);
1343+
break;
1344+
case 9:
1345+
var value = /** @type {number} */ (reader.readDouble());
1346+
msg.setXMaxNormalized(value);
1347+
break;
1348+
case 10:
1349+
var value = /** @type {number} */ (reader.readDouble());
1350+
msg.setYMaxNormalized(value);
1351+
break;
13321352
default:
13331353
reader.skipField();
13341354
break;
@@ -1400,6 +1420,34 @@ proto.viam.service.vision.v1.Detection.serializeBinaryToWriter = function(messag
14001420
f
14011421
);
14021422
}
1423+
f = /** @type {number} */ (jspb.Message.getField(message, 7));
1424+
if (f != null) {
1425+
writer.writeDouble(
1426+
7,
1427+
f
1428+
);
1429+
}
1430+
f = /** @type {number} */ (jspb.Message.getField(message, 8));
1431+
if (f != null) {
1432+
writer.writeDouble(
1433+
8,
1434+
f
1435+
);
1436+
}
1437+
f = /** @type {number} */ (jspb.Message.getField(message, 9));
1438+
if (f != null) {
1439+
writer.writeDouble(
1440+
9,
1441+
f
1442+
);
1443+
}
1444+
f = /** @type {number} */ (jspb.Message.getField(message, 10));
1445+
if (f != null) {
1446+
writer.writeDouble(
1447+
10,
1448+
f
1449+
);
1450+
}
14031451
};
14041452

14051453

@@ -1583,6 +1631,150 @@ proto.viam.service.vision.v1.Detection.prototype.setClassName = function(value)
15831631
};
15841632

15851633

1634+
/**
1635+
* optional double x_min_normalized = 7;
1636+
* @return {number}
1637+
*/
1638+
proto.viam.service.vision.v1.Detection.prototype.getXMinNormalized = function() {
1639+
return /** @type {number} */ (jspb.Message.getFloatingPointFieldWithDefault(this, 7, 0.0));
1640+
};
1641+
1642+
1643+
/**
1644+
* @param {number} value
1645+
* @return {!proto.viam.service.vision.v1.Detection} returns this
1646+
*/
1647+
proto.viam.service.vision.v1.Detection.prototype.setXMinNormalized = function(value) {
1648+
return jspb.Message.setField(this, 7, value);
1649+
};
1650+
1651+
1652+
/**
1653+
* Clears the field making it undefined.
1654+
* @return {!proto.viam.service.vision.v1.Detection} returns this
1655+
*/
1656+
proto.viam.service.vision.v1.Detection.prototype.clearXMinNormalized = function() {
1657+
return jspb.Message.setField(this, 7, undefined);
1658+
};
1659+
1660+
1661+
/**
1662+
* Returns whether this field is set.
1663+
* @return {boolean}
1664+
*/
1665+
proto.viam.service.vision.v1.Detection.prototype.hasXMinNormalized = function() {
1666+
return jspb.Message.getField(this, 7) != null;
1667+
};
1668+
1669+
1670+
/**
1671+
* optional double y_min_normalized = 8;
1672+
* @return {number}
1673+
*/
1674+
proto.viam.service.vision.v1.Detection.prototype.getYMinNormalized = function() {
1675+
return /** @type {number} */ (jspb.Message.getFloatingPointFieldWithDefault(this, 8, 0.0));
1676+
};
1677+
1678+
1679+
/**
1680+
* @param {number} value
1681+
* @return {!proto.viam.service.vision.v1.Detection} returns this
1682+
*/
1683+
proto.viam.service.vision.v1.Detection.prototype.setYMinNormalized = function(value) {
1684+
return jspb.Message.setField(this, 8, value);
1685+
};
1686+
1687+
1688+
/**
1689+
* Clears the field making it undefined.
1690+
* @return {!proto.viam.service.vision.v1.Detection} returns this
1691+
*/
1692+
proto.viam.service.vision.v1.Detection.prototype.clearYMinNormalized = function() {
1693+
return jspb.Message.setField(this, 8, undefined);
1694+
};
1695+
1696+
1697+
/**
1698+
* Returns whether this field is set.
1699+
* @return {boolean}
1700+
*/
1701+
proto.viam.service.vision.v1.Detection.prototype.hasYMinNormalized = function() {
1702+
return jspb.Message.getField(this, 8) != null;
1703+
};
1704+
1705+
1706+
/**
1707+
* optional double x_max_normalized = 9;
1708+
* @return {number}
1709+
*/
1710+
proto.viam.service.vision.v1.Detection.prototype.getXMaxNormalized = function() {
1711+
return /** @type {number} */ (jspb.Message.getFloatingPointFieldWithDefault(this, 9, 0.0));
1712+
};
1713+
1714+
1715+
/**
1716+
* @param {number} value
1717+
* @return {!proto.viam.service.vision.v1.Detection} returns this
1718+
*/
1719+
proto.viam.service.vision.v1.Detection.prototype.setXMaxNormalized = function(value) {
1720+
return jspb.Message.setField(this, 9, value);
1721+
};
1722+
1723+
1724+
/**
1725+
* Clears the field making it undefined.
1726+
* @return {!proto.viam.service.vision.v1.Detection} returns this
1727+
*/
1728+
proto.viam.service.vision.v1.Detection.prototype.clearXMaxNormalized = function() {
1729+
return jspb.Message.setField(this, 9, undefined);
1730+
};
1731+
1732+
1733+
/**
1734+
* Returns whether this field is set.
1735+
* @return {boolean}
1736+
*/
1737+
proto.viam.service.vision.v1.Detection.prototype.hasXMaxNormalized = function() {
1738+
return jspb.Message.getField(this, 9) != null;
1739+
};
1740+
1741+
1742+
/**
1743+
* optional double y_max_normalized = 10;
1744+
* @return {number}
1745+
*/
1746+
proto.viam.service.vision.v1.Detection.prototype.getYMaxNormalized = function() {
1747+
return /** @type {number} */ (jspb.Message.getFloatingPointFieldWithDefault(this, 10, 0.0));
1748+
};
1749+
1750+
1751+
/**
1752+
* @param {number} value
1753+
* @return {!proto.viam.service.vision.v1.Detection} returns this
1754+
*/
1755+
proto.viam.service.vision.v1.Detection.prototype.setYMaxNormalized = function(value) {
1756+
return jspb.Message.setField(this, 10, value);
1757+
};
1758+
1759+
1760+
/**
1761+
* Clears the field making it undefined.
1762+
* @return {!proto.viam.service.vision.v1.Detection} returns this
1763+
*/
1764+
proto.viam.service.vision.v1.Detection.prototype.clearYMaxNormalized = function() {
1765+
return jspb.Message.setField(this, 10, undefined);
1766+
};
1767+
1768+
1769+
/**
1770+
* Returns whether this field is set.
1771+
* @return {boolean}
1772+
*/
1773+
proto.viam.service.vision.v1.Detection.prototype.hasYMaxNormalized = function() {
1774+
return jspb.Message.getField(this, 10) != null;
1775+
};
1776+
1777+
15861778

15871779

15881780

proto/viam/service/vision/v1/vision.proto

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,11 @@ message Detection {
9797
double confidence = 5;
9898
// label associated with the detected object
9999
string class_name = 6;
100+
// the four corners of the box, in proportion to the respective image dimension
101+
optional double x_min_normalized = 7;
102+
optional double y_min_normalized = 8;
103+
optional double x_max_normalized = 9;
104+
optional double y_max_normalized = 10;
100105
}
101106

102107
message GetClassificationsRequest {

service/vision/v1/vision.pb.go

Lines changed: 55 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)