@luxonis/visualizer-protobuf 3.1.10 → 3.1.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{FoxgloveServer-B98MHUu6.js → FoxgloveServer-Da9kV1cr.js} +1 -1
- package/dist/{communicator-Bzkx3Qfr.js → communicator-Dh2aL-rj.js} +1 -1
- package/dist/{depth-DlC6A3Te.js → depth-DiD1V2Sg.js} +15 -28
- package/dist/{deserialization.worker-9hAwTVSJ.js → deserialization.worker-CxHfbNSI.js} +544 -325
- package/dist/{foxglove-protocol-yHdoBNaD.js → foxglove-protocol-BtLMVx24.js} +1 -1
- package/dist/{index-BNRG4n8S.js → index-8bTMarZg.js} +5 -5
- package/dist/{index-CgO2loIY.js → index-9Qz76jnn.js} +7 -7
- package/dist/{index-Dqm1x8G2.js → index-B5oN0fQm.js} +1 -1
- package/dist/{index-C3x3eXLL.js → index-B8JZ9tAh.js} +5 -5
- package/dist/{index-CqpBZXmI.js → index-BFAcwVLJ.js} +5 -5
- package/dist/{index-DS9yDY3d.js → index-BtMMMbp8.js} +5 -5
- package/dist/{index-BUCw6ogj.js → index-BvC_JYBX.js} +5 -5
- package/dist/{index-BTrKy8v9.js → index-BydKxany.js} +6 -6
- package/dist/{index-DldmStLW.js → index-C-n27_wk.js} +5 -5
- package/dist/{index-DFVJaJfj.js → index-CQhsew4_.js} +5 -5
- package/dist/{index-BvMwNB0O.js → index-CVrY6MoS.js} +5 -5
- package/dist/{index-CnW73wMv.js → index-CwAmHvi3.js} +5 -5
- package/dist/{index-oTTuj_AL.js → index-DXdd6C_Q.js} +5 -5
- package/dist/{index-DOs4ht8l.js → index-D_TjqfY9.js} +5 -5
- package/dist/{index-BIUuYZt4.js → index-DnaaNoIT.js} +5 -5
- package/dist/{index-DWGbRPWz.js → index-DuP_Wg3E.js} +5 -5
- package/dist/{index-CKDJhjoP.js → index-O1aT66OM.js} +5 -5
- package/dist/{index-dQnMk-le.js → index-RxEWv1Fn.js} +5 -5
- package/dist/{index-EnK8PYK9.js → index-gafqmUmi.js} +49 -35
- package/dist/{index-CHfKyvcJ.js → index-oyn_LQK1.js} +5 -5
- package/dist/{index-DUCH3rNb.js → index-yO9F9DL5.js} +5 -5
- package/dist/index.js +5 -5
- package/dist/lib/src/connection/foxglove-connection.d.ts.map +1 -1
- package/dist/lib/src/connection/foxglove-connection.js +7 -1
- package/dist/lib/src/connection/foxglove-connection.js.map +1 -1
- package/dist/lib/src/messaging/deserialization/pointcloud/pointcloudFromDepth.worker.js +2 -2
- package/dist/lib/src/messaging/deserialization/pointcloud/pointcloudFromDepth.worker.js.map +1 -1
- package/dist/lib/src/messaging/deserialization/pointcloud/poitcloudPoolManager.js.map +1 -1
- package/dist/lib/src/messaging/deserialization/pointcloud/utils.d.ts.map +1 -1
- package/dist/lib/src/messaging/deserialization/pointcloud/utils.js.map +1 -1
- package/dist/lib/src/messaging/deserialization/video/depth.d.ts.map +1 -1
- package/dist/lib/src/messaging/deserialization/video/depth.js +11 -1
- package/dist/lib/src/messaging/deserialization/video/depth.js.map +1 -1
- package/dist/lib/src/messaging/deserialization/video/h264.d.ts +9 -6
- package/dist/lib/src/messaging/deserialization/video/h264.d.ts.map +1 -1
- package/dist/lib/src/messaging/deserialization/video/h264.js +104 -163
- package/dist/lib/src/messaging/deserialization/video/h264.js.map +1 -1
- package/dist/lib/src/messaging/deserialization/video/h265.d.ts +0 -7
- package/dist/lib/src/messaging/deserialization/video/h265.d.ts.map +1 -1
- package/dist/lib/src/messaging/deserialization/video/h265.js +46 -123
- package/dist/lib/src/messaging/deserialization/video/h265.js.map +1 -1
- package/dist/lib/src/messaging/deserialization/video/mjpeg.d.ts.map +1 -1
- package/dist/lib/src/messaging/deserialization/video/mjpeg.js +7 -8
- package/dist/lib/src/messaging/deserialization/video/mjpeg.js.map +1 -1
- package/dist/lib/src/messaging/deserialization/video/rgbd-to-pointcloud.d.ts +17 -0
- package/dist/lib/src/messaging/deserialization/video/rgbd-to-pointcloud.d.ts.map +1 -0
- package/dist/lib/src/messaging/deserialization/video/rgbd-to-pointcloud.js +320 -0
- package/dist/lib/src/messaging/deserialization/video/rgbd-to-pointcloud.js.map +1 -0
- package/dist/lib/src/messaging/deserialization.worker.d.ts +4 -0
- package/dist/lib/src/messaging/deserialization.worker.d.ts.map +1 -1
- package/dist/lib/src/messaging/deserialization.worker.js +16 -3
- package/dist/lib/src/messaging/deserialization.worker.js.map +1 -1
- package/dist/lib/src/messaging/protobuf.d.ts +12 -1
- package/dist/lib/src/messaging/protobuf.d.ts.map +1 -1
- package/dist/lib/src/messaging/protobuf.js +8 -0
- package/dist/lib/src/messaging/protobuf.js.map +1 -1
- package/dist/lib/src/messaging/utils.d.ts.map +1 -1
- package/dist/lib/src/messaging/utils.js +2 -0
- package/dist/lib/src/messaging/utils.js.map +1 -1
- package/dist/lib/src/output.css +2 -21
- package/dist/lib/src/panels/PointCloudPanel.d.ts.map +1 -1
- package/dist/lib/src/panels/PointCloudPanel.js +5 -1
- package/dist/lib/src/panels/PointCloudPanel.js.map +1 -1
- package/dist/lib/src/utils/metrics-manager.d.ts +1 -0
- package/dist/lib/src/utils/metrics-manager.d.ts.map +1 -1
- package/dist/lib/src/utils/metrics-manager.js +4 -2
- package/dist/lib/src/utils/metrics-manager.js.map +1 -1
- package/dist/lib/src/utils/poitcloud-sync.d.ts +4 -3
- package/dist/lib/src/utils/poitcloud-sync.d.ts.map +1 -1
- package/dist/lib/src/utils/poitcloud-sync.js +3 -1
- package/dist/lib/src/utils/poitcloud-sync.js.map +1 -1
- package/dist/{pointcloudFromDepth.worker-JLptpLHr.js → pointcloudFromDepth.worker-60RA4Ief.js} +2 -2
- package/dist/{protobuf-Be0G3NFz.js → protobuf-OcbVtxg1.js} +406 -218
- package/dist/{worker-NFznpx6V.js → worker-Be-hru8f.js} +3 -3
- package/dist/{worker-0Q6os6Ck.js → worker-C2MHIq3t.js} +4 -4
- package/package.json +2 -2
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import { b as _objectSpread2, P as PointsAnnotationType,
|
|
3
|
-
import { e as expose } from './comlink-jf8bdrAf.js';
|
|
4
|
-
import { t as typescript } from './index-
|
|
5
|
-
import { U as parseMessage, e as estimateObjectSize, V as fromMillis, W as DecoderRuntimeError, d as dist, X as
|
|
2
|
+
import { b as _objectSpread2, P as PointsAnnotationType, T as Type, h as Profile, p as protobufsBySchema } from './protobuf-OcbVtxg1.js';
|
|
3
|
+
import { w as wrap, e as expose } from './comlink-jf8bdrAf.js';
|
|
4
|
+
import { t as typescript } from './index-B5oN0fQm.js';
|
|
5
|
+
import { U as parseMessage, e as estimateObjectSize, V as fromMillis, W as DecoderRuntimeError, d as dist, X as deserializeDepthFrame, Y as UnsupportedTopicError, Z as NotInSecureContextError, _ as EncodedStreamNotSupportedError } from './depth-DiD1V2Sg.js';
|
|
6
6
|
import { L as Logger } from './logger-Bqy1nuLj.js';
|
|
7
7
|
import { i as isCapableOfEncodedStream } from './encoding-jXImCIb4.js';
|
|
8
|
+
import { u as uint8ArrayToUint16Array } from './utils-DmlHZWuo.js';
|
|
8
9
|
import 'react';
|
|
9
10
|
import 'zustand';
|
|
10
11
|
import 'react-mosaic-component';
|
|
@@ -797,17 +798,12 @@ function ensureWebCodecsSupported(target) {
|
|
|
797
798
|
// file, You can obtain one at http://mozilla.org/MPL/2.0/
|
|
798
799
|
|
|
799
800
|
const logger$2 = Logger.getLogger();
|
|
800
|
-
function configureDecoder
|
|
801
|
+
function configureDecoder(decoder) {
|
|
801
802
|
decoder.configure({
|
|
802
803
|
codec: "avc1.42001E",
|
|
803
804
|
optimizeForLatency: true
|
|
804
805
|
});
|
|
805
806
|
}
|
|
806
|
-
function ensureDecoderConfigured$1(decoder) {
|
|
807
|
-
if (decoder.state === "unconfigured") {
|
|
808
|
-
configureDecoder$1(decoder);
|
|
809
|
-
}
|
|
810
|
-
}
|
|
811
807
|
function closeDecoder$1(decoder) {
|
|
812
808
|
if (!decoder) {
|
|
813
809
|
return;
|
|
@@ -823,110 +819,14 @@ function closeDecoder$1(decoder) {
|
|
|
823
819
|
}
|
|
824
820
|
function closeTopicDecoder$1(topic, topicDecoders) {
|
|
825
821
|
const decoderInfo = topicDecoders.get(topic);
|
|
826
|
-
topicDecoders.delete(topic);
|
|
827
822
|
closeDecoder$1(decoderInfo === null || decoderInfo === void 0 ? void 0 : decoderInfo.decoder);
|
|
828
823
|
decoderInfo === null || decoderInfo === void 0 || decoderInfo.timing.clear();
|
|
829
824
|
decoderInfo === null || decoderInfo === void 0 || decoderInfo.transformations.clear();
|
|
830
|
-
if (decoderInfo) {
|
|
831
|
-
decoderInfo.pendingFrame = undefined;
|
|
832
|
-
}
|
|
833
825
|
}
|
|
834
826
|
function isIgnorableInitialDecodeError(error) {
|
|
835
827
|
const message = error instanceof Error ? error.message : String(error);
|
|
836
828
|
return message.includes("A key frame is required after configure() or flush()");
|
|
837
829
|
}
|
|
838
|
-
function isUnconfiguredCodecError$1(error) {
|
|
839
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
840
|
-
return message.includes("cannot call 'decode' on an unconfigured codec");
|
|
841
|
-
}
|
|
842
|
-
function resetTopicDecoder$1({
|
|
843
|
-
topic,
|
|
844
|
-
topicDecoders,
|
|
845
|
-
callback,
|
|
846
|
-
onError
|
|
847
|
-
}) {
|
|
848
|
-
const existingDecoderInfo = topicDecoders.get(topic);
|
|
849
|
-
closeDecoder$1(existingDecoderInfo === null || existingDecoderInfo === void 0 ? void 0 : existingDecoderInfo.decoder);
|
|
850
|
-
const decoder = createVideoDecoder$1({
|
|
851
|
-
topic,
|
|
852
|
-
callback,
|
|
853
|
-
topicDecoders,
|
|
854
|
-
onError
|
|
855
|
-
});
|
|
856
|
-
try {
|
|
857
|
-
configureDecoder$1(decoder);
|
|
858
|
-
} catch (error) {
|
|
859
|
-
closeDecoder$1(decoder);
|
|
860
|
-
closeTopicDecoder$1(topic, topicDecoders);
|
|
861
|
-
onError(new DecoderRuntimeError(topic, error instanceof Error ? error.message : "Failed to configure H.264 decoder."));
|
|
862
|
-
return undefined;
|
|
863
|
-
}
|
|
864
|
-
if (existingDecoderInfo) {
|
|
865
|
-
existingDecoderInfo.decoder = decoder;
|
|
866
|
-
existingDecoderInfo.timing.clear();
|
|
867
|
-
existingDecoderInfo.transformations.clear();
|
|
868
|
-
existingDecoderInfo.pendingFrame = undefined;
|
|
869
|
-
} else {
|
|
870
|
-
topicDecoders.set(topic, {
|
|
871
|
-
decoder,
|
|
872
|
-
timing: new Map(),
|
|
873
|
-
transformations: new Map(),
|
|
874
|
-
pendingFrame: undefined
|
|
875
|
-
});
|
|
876
|
-
}
|
|
877
|
-
return decoder;
|
|
878
|
-
}
|
|
879
|
-
function decodePendingFrame$1(topic, topicDecoders, callback, onError) {
|
|
880
|
-
const decoderInfo = topicDecoders.get(topic);
|
|
881
|
-
if (!decoderInfo) {
|
|
882
|
-
return;
|
|
883
|
-
}
|
|
884
|
-
const decoder = decoderInfo.decoder;
|
|
885
|
-
if (decoder.state === "closed" || decoder.decodeQueueSize > 0) {
|
|
886
|
-
return;
|
|
887
|
-
}
|
|
888
|
-
const pendingFrame = decoderInfo.pendingFrame;
|
|
889
|
-
if (!pendingFrame) {
|
|
890
|
-
return;
|
|
891
|
-
}
|
|
892
|
-
decoderInfo.pendingFrame = undefined;
|
|
893
|
-
decoderInfo.timing.set(pendingFrame.timestamp, pendingFrame.receiveTime);
|
|
894
|
-
decoderInfo.transformations.set(pendingFrame.timestamp, pendingFrame.transformation);
|
|
895
|
-
try {
|
|
896
|
-
var _topicDecoders$get;
|
|
897
|
-
ensureDecoderConfigured$1(decoder);
|
|
898
|
-
if (decoder.state !== "configured" || ((_topicDecoders$get = topicDecoders.get(topic)) === null || _topicDecoders$get === void 0 ? void 0 : _topicDecoders$get.decoder) !== decoder) {
|
|
899
|
-
closeTopicDecoder$1(topic, topicDecoders);
|
|
900
|
-
return;
|
|
901
|
-
}
|
|
902
|
-
const chunk = new EncodedVideoChunk({
|
|
903
|
-
type: "key",
|
|
904
|
-
data: pendingFrame.data,
|
|
905
|
-
timestamp: pendingFrame.timestamp
|
|
906
|
-
});
|
|
907
|
-
decoder.decode(chunk);
|
|
908
|
-
} catch (error) {
|
|
909
|
-
if (isUnconfiguredCodecError$1(error)) {
|
|
910
|
-
decoderInfo.pendingFrame = pendingFrame;
|
|
911
|
-
const replacementDecoder = resetTopicDecoder$1({
|
|
912
|
-
topic,
|
|
913
|
-
topicDecoders,
|
|
914
|
-
callback,
|
|
915
|
-
onError
|
|
916
|
-
});
|
|
917
|
-
if ((replacementDecoder === null || replacementDecoder === void 0 ? void 0 : replacementDecoder.state) === "configured") {
|
|
918
|
-
decodePendingFrame$1(topic, topicDecoders, callback, onError);
|
|
919
|
-
}
|
|
920
|
-
return;
|
|
921
|
-
}
|
|
922
|
-
if (isIgnorableInitialDecodeError(error)) {
|
|
923
|
-
closeTopicDecoder$1(topic, topicDecoders);
|
|
924
|
-
return;
|
|
925
|
-
}
|
|
926
|
-
closeTopicDecoder$1(topic, topicDecoders);
|
|
927
|
-
onError(new DecoderRuntimeError(topic, error instanceof Error ? error.message : "Failed to decode H.264 frame."));
|
|
928
|
-
}
|
|
929
|
-
}
|
|
930
830
|
function packedToI420(packed, width, height, stride, format, cropLeft = 0, cropTop = 0) {
|
|
931
831
|
if ((width & 1) !== 0 || (height & 1) !== 0) {
|
|
932
832
|
throw new Error("I420 requires even width and height.");
|
|
@@ -1032,6 +932,55 @@ function repackI420(source, width, height, yLayout, uLayout, vLayout, cropLeft =
|
|
|
1032
932
|
}
|
|
1033
933
|
return out;
|
|
1034
934
|
}
|
|
935
|
+
async function copyVideoFrameToI420(frame, logPrefix) {
|
|
936
|
+
var _visibleRect$width, _visibleRect$height, _visibleRect$x, _visibleRect$y;
|
|
937
|
+
const visibleRect = frame.visibleRect;
|
|
938
|
+
const frameWidth = (_visibleRect$width = visibleRect === null || visibleRect === void 0 ? void 0 : visibleRect.width) !== null && _visibleRect$width !== void 0 ? _visibleRect$width : frame.codedWidth;
|
|
939
|
+
const frameHeight = (_visibleRect$height = visibleRect === null || visibleRect === void 0 ? void 0 : visibleRect.height) !== null && _visibleRect$height !== void 0 ? _visibleRect$height : frame.codedHeight;
|
|
940
|
+
const cropLeft = (_visibleRect$x = visibleRect === null || visibleRect === void 0 ? void 0 : visibleRect.x) !== null && _visibleRect$x !== void 0 ? _visibleRect$x : 0;
|
|
941
|
+
const cropTop = (_visibleRect$y = visibleRect === null || visibleRect === void 0 ? void 0 : visibleRect.y) !== null && _visibleRect$y !== void 0 ? _visibleRect$y : 0;
|
|
942
|
+
let finalBuffer = new Uint8Array(frame.allocationSize());
|
|
943
|
+
logger$2.warn(`${logPrefix} decoder output format: ${frame.format}, coded=${frame.codedWidth}x${frame.codedHeight}, display=${frame.displayWidth}x${frame.displayHeight}, visible=${frameWidth}x${frameHeight}@${cropLeft},${cropTop}`);
|
|
944
|
+
switch (frame.format) {
|
|
945
|
+
case "I420":
|
|
946
|
+
{
|
|
947
|
+
const i420Buffer = new Uint8Array(frame.allocationSize());
|
|
948
|
+
const layouts = await frame.copyTo(i420Buffer);
|
|
949
|
+
const [yLayout, uLayout, vLayout] = layouts;
|
|
950
|
+
finalBuffer = yLayout != undefined && uLayout != undefined && vLayout != undefined ? repackI420(i420Buffer, frameWidth, frameHeight, yLayout, uLayout, vLayout, cropLeft, cropTop) : i420Buffer;
|
|
951
|
+
break;
|
|
952
|
+
}
|
|
953
|
+
case "NV12":
|
|
954
|
+
{
|
|
955
|
+
var _yLayout$stride, _uvLayout$stride, _yLayout$offset, _uvLayout$offset, _yLayout$stride2;
|
|
956
|
+
const nv12Buffer = new Uint8Array(frame.allocationSize());
|
|
957
|
+
const layouts = await frame.copyTo(nv12Buffer);
|
|
958
|
+
const [yLayout, uvLayout] = layouts;
|
|
959
|
+
finalBuffer = convertNv12ToI420(nv12Buffer, frameWidth, frameHeight, (_yLayout$stride = yLayout === null || yLayout === void 0 ? void 0 : yLayout.stride) !== null && _yLayout$stride !== void 0 ? _yLayout$stride : frame.codedWidth, (_uvLayout$stride = uvLayout === null || uvLayout === void 0 ? void 0 : uvLayout.stride) !== null && _uvLayout$stride !== void 0 ? _uvLayout$stride : frame.codedWidth, (_yLayout$offset = yLayout === null || yLayout === void 0 ? void 0 : yLayout.offset) !== null && _yLayout$offset !== void 0 ? _yLayout$offset : 0, (_uvLayout$offset = uvLayout === null || uvLayout === void 0 ? void 0 : uvLayout.offset) !== null && _uvLayout$offset !== void 0 ? _uvLayout$offset : ((_yLayout$stride2 = yLayout === null || yLayout === void 0 ? void 0 : yLayout.stride) !== null && _yLayout$stride2 !== void 0 ? _yLayout$stride2 : frame.codedWidth) * frame.codedHeight, cropLeft, cropTop);
|
|
960
|
+
break;
|
|
961
|
+
}
|
|
962
|
+
case "RGBX":
|
|
963
|
+
case "RGBA":
|
|
964
|
+
case "BGRX":
|
|
965
|
+
case "BGRA":
|
|
966
|
+
{
|
|
967
|
+
var _layout$stride;
|
|
968
|
+
const packedBuffer = new Uint8Array(frame.allocationSize());
|
|
969
|
+
const [layout] = await frame.copyTo(packedBuffer);
|
|
970
|
+
logger$2.warn(`${logPrefix} decoder received ${frame.format} frame.`);
|
|
971
|
+
finalBuffer = packedToI420(packedBuffer, frameWidth, frameHeight, (_layout$stride = layout === null || layout === void 0 ? void 0 : layout.stride) !== null && _layout$stride !== void 0 ? _layout$stride : frame.codedWidth * 4, frame.format, cropLeft, cropTop);
|
|
972
|
+
break;
|
|
973
|
+
}
|
|
974
|
+
default:
|
|
975
|
+
logger$2.warn(`${logPrefix} decoder received unexpected frame format:`, frame.format);
|
|
976
|
+
break;
|
|
977
|
+
}
|
|
978
|
+
return {
|
|
979
|
+
data: finalBuffer,
|
|
980
|
+
width: frameWidth,
|
|
981
|
+
height: frameHeight
|
|
982
|
+
};
|
|
983
|
+
}
|
|
1035
984
|
function createVideoDecoder$1({
|
|
1036
985
|
topic,
|
|
1037
986
|
callback,
|
|
@@ -1039,60 +988,18 @@ function createVideoDecoder$1({
|
|
|
1039
988
|
onError
|
|
1040
989
|
}) {
|
|
1041
990
|
let hasProducedFrame = false;
|
|
1042
|
-
|
|
1043
|
-
decoder = new VideoDecoder({
|
|
991
|
+
return new VideoDecoder({
|
|
1044
992
|
output: async frame => {
|
|
1045
|
-
var _topicDecoders$
|
|
1046
|
-
if (((_topicDecoders$get2 = topicDecoders.get(topic)) === null || _topicDecoders$get2 === void 0 ? void 0 : _topicDecoders$get2.decoder) !== decoder) {
|
|
1047
|
-
frame.close();
|
|
1048
|
-
return;
|
|
1049
|
-
}
|
|
993
|
+
var _topicDecoders$get$ti, _topicDecoders$get, _topicDecoders$get2, _topicDecoders$get3;
|
|
1050
994
|
hasProducedFrame = true;
|
|
1051
|
-
const
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
case "I420":
|
|
1060
|
-
{
|
|
1061
|
-
const i420Buffer = new Uint8Array(frame.allocationSize());
|
|
1062
|
-
const layouts = await frame.copyTo(i420Buffer);
|
|
1063
|
-
const [yLayout, uLayout, vLayout] = layouts;
|
|
1064
|
-
finalBuffer = yLayout != undefined && uLayout != undefined && vLayout != undefined ? repackI420(i420Buffer, frameWidth, frameHeight, yLayout, uLayout, vLayout, cropLeft, cropTop) : i420Buffer;
|
|
1065
|
-
break;
|
|
1066
|
-
}
|
|
1067
|
-
case "NV12":
|
|
1068
|
-
{
|
|
1069
|
-
var _yLayout$stride, _uvLayout$stride, _yLayout$offset, _uvLayout$offset, _yLayout$stride2;
|
|
1070
|
-
const nv12Buffer = new Uint8Array(frame.allocationSize());
|
|
1071
|
-
const layouts = await frame.copyTo(nv12Buffer);
|
|
1072
|
-
const [yLayout, uvLayout] = layouts;
|
|
1073
|
-
finalBuffer = convertNv12ToI420(nv12Buffer, frameWidth, frameHeight, (_yLayout$stride = yLayout === null || yLayout === void 0 ? void 0 : yLayout.stride) !== null && _yLayout$stride !== void 0 ? _yLayout$stride : frame.codedWidth, (_uvLayout$stride = uvLayout === null || uvLayout === void 0 ? void 0 : uvLayout.stride) !== null && _uvLayout$stride !== void 0 ? _uvLayout$stride : frame.codedWidth, (_yLayout$offset = yLayout === null || yLayout === void 0 ? void 0 : yLayout.offset) !== null && _yLayout$offset !== void 0 ? _yLayout$offset : 0, (_uvLayout$offset = uvLayout === null || uvLayout === void 0 ? void 0 : uvLayout.offset) !== null && _uvLayout$offset !== void 0 ? _uvLayout$offset : ((_yLayout$stride2 = yLayout === null || yLayout === void 0 ? void 0 : yLayout.stride) !== null && _yLayout$stride2 !== void 0 ? _yLayout$stride2 : frame.codedWidth) * frame.codedHeight, cropLeft, cropTop);
|
|
1074
|
-
break;
|
|
1075
|
-
}
|
|
1076
|
-
case "RGBX":
|
|
1077
|
-
case "RGBA":
|
|
1078
|
-
case "BGRX":
|
|
1079
|
-
case "BGRA":
|
|
1080
|
-
{
|
|
1081
|
-
var _layout$stride;
|
|
1082
|
-
const packedBuffer = new Uint8Array(frame.allocationSize());
|
|
1083
|
-
const [layout] = await frame.copyTo(packedBuffer);
|
|
1084
|
-
logger$2.warn(`H264 decoder received ${frame.format} frame.`);
|
|
1085
|
-
finalBuffer = packedToI420(packedBuffer, frameWidth, frameHeight, (_layout$stride = layout === null || layout === void 0 ? void 0 : layout.stride) !== null && _layout$stride !== void 0 ? _layout$stride : frame.codedWidth * 4, frame.format, cropLeft, cropTop);
|
|
1086
|
-
break;
|
|
1087
|
-
}
|
|
1088
|
-
}
|
|
1089
|
-
if (frame.format !== "I420" && frame.format !== "NV12" && frame.format !== "RGBX" && frame.format !== "RGBA" && frame.format !== "BGRX" && frame.format !== "BGRA") {
|
|
1090
|
-
logger$2.warn("H264 decoder received unexpected frame format:", frame.format);
|
|
1091
|
-
}
|
|
1092
|
-
const receiveTime = (_topicDecoders$get$ti = (_topicDecoders$get3 = topicDecoders.get(topic)) === null || _topicDecoders$get3 === void 0 ? void 0 : _topicDecoders$get3.timing.get(frame.timestamp)) !== null && _topicDecoders$get$ti !== void 0 ? _topicDecoders$get$ti : dist.fromMicros(frame.timestamp);
|
|
1093
|
-
(_topicDecoders$get4 = topicDecoders.get(topic)) === null || _topicDecoders$get4 === void 0 || _topicDecoders$get4.timing.delete(frame.timestamp);
|
|
1094
|
-
const transformation = (_topicDecoders$get5 = topicDecoders.get(topic)) === null || _topicDecoders$get5 === void 0 ? void 0 : _topicDecoders$get5.transformations.get(frame.timestamp);
|
|
1095
|
-
(_topicDecoders$get6 = topicDecoders.get(topic)) === null || _topicDecoders$get6 === void 0 || _topicDecoders$get6.transformations.delete(frame.timestamp);
|
|
995
|
+
const {
|
|
996
|
+
data: finalBuffer,
|
|
997
|
+
width: frameWidth,
|
|
998
|
+
height: frameHeight
|
|
999
|
+
} = await copyVideoFrameToI420(frame, "H264");
|
|
1000
|
+
const receiveTime = (_topicDecoders$get$ti = (_topicDecoders$get = topicDecoders.get(topic)) === null || _topicDecoders$get === void 0 ? void 0 : _topicDecoders$get.timing.get(frame.timestamp)) !== null && _topicDecoders$get$ti !== void 0 ? _topicDecoders$get$ti : dist.fromMicros(frame.timestamp);
|
|
1001
|
+
const transformation = (_topicDecoders$get2 = topicDecoders.get(topic)) === null || _topicDecoders$get2 === void 0 ? void 0 : _topicDecoders$get2.transformations.get(frame.timestamp);
|
|
1002
|
+
(_topicDecoders$get3 = topicDecoders.get(topic)) === null || _topicDecoders$get3 === void 0 || _topicDecoders$get3.transformations.delete(frame.timestamp);
|
|
1096
1003
|
const foxgloveMessage = {
|
|
1097
1004
|
timestamp: receiveTime,
|
|
1098
1005
|
frame_id: `h264-${topic}-frame`,
|
|
@@ -1111,15 +1018,8 @@ function createVideoDecoder$1({
|
|
|
1111
1018
|
depthaiTransformation: transformation
|
|
1112
1019
|
});
|
|
1113
1020
|
frame.close();
|
|
1114
|
-
if (((_topicDecoders$get7 = topicDecoders.get(topic)) === null || _topicDecoders$get7 === void 0 ? void 0 : _topicDecoders$get7.decoder) === decoder) {
|
|
1115
|
-
decodePendingFrame$1(topic, topicDecoders, callback, onError);
|
|
1116
|
-
}
|
|
1117
1021
|
},
|
|
1118
1022
|
error: error => {
|
|
1119
|
-
var _topicDecoders$get8;
|
|
1120
|
-
if (((_topicDecoders$get8 = topicDecoders.get(topic)) === null || _topicDecoders$get8 === void 0 ? void 0 : _topicDecoders$get8.decoder) !== decoder) {
|
|
1121
|
-
return;
|
|
1122
|
-
}
|
|
1123
1023
|
if (!hasProducedFrame && isIgnorableInitialDecodeError(error)) {
|
|
1124
1024
|
logger$2.warn(`Ignoring initial H264 decoder error for topic ${topic}: ${error.message}`);
|
|
1125
1025
|
closeTopicDecoder$1(topic, topicDecoders);
|
|
@@ -1130,7 +1030,6 @@ function createVideoDecoder$1({
|
|
|
1130
1030
|
onError(new DecoderRuntimeError(topic, error.message));
|
|
1131
1031
|
}
|
|
1132
1032
|
});
|
|
1133
|
-
return decoder;
|
|
1134
1033
|
}
|
|
1135
1034
|
async function deserializeEncodedFrameH264({
|
|
1136
1035
|
topic,
|
|
@@ -1147,14 +1046,39 @@ async function deserializeEncodedFrameH264({
|
|
|
1147
1046
|
return;
|
|
1148
1047
|
}
|
|
1149
1048
|
const existingDecoderInfo = topicDecoders.get(topic);
|
|
1150
|
-
if (!existingDecoderInfo || existingDecoderInfo.decoder.state
|
|
1151
|
-
const decoder =
|
|
1049
|
+
if (!existingDecoderInfo || existingDecoderInfo.decoder.state === "closed") {
|
|
1050
|
+
const decoder = createVideoDecoder$1({
|
|
1152
1051
|
topic,
|
|
1153
1052
|
callback,
|
|
1154
1053
|
topicDecoders,
|
|
1155
1054
|
onError
|
|
1156
1055
|
});
|
|
1157
|
-
|
|
1056
|
+
try {
|
|
1057
|
+
configureDecoder(decoder);
|
|
1058
|
+
} catch (error) {
|
|
1059
|
+
closeDecoder$1(decoder);
|
|
1060
|
+
onError(new DecoderRuntimeError(topic, error instanceof Error ? error.message : "Failed to configure H.264 decoder."));
|
|
1061
|
+
return;
|
|
1062
|
+
}
|
|
1063
|
+
if (existingDecoderInfo) {
|
|
1064
|
+
existingDecoderInfo.decoder = decoder;
|
|
1065
|
+
existingDecoderInfo.timing.clear();
|
|
1066
|
+
existingDecoderInfo.transformations.clear();
|
|
1067
|
+
} else {
|
|
1068
|
+
topicDecoders.set(topic, {
|
|
1069
|
+
decoder,
|
|
1070
|
+
timing: new Map(),
|
|
1071
|
+
transformations: new Map()
|
|
1072
|
+
});
|
|
1073
|
+
}
|
|
1074
|
+
} else if (existingDecoderInfo.decoder.state === "unconfigured") {
|
|
1075
|
+
try {
|
|
1076
|
+
configureDecoder(existingDecoderInfo.decoder);
|
|
1077
|
+
existingDecoderInfo.timing.clear();
|
|
1078
|
+
existingDecoderInfo.transformations.clear();
|
|
1079
|
+
} catch (error) {
|
|
1080
|
+
closeTopicDecoder$1(topic, topicDecoders);
|
|
1081
|
+
onError(new DecoderRuntimeError(topic, error instanceof Error ? error.message : "Failed to reconfigure H.264 decoder."));
|
|
1158
1082
|
return;
|
|
1159
1083
|
}
|
|
1160
1084
|
}
|
|
@@ -1162,19 +1086,31 @@ async function deserializeEncodedFrameH264({
|
|
|
1162
1086
|
if (!decoderInfo) {
|
|
1163
1087
|
return;
|
|
1164
1088
|
}
|
|
1089
|
+
if (decoderInfo.decoder.decodeQueueSize > 60) {
|
|
1090
|
+
decoderInfo.decoder.reset();
|
|
1091
|
+
decoderInfo.timing.clear();
|
|
1092
|
+
decoderInfo.transformations.clear();
|
|
1093
|
+
return;
|
|
1094
|
+
}
|
|
1165
1095
|
const microTimestamp = receiveTime.sec * 1000000 + Math.floor(receiveTime.nsec / 1000);
|
|
1096
|
+
decoderInfo.timing.set(microTimestamp, receiveTime);
|
|
1097
|
+
decoderInfo.transformations.set(microTimestamp, message.transformation);
|
|
1166
1098
|
const frame = {
|
|
1099
|
+
type: 'key',
|
|
1167
1100
|
data: message.data,
|
|
1168
|
-
timestamp: microTimestamp
|
|
1169
|
-
receiveTime,
|
|
1170
|
-
transformation: message.transformation
|
|
1101
|
+
timestamp: microTimestamp
|
|
1171
1102
|
};
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1103
|
+
try {
|
|
1104
|
+
const chunk = new EncodedVideoChunk(frame);
|
|
1105
|
+
decoderInfo.decoder.decode(chunk);
|
|
1106
|
+
} catch (error) {
|
|
1107
|
+
if (isIgnorableInitialDecodeError(error)) {
|
|
1108
|
+
closeTopicDecoder$1(topic, topicDecoders);
|
|
1109
|
+
return;
|
|
1110
|
+
}
|
|
1111
|
+
closeTopicDecoder$1(topic, topicDecoders);
|
|
1112
|
+
onError(new DecoderRuntimeError(topic, error instanceof Error ? error.message : "Failed to decode H.264 frame."));
|
|
1175
1113
|
}
|
|
1176
|
-
decoderInfo.pendingFrame = frame;
|
|
1177
|
-
decodePendingFrame$1(topic, topicDecoders, callback, onError);
|
|
1178
1114
|
}
|
|
1179
1115
|
|
|
1180
1116
|
// This Source Code Form is subject to the terms of the Mozilla Public
|
|
@@ -1182,17 +1118,6 @@ async function deserializeEncodedFrameH264({
|
|
|
1182
1118
|
// file, You can obtain one at http://mozilla.org/MPL/2.0/
|
|
1183
1119
|
|
|
1184
1120
|
const logger$1 = Logger.getLogger();
|
|
1185
|
-
function configureDecoder(decoder) {
|
|
1186
|
-
decoder.configure({
|
|
1187
|
-
codec: "hev1.1.6.L93.B0",
|
|
1188
|
-
optimizeForLatency: true
|
|
1189
|
-
});
|
|
1190
|
-
}
|
|
1191
|
-
function ensureDecoderConfigured(decoder) {
|
|
1192
|
-
if (decoder.state === "unconfigured") {
|
|
1193
|
-
configureDecoder(decoder);
|
|
1194
|
-
}
|
|
1195
|
-
}
|
|
1196
1121
|
function closeDecoder(decoder) {
|
|
1197
1122
|
if (!decoder) {
|
|
1198
1123
|
return;
|
|
@@ -1208,101 +1133,9 @@ function closeDecoder(decoder) {
|
|
|
1208
1133
|
}
|
|
1209
1134
|
function closeTopicDecoder(topic, topicDecoders) {
|
|
1210
1135
|
const decoderInfo = topicDecoders.get(topic);
|
|
1211
|
-
topicDecoders.delete(topic);
|
|
1212
1136
|
closeDecoder(decoderInfo === null || decoderInfo === void 0 ? void 0 : decoderInfo.decoder);
|
|
1213
1137
|
decoderInfo === null || decoderInfo === void 0 || decoderInfo.timing.clear();
|
|
1214
1138
|
decoderInfo === null || decoderInfo === void 0 || decoderInfo.transformations.clear();
|
|
1215
|
-
if (decoderInfo) {
|
|
1216
|
-
decoderInfo.pendingFrame = undefined;
|
|
1217
|
-
}
|
|
1218
|
-
}
|
|
1219
|
-
function isUnconfiguredCodecError(error) {
|
|
1220
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
1221
|
-
return message.includes("cannot call 'decode' on an unconfigured codec");
|
|
1222
|
-
}
|
|
1223
|
-
function resetTopicDecoder({
|
|
1224
|
-
topic,
|
|
1225
|
-
topicDecoders,
|
|
1226
|
-
callback,
|
|
1227
|
-
onError
|
|
1228
|
-
}) {
|
|
1229
|
-
const existingDecoderInfo = topicDecoders.get(topic);
|
|
1230
|
-
closeDecoder(existingDecoderInfo === null || existingDecoderInfo === void 0 ? void 0 : existingDecoderInfo.decoder);
|
|
1231
|
-
const decoder = createVideoDecoder({
|
|
1232
|
-
topic,
|
|
1233
|
-
callback,
|
|
1234
|
-
topicDecoders,
|
|
1235
|
-
onError
|
|
1236
|
-
});
|
|
1237
|
-
try {
|
|
1238
|
-
configureDecoder(decoder);
|
|
1239
|
-
} catch (error) {
|
|
1240
|
-
closeDecoder(decoder);
|
|
1241
|
-
closeTopicDecoder(topic, topicDecoders);
|
|
1242
|
-
onError(new DecoderRuntimeError(topic, error instanceof Error ? error.message : "Failed to configure H.265 decoder."));
|
|
1243
|
-
return undefined;
|
|
1244
|
-
}
|
|
1245
|
-
if (existingDecoderInfo) {
|
|
1246
|
-
existingDecoderInfo.decoder = decoder;
|
|
1247
|
-
existingDecoderInfo.timing.clear();
|
|
1248
|
-
existingDecoderInfo.transformations.clear();
|
|
1249
|
-
existingDecoderInfo.pendingFrame = undefined;
|
|
1250
|
-
} else {
|
|
1251
|
-
topicDecoders.set(topic, {
|
|
1252
|
-
decoder,
|
|
1253
|
-
timing: new Map(),
|
|
1254
|
-
transformations: new Map(),
|
|
1255
|
-
pendingFrame: undefined
|
|
1256
|
-
});
|
|
1257
|
-
}
|
|
1258
|
-
return decoder;
|
|
1259
|
-
}
|
|
1260
|
-
function decodePendingFrame(topic, topicDecoders, callback, onError) {
|
|
1261
|
-
const decoderInfo = topicDecoders.get(topic);
|
|
1262
|
-
if (!decoderInfo) {
|
|
1263
|
-
return;
|
|
1264
|
-
}
|
|
1265
|
-
const decoder = decoderInfo.decoder;
|
|
1266
|
-
if (decoder.state === "closed" || decoder.decodeQueueSize > 0) {
|
|
1267
|
-
return;
|
|
1268
|
-
}
|
|
1269
|
-
const pendingFrame = decoderInfo.pendingFrame;
|
|
1270
|
-
if (!pendingFrame) {
|
|
1271
|
-
return;
|
|
1272
|
-
}
|
|
1273
|
-
decoderInfo.pendingFrame = undefined;
|
|
1274
|
-
decoderInfo.timing.set(pendingFrame.timestamp, pendingFrame.receiveTime);
|
|
1275
|
-
decoderInfo.transformations.set(pendingFrame.timestamp, pendingFrame.transformation);
|
|
1276
|
-
try {
|
|
1277
|
-
var _topicDecoders$get;
|
|
1278
|
-
ensureDecoderConfigured(decoder);
|
|
1279
|
-
if (decoder.state !== "configured" || ((_topicDecoders$get = topicDecoders.get(topic)) === null || _topicDecoders$get === void 0 ? void 0 : _topicDecoders$get.decoder) !== decoder) {
|
|
1280
|
-
closeTopicDecoder(topic, topicDecoders);
|
|
1281
|
-
return;
|
|
1282
|
-
}
|
|
1283
|
-
const chunk = new EncodedVideoChunk({
|
|
1284
|
-
type: "key",
|
|
1285
|
-
data: pendingFrame.data,
|
|
1286
|
-
timestamp: pendingFrame.timestamp
|
|
1287
|
-
});
|
|
1288
|
-
decoder.decode(chunk);
|
|
1289
|
-
} catch (error) {
|
|
1290
|
-
if (isUnconfiguredCodecError(error)) {
|
|
1291
|
-
decoderInfo.pendingFrame = pendingFrame;
|
|
1292
|
-
const replacementDecoder = resetTopicDecoder({
|
|
1293
|
-
topic,
|
|
1294
|
-
topicDecoders,
|
|
1295
|
-
callback,
|
|
1296
|
-
onError
|
|
1297
|
-
});
|
|
1298
|
-
if ((replacementDecoder === null || replacementDecoder === void 0 ? void 0 : replacementDecoder.state) === "configured") {
|
|
1299
|
-
decodePendingFrame(topic, topicDecoders, callback, onError);
|
|
1300
|
-
}
|
|
1301
|
-
return;
|
|
1302
|
-
}
|
|
1303
|
-
closeTopicDecoder(topic, topicDecoders);
|
|
1304
|
-
onError(new DecoderRuntimeError(topic, error instanceof Error ? error.message : "Failed to decode H.265 frame."));
|
|
1305
|
-
}
|
|
1306
1139
|
}
|
|
1307
1140
|
function createVideoDecoder({
|
|
1308
1141
|
topic,
|
|
@@ -1310,29 +1143,25 @@ function createVideoDecoder({
|
|
|
1310
1143
|
topicDecoders,
|
|
1311
1144
|
onError
|
|
1312
1145
|
}) {
|
|
1313
|
-
|
|
1314
|
-
decoder = new VideoDecoder({
|
|
1146
|
+
return new VideoDecoder({
|
|
1315
1147
|
output: async frame => {
|
|
1316
|
-
var _topicDecoders$
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
const
|
|
1324
|
-
(_topicDecoders$
|
|
1325
|
-
const transformation = (_topicDecoders$get5 = topicDecoders.get(topic)) === null || _topicDecoders$get5 === void 0 ? void 0 : _topicDecoders$get5.transformations.get(frame.timestamp);
|
|
1326
|
-
(_topicDecoders$get6 = topicDecoders.get(topic)) === null || _topicDecoders$get6 === void 0 || _topicDecoders$get6.transformations.delete(frame.timestamp);
|
|
1327
|
-
const [encoding, step] = parsePixelFormat(frame.format);
|
|
1148
|
+
var _topicDecoders$get$ti, _topicDecoders$get, _topicDecoders$get2, _topicDecoders$get3;
|
|
1149
|
+
const {
|
|
1150
|
+
data: buffer,
|
|
1151
|
+
width,
|
|
1152
|
+
height
|
|
1153
|
+
} = await copyVideoFrameToI420(frame, "H265");
|
|
1154
|
+
const receiveTime = (_topicDecoders$get$ti = (_topicDecoders$get = topicDecoders.get(topic)) === null || _topicDecoders$get === void 0 ? void 0 : _topicDecoders$get.timing.get(frame.timestamp)) !== null && _topicDecoders$get$ti !== void 0 ? _topicDecoders$get$ti : dist.fromMicros(frame.timestamp);
|
|
1155
|
+
const transformation = (_topicDecoders$get2 = topicDecoders.get(topic)) === null || _topicDecoders$get2 === void 0 ? void 0 : _topicDecoders$get2.transformations.get(frame.timestamp);
|
|
1156
|
+
(_topicDecoders$get3 = topicDecoders.get(topic)) === null || _topicDecoders$get3 === void 0 || _topicDecoders$get3.transformations.delete(frame.timestamp);
|
|
1328
1157
|
const foxgloveMessage = {
|
|
1329
1158
|
timestamp: receiveTime,
|
|
1330
1159
|
frame_id: `h265-${topic}-frame`,
|
|
1331
|
-
width
|
|
1332
|
-
height
|
|
1160
|
+
width,
|
|
1161
|
+
height,
|
|
1333
1162
|
data: buffer,
|
|
1334
|
-
encoding,
|
|
1335
|
-
step:
|
|
1163
|
+
encoding: "yuv420p",
|
|
1164
|
+
step: width
|
|
1336
1165
|
};
|
|
1337
1166
|
callback({
|
|
1338
1167
|
topic,
|
|
@@ -1343,21 +1172,13 @@ function createVideoDecoder({
|
|
|
1343
1172
|
depthaiTransformation: transformation
|
|
1344
1173
|
});
|
|
1345
1174
|
frame.close();
|
|
1346
|
-
if (((_topicDecoders$get7 = topicDecoders.get(topic)) === null || _topicDecoders$get7 === void 0 ? void 0 : _topicDecoders$get7.decoder) === decoder) {
|
|
1347
|
-
decodePendingFrame(topic, topicDecoders, callback, onError);
|
|
1348
|
-
}
|
|
1349
1175
|
},
|
|
1350
1176
|
error: error => {
|
|
1351
|
-
var _topicDecoders$get8;
|
|
1352
|
-
if (((_topicDecoders$get8 = topicDecoders.get(topic)) === null || _topicDecoders$get8 === void 0 ? void 0 : _topicDecoders$get8.decoder) !== decoder) {
|
|
1353
|
-
return;
|
|
1354
|
-
}
|
|
1355
1177
|
logger$1.error(error);
|
|
1356
1178
|
closeTopicDecoder(topic, topicDecoders);
|
|
1357
1179
|
onError(new DecoderRuntimeError(topic, error.message));
|
|
1358
1180
|
}
|
|
1359
1181
|
});
|
|
1360
|
-
return decoder;
|
|
1361
1182
|
}
|
|
1362
1183
|
async function deserializeEncodedFrameH265({
|
|
1363
1184
|
topic,
|
|
@@ -1374,34 +1195,58 @@ async function deserializeEncodedFrameH265({
|
|
|
1374
1195
|
return;
|
|
1375
1196
|
}
|
|
1376
1197
|
const existingDecoderInfo = topicDecoders.get(topic);
|
|
1377
|
-
if (!existingDecoderInfo || existingDecoderInfo.decoder.state
|
|
1378
|
-
const decoder =
|
|
1198
|
+
if (!existingDecoderInfo || existingDecoderInfo.decoder.state === "closed") {
|
|
1199
|
+
const decoder = createVideoDecoder({
|
|
1379
1200
|
topic,
|
|
1380
1201
|
callback,
|
|
1381
1202
|
topicDecoders,
|
|
1382
1203
|
onError
|
|
1383
1204
|
});
|
|
1384
|
-
|
|
1205
|
+
try {
|
|
1206
|
+
decoder.configure({
|
|
1207
|
+
codec: "hev1.1.6.L93.B0",
|
|
1208
|
+
optimizeForLatency: true
|
|
1209
|
+
});
|
|
1210
|
+
} catch (error) {
|
|
1211
|
+
closeDecoder(decoder);
|
|
1212
|
+
onError(new DecoderRuntimeError(topic, error instanceof Error ? error.message : "Failed to configure H.265 decoder."));
|
|
1385
1213
|
return;
|
|
1386
1214
|
}
|
|
1215
|
+
if (existingDecoderInfo) {
|
|
1216
|
+
existingDecoderInfo.decoder = decoder;
|
|
1217
|
+
existingDecoderInfo.timing.clear();
|
|
1218
|
+
existingDecoderInfo.transformations.clear();
|
|
1219
|
+
} else {
|
|
1220
|
+
topicDecoders.set(topic, {
|
|
1221
|
+
decoder,
|
|
1222
|
+
timing: new Map(),
|
|
1223
|
+
transformations: new Map()
|
|
1224
|
+
});
|
|
1225
|
+
}
|
|
1387
1226
|
}
|
|
1388
1227
|
const decoderInfo = topicDecoders.get(topic);
|
|
1389
1228
|
if (!decoderInfo) {
|
|
1390
1229
|
return;
|
|
1391
1230
|
}
|
|
1231
|
+
if (decoderInfo.decoder.decodeQueueSize > 60) {
|
|
1232
|
+
decoderInfo.decoder.reset();
|
|
1233
|
+
return;
|
|
1234
|
+
}
|
|
1392
1235
|
const microTimestamp = receiveTime.sec * 1000000 + Math.floor(receiveTime.nsec / 1000);
|
|
1236
|
+
decoderInfo.timing.set(microTimestamp, receiveTime);
|
|
1237
|
+
decoderInfo.transformations.set(microTimestamp, message.transformation);
|
|
1393
1238
|
const frame = {
|
|
1239
|
+
type: 'key',
|
|
1394
1240
|
data: message.data,
|
|
1395
|
-
timestamp: microTimestamp
|
|
1396
|
-
receiveTime,
|
|
1397
|
-
transformation: message.transformation
|
|
1241
|
+
timestamp: microTimestamp
|
|
1398
1242
|
};
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1243
|
+
try {
|
|
1244
|
+
const chunk = new EncodedVideoChunk(frame);
|
|
1245
|
+
decoderInfo.decoder.decode(chunk);
|
|
1246
|
+
} catch (error) {
|
|
1247
|
+
closeTopicDecoder(topic, topicDecoders);
|
|
1248
|
+
onError(new DecoderRuntimeError(topic, error instanceof Error ? error.message : "Failed to decode H.265 frame."));
|
|
1402
1249
|
}
|
|
1403
|
-
decoderInfo.pendingFrame = frame;
|
|
1404
|
-
decodePendingFrame(topic, topicDecoders, callback, onError);
|
|
1405
1250
|
}
|
|
1406
1251
|
|
|
1407
1252
|
// This Source Code Form is subject to the terms of the Mozilla Public
|
|
@@ -1427,17 +1272,19 @@ async function deserializeMJPEGFrame({
|
|
|
1427
1272
|
const {
|
|
1428
1273
|
image: frame
|
|
1429
1274
|
} = await decoder.decode();
|
|
1430
|
-
const
|
|
1431
|
-
|
|
1432
|
-
|
|
1275
|
+
const {
|
|
1276
|
+
data: buffer,
|
|
1277
|
+
width,
|
|
1278
|
+
height
|
|
1279
|
+
} = await copyVideoFrameToI420(frame, "MJPEG");
|
|
1433
1280
|
const foxgloveMessage = {
|
|
1434
1281
|
timestamp: receiveTime,
|
|
1435
1282
|
frame_id: "camera",
|
|
1436
|
-
width
|
|
1437
|
-
height
|
|
1283
|
+
width,
|
|
1284
|
+
height,
|
|
1438
1285
|
data: buffer,
|
|
1439
|
-
encoding,
|
|
1440
|
-
step:
|
|
1286
|
+
encoding: "yuv420p",
|
|
1287
|
+
step: width
|
|
1441
1288
|
};
|
|
1442
1289
|
frame.close();
|
|
1443
1290
|
callback({
|
|
@@ -1450,6 +1297,363 @@ async function deserializeMJPEGFrame({
|
|
|
1450
1297
|
});
|
|
1451
1298
|
}
|
|
1452
1299
|
|
|
1300
|
+
const RGBD_POINTCLOUD_WORKER_COUNT = 4;
|
|
1301
|
+
let cachedRGBDHasGPU;
|
|
1302
|
+
let rgbdHasGPUPromise;
|
|
1303
|
+
let rgbdPointCloudWorkers;
|
|
1304
|
+
let rgbdPointCloudWorkerIndex = 0;
|
|
1305
|
+
Logger.getLogger();
|
|
1306
|
+
function ensureEvenByteLength(data) {
|
|
1307
|
+
if (data.length % 2 === 0) {
|
|
1308
|
+
return data;
|
|
1309
|
+
}
|
|
1310
|
+
const padded = new Uint8Array(data.length + 1);
|
|
1311
|
+
padded.set(data);
|
|
1312
|
+
return padded;
|
|
1313
|
+
}
|
|
1314
|
+
async function detectRGBDGPUSupport() {
|
|
1315
|
+
if (cachedRGBDHasGPU != undefined) {
|
|
1316
|
+
return cachedRGBDHasGPU;
|
|
1317
|
+
}
|
|
1318
|
+
if (rgbdHasGPUPromise) {
|
|
1319
|
+
return await rgbdHasGPUPromise;
|
|
1320
|
+
}
|
|
1321
|
+
rgbdHasGPUPromise = (async () => {
|
|
1322
|
+
if (typeof navigator.gpu === "undefined") {
|
|
1323
|
+
cachedRGBDHasGPU = false;
|
|
1324
|
+
return false;
|
|
1325
|
+
}
|
|
1326
|
+
try {
|
|
1327
|
+
const adapter = await navigator.gpu.requestAdapter();
|
|
1328
|
+
cachedRGBDHasGPU = adapter != undefined;
|
|
1329
|
+
return cachedRGBDHasGPU;
|
|
1330
|
+
} catch (_unused) {
|
|
1331
|
+
cachedRGBDHasGPU = false;
|
|
1332
|
+
return false;
|
|
1333
|
+
} finally {
|
|
1334
|
+
rgbdHasGPUPromise = undefined;
|
|
1335
|
+
}
|
|
1336
|
+
})();
|
|
1337
|
+
return await rgbdHasGPUPromise;
|
|
1338
|
+
}
|
|
1339
|
+
function getRGBDPointCloudWorkerSlot() {
|
|
1340
|
+
if (!rgbdPointCloudWorkers) {
|
|
1341
|
+
rgbdPointCloudWorkers = Array.from({
|
|
1342
|
+
length: RGBD_POINTCLOUD_WORKER_COUNT
|
|
1343
|
+
}, () => {
|
|
1344
|
+
const worker = new Worker(new URL("pointcloudFromDepth.worker-60RA4Ief.js", import.meta.url), {
|
|
1345
|
+
type: "module"
|
|
1346
|
+
});
|
|
1347
|
+
return {
|
|
1348
|
+
worker,
|
|
1349
|
+
remote: wrap(worker),
|
|
1350
|
+
activeJobs: 0
|
|
1351
|
+
};
|
|
1352
|
+
});
|
|
1353
|
+
}
|
|
1354
|
+
const slots = rgbdPointCloudWorkers;
|
|
1355
|
+
const candidateSlots = slots.map((slot, index) => ({
|
|
1356
|
+
slot,
|
|
1357
|
+
index
|
|
1358
|
+
})).sort((left, right) => {
|
|
1359
|
+
if (left.slot.activeJobs !== right.slot.activeJobs) {
|
|
1360
|
+
return left.slot.activeJobs - right.slot.activeJobs;
|
|
1361
|
+
}
|
|
1362
|
+
const leftDistance = (left.index - rgbdPointCloudWorkerIndex + slots.length) % slots.length;
|
|
1363
|
+
const rightDistance = (right.index - rgbdPointCloudWorkerIndex + slots.length) % slots.length;
|
|
1364
|
+
return leftDistance - rightDistance;
|
|
1365
|
+
});
|
|
1366
|
+
const selected = candidateSlots[0];
|
|
1367
|
+
rgbdPointCloudWorkerIndex = (selected.index + 1) % slots.length;
|
|
1368
|
+
return selected.slot;
|
|
1369
|
+
}
|
|
1370
|
+
function repackYuv420pToI420(imageFrame, width, height) {
|
|
1371
|
+
var _imageFrame$fb;
|
|
1372
|
+
const specs = (_imageFrame$fb = imageFrame.fb) !== null && _imageFrame$fb !== void 0 ? _imageFrame$fb : imageFrame.sourceFb;
|
|
1373
|
+
const source = ensureEvenByteLength(imageFrame.data);
|
|
1374
|
+
const yStride = (specs === null || specs === void 0 ? void 0 : specs.stride) || width;
|
|
1375
|
+
const uvWidth = Math.floor(width / 2);
|
|
1376
|
+
const uvHeight = Math.floor(height / 2);
|
|
1377
|
+
const uvStride = yStride > width ? Math.floor(yStride / 2) : uvWidth;
|
|
1378
|
+
const yPlaneSize = width * height;
|
|
1379
|
+
const uvPlaneSize = uvWidth * uvHeight;
|
|
1380
|
+
const uOffset = (specs === null || specs === void 0 ? void 0 : specs.p1Offset) || yStride * height;
|
|
1381
|
+
const vOffset = (specs === null || specs === void 0 ? void 0 : specs.p2Offset) || uOffset + uvStride * uvHeight;
|
|
1382
|
+
const i420 = new Uint8Array(yPlaneSize + 2 * uvPlaneSize);
|
|
1383
|
+
for (let row = 0; row < height; row++) {
|
|
1384
|
+
const srcOffset = row * yStride;
|
|
1385
|
+
const dstOffset = row * width;
|
|
1386
|
+
i420.set(source.subarray(srcOffset, srcOffset + width), dstOffset);
|
|
1387
|
+
}
|
|
1388
|
+
for (let row = 0; row < uvHeight; row++) {
|
|
1389
|
+
const srcUOffset = uOffset + row * uvStride;
|
|
1390
|
+
const srcVOffset = vOffset + row * uvStride;
|
|
1391
|
+
const dstOffset = row * uvWidth;
|
|
1392
|
+
i420.set(source.subarray(srcUOffset, srcUOffset + uvWidth), yPlaneSize + dstOffset);
|
|
1393
|
+
i420.set(source.subarray(srcVOffset, srcVOffset + uvWidth), yPlaneSize + uvPlaneSize + dstOffset);
|
|
1394
|
+
}
|
|
1395
|
+
return i420;
|
|
1396
|
+
}
|
|
1397
|
+
function toMatrix3x3(matrix) {
|
|
1398
|
+
const rows = matrix === null || matrix === void 0 ? void 0 : matrix.arrays;
|
|
1399
|
+
if (!rows || rows.length < 3) {
|
|
1400
|
+
return undefined;
|
|
1401
|
+
}
|
|
1402
|
+
const normalizedRows = rows.slice(0, 3).map(row => row === null || row === void 0 ? void 0 : row.values.slice(0, 3).map(value => value !== null && value !== void 0 ? value : 0));
|
|
1403
|
+
if (normalizedRows.some(row => !row || row.length < 3)) {
|
|
1404
|
+
return undefined;
|
|
1405
|
+
}
|
|
1406
|
+
return normalizedRows;
|
|
1407
|
+
}
|
|
1408
|
+
function multiply3x3(left, right) {
|
|
1409
|
+
return [[left[0][0] * right[0][0] + left[0][1] * right[1][0] + left[0][2] * right[2][0], left[0][0] * right[0][1] + left[0][1] * right[1][1] + left[0][2] * right[2][1], left[0][0] * right[0][2] + left[0][1] * right[1][2] + left[0][2] * right[2][2]], [left[1][0] * right[0][0] + left[1][1] * right[1][0] + left[1][2] * right[2][0], left[1][0] * right[0][1] + left[1][1] * right[1][1] + left[1][2] * right[2][1], left[1][0] * right[0][2] + left[1][1] * right[1][2] + left[1][2] * right[2][2]], [left[2][0] * right[0][0] + left[2][1] * right[1][0] + left[2][2] * right[2][0], left[2][0] * right[0][1] + left[2][1] * right[1][1] + left[2][2] * right[2][1], left[2][0] * right[0][2] + left[2][1] * right[1][2] + left[2][2] * right[2][2]]];
|
|
1410
|
+
}
|
|
1411
|
+
function extractIntrinsicsFromTransformation(transformation) {
|
|
1412
|
+
const sourceIntrinsicMatrix = toMatrix3x3(transformation === null || transformation === void 0 ? void 0 : transformation.sourceIntrinsicMatrix);
|
|
1413
|
+
if (!sourceIntrinsicMatrix) {
|
|
1414
|
+
return undefined;
|
|
1415
|
+
}
|
|
1416
|
+
const transformationMatrix = toMatrix3x3(transformation === null || transformation === void 0 ? void 0 : transformation.transformationMatrix);
|
|
1417
|
+
const effectiveIntrinsicMatrix = transformationMatrix ? multiply3x3(transformationMatrix, sourceIntrinsicMatrix) : sourceIntrinsicMatrix;
|
|
1418
|
+
const fx = effectiveIntrinsicMatrix[0][0];
|
|
1419
|
+
const fy = effectiveIntrinsicMatrix[1][1];
|
|
1420
|
+
const cx = effectiveIntrinsicMatrix[0][2];
|
|
1421
|
+
const cy = effectiveIntrinsicMatrix[1][2];
|
|
1422
|
+
if (![fx, fy, cx, cy].every(value => Number.isFinite(value))) {
|
|
1423
|
+
return undefined;
|
|
1424
|
+
}
|
|
1425
|
+
return {
|
|
1426
|
+
left: {
|
|
1427
|
+
focalLenght: {
|
|
1428
|
+
x: fx,
|
|
1429
|
+
y: fy
|
|
1430
|
+
},
|
|
1431
|
+
principalPoint: {
|
|
1432
|
+
x: cx,
|
|
1433
|
+
y: cy
|
|
1434
|
+
}
|
|
1435
|
+
},
|
|
1436
|
+
right: {
|
|
1437
|
+
focalLenght: {
|
|
1438
|
+
x: fx,
|
|
1439
|
+
y: fy
|
|
1440
|
+
},
|
|
1441
|
+
principalPoint: {
|
|
1442
|
+
x: cx,
|
|
1443
|
+
y: cy
|
|
1444
|
+
}
|
|
1445
|
+
}
|
|
1446
|
+
};
|
|
1447
|
+
}
|
|
1448
|
+
function resolveRGBDIntrinsics(message, fallbackIntrinsics) {
|
|
1449
|
+
var _ref, _ref2, _ref3, _extractIntrinsicsFro, _message$depthImgFram, _message$depthEncoded, _message$colorImgFram, _message$colorEncoded;
|
|
1450
|
+
return (_ref = (_ref2 = (_ref3 = (_extractIntrinsicsFro = extractIntrinsicsFromTransformation((_message$depthImgFram = message.depthImgFrame) === null || _message$depthImgFram === void 0 ? void 0 : _message$depthImgFram.transformation)) !== null && _extractIntrinsicsFro !== void 0 ? _extractIntrinsicsFro : extractIntrinsicsFromTransformation((_message$depthEncoded = message.depthEncodedFrame) === null || _message$depthEncoded === void 0 ? void 0 : _message$depthEncoded.transformation)) !== null && _ref3 !== void 0 ? _ref3 : extractIntrinsicsFromTransformation((_message$colorImgFram = message.colorImgFrame) === null || _message$colorImgFram === void 0 ? void 0 : _message$colorImgFram.transformation)) !== null && _ref2 !== void 0 ? _ref2 : extractIntrinsicsFromTransformation((_message$colorEncoded = message.colorEncodedFrame) === null || _message$colorEncoded === void 0 ? void 0 : _message$colorEncoded.transformation)) !== null && _ref !== void 0 ? _ref : fallbackIntrinsics;
|
|
1451
|
+
}
|
|
1452
|
+
async function extractEncodedColorFrame(encodedFrame, topicDecoders, topic) {
|
|
1453
|
+
const decodeFrame = async () => await new Promise((resolve, reject) => {
|
|
1454
|
+
const callback = event => {
|
|
1455
|
+
resolve(event.message);
|
|
1456
|
+
};
|
|
1457
|
+
const rejectDecode = error => {
|
|
1458
|
+
reject(error);
|
|
1459
|
+
};
|
|
1460
|
+
const args = {
|
|
1461
|
+
topic,
|
|
1462
|
+
message: encodedFrame,
|
|
1463
|
+
callback
|
|
1464
|
+
};
|
|
1465
|
+
if (encodedFrame.profile === Profile.AVC) {
|
|
1466
|
+
void deserializeEncodedFrameH264(_objectSpread2(_objectSpread2({}, args), {}, {
|
|
1467
|
+
topicDecoders,
|
|
1468
|
+
onError: rejectDecode
|
|
1469
|
+
})).catch(rejectDecode);
|
|
1470
|
+
} else if (encodedFrame.profile === Profile.JPEG) {
|
|
1471
|
+
void deserializeMJPEGFrame(args).catch(rejectDecode);
|
|
1472
|
+
} else if (encodedFrame.profile === Profile.HEVC) {
|
|
1473
|
+
void deserializeEncodedFrameH265(_objectSpread2(_objectSpread2({}, args), {}, {
|
|
1474
|
+
topicDecoders,
|
|
1475
|
+
onError: rejectDecode
|
|
1476
|
+
})).catch(rejectDecode);
|
|
1477
|
+
} else {
|
|
1478
|
+
var _Profile$encodedFrame;
|
|
1479
|
+
reject(new Error(`Unsupported RGBD color profile ${(_Profile$encodedFrame = Profile[encodedFrame.profile]) !== null && _Profile$encodedFrame !== void 0 ? _Profile$encodedFrame : encodedFrame.profile}`));
|
|
1480
|
+
}
|
|
1481
|
+
});
|
|
1482
|
+
const decoded = await decodeFrame();
|
|
1483
|
+
return {
|
|
1484
|
+
data: ensureEvenByteLength(decoded.data),
|
|
1485
|
+
width: decoded.width,
|
|
1486
|
+
height: decoded.height
|
|
1487
|
+
};
|
|
1488
|
+
}
|
|
1489
|
+
function extractColorFrame(encodedFrame, imageFrame, topicDecoders, topic) {
|
|
1490
|
+
if (encodedFrame) {
|
|
1491
|
+
return extractEncodedColorFrame(encodedFrame, topicDecoders, topic);
|
|
1492
|
+
}
|
|
1493
|
+
if (imageFrame) {
|
|
1494
|
+
var _imageFrame$fb2;
|
|
1495
|
+
const {
|
|
1496
|
+
width,
|
|
1497
|
+
height,
|
|
1498
|
+
type
|
|
1499
|
+
} = parseMessage(imageFrame);
|
|
1500
|
+
const specs = (_imageFrame$fb2 = imageFrame.fb) !== null && _imageFrame$fb2 !== void 0 ? _imageFrame$fb2 : imageFrame.sourceFb;
|
|
1501
|
+
if (type === Type.NV12) {
|
|
1502
|
+
const stride = (specs === null || specs === void 0 ? void 0 : specs.stride) || width;
|
|
1503
|
+
const uvOffset = (specs === null || specs === void 0 ? void 0 : specs.p1Offset) || stride * height;
|
|
1504
|
+
return Promise.resolve({
|
|
1505
|
+
data: convertNv12ToI420(ensureEvenByteLength(imageFrame.data), width, height, stride, stride, 0, uvOffset),
|
|
1506
|
+
width,
|
|
1507
|
+
height
|
|
1508
|
+
});
|
|
1509
|
+
}
|
|
1510
|
+
if (type === Type.YUV420p) {
|
|
1511
|
+
return Promise.resolve({
|
|
1512
|
+
data: repackYuv420pToI420(imageFrame, width, height),
|
|
1513
|
+
width,
|
|
1514
|
+
height
|
|
1515
|
+
});
|
|
1516
|
+
}
|
|
1517
|
+
return Promise.reject(new Error(`Unsupported RGBD color ImgFrame type ${Type[type]}`));
|
|
1518
|
+
}
|
|
1519
|
+
return Promise.resolve({
|
|
1520
|
+
data: new Uint8Array(),
|
|
1521
|
+
width: 0,
|
|
1522
|
+
height: 0
|
|
1523
|
+
});
|
|
1524
|
+
}
|
|
1525
|
+
function extractDepthFrame(encodedFrame, imageFrame) {
|
|
1526
|
+
if (encodedFrame) {
|
|
1527
|
+
return ensureEvenByteLength(encodedFrame.data);
|
|
1528
|
+
}
|
|
1529
|
+
if (imageFrame) {
|
|
1530
|
+
return ensureEvenByteLength(imageFrame.data);
|
|
1531
|
+
}
|
|
1532
|
+
return new Uint8Array();
|
|
1533
|
+
}
|
|
1534
|
+
function parseDimensions(message) {
|
|
1535
|
+
const obj = {
|
|
1536
|
+
depthWidth: 0,
|
|
1537
|
+
depthHeight: 0
|
|
1538
|
+
};
|
|
1539
|
+
if (message.depthEncodedFrame) {
|
|
1540
|
+
var _message$depthEncoded2;
|
|
1541
|
+
const {
|
|
1542
|
+
width,
|
|
1543
|
+
height
|
|
1544
|
+
} = (_message$depthEncoded2 = message.depthEncodedFrame) !== null && _message$depthEncoded2 !== void 0 ? _message$depthEncoded2 : {
|
|
1545
|
+
width: 1920,
|
|
1546
|
+
height: 1200
|
|
1547
|
+
};
|
|
1548
|
+
obj.depthWidth = width;
|
|
1549
|
+
obj.depthHeight = height;
|
|
1550
|
+
} else if (message.depthImgFrame) {
|
|
1551
|
+
const {
|
|
1552
|
+
width,
|
|
1553
|
+
height
|
|
1554
|
+
} = parseMessage(message.depthImgFrame);
|
|
1555
|
+
obj.depthWidth = width;
|
|
1556
|
+
obj.depthHeight = height;
|
|
1557
|
+
}
|
|
1558
|
+
return obj;
|
|
1559
|
+
}
|
|
1560
|
+
async function deserializeRGBDFrameToPointCloud({
|
|
1561
|
+
topic,
|
|
1562
|
+
topicDecoders,
|
|
1563
|
+
cameraIntrinsics,
|
|
1564
|
+
maxStereoDepth,
|
|
1565
|
+
message,
|
|
1566
|
+
callback
|
|
1567
|
+
}) {
|
|
1568
|
+
const workerSlot = getRGBDPointCloudWorkerSlot();
|
|
1569
|
+
workerSlot.activeJobs += 1;
|
|
1570
|
+
const {
|
|
1571
|
+
receiveTime
|
|
1572
|
+
} = parseMessage(message);
|
|
1573
|
+
const {
|
|
1574
|
+
depthWidth,
|
|
1575
|
+
depthHeight
|
|
1576
|
+
} = parseDimensions(message);
|
|
1577
|
+
const rgbdIntrinsics = resolveRGBDIntrinsics(message, cameraIntrinsics);
|
|
1578
|
+
const hasGPU = await detectRGBDGPUSupport();
|
|
1579
|
+
const colorFrame = await extractColorFrame(message.colorEncodedFrame, message.colorImgFrame, topicDecoders, topic);
|
|
1580
|
+
const uint8DepthFrames = extractDepthFrame(message.depthEncodedFrame, message.depthImgFrame);
|
|
1581
|
+
const depthFrames = uint8ArrayToUint16Array(uint8DepthFrames);
|
|
1582
|
+
try {
|
|
1583
|
+
var _message$tsDevice;
|
|
1584
|
+
const pointCloud = await workerSlot.remote.depthToPointcloudGPU([depthFrames], depthWidth, depthHeight, rgbdIntrinsics.right.focalLenght.x, rgbdIntrinsics.right.focalLenght.y, rgbdIntrinsics.right.principalPoint.x, rgbdIntrinsics.right.principalPoint.y, [colorFrame.data], colorFrame.width, colorFrame.height, maxStereoDepth, {
|
|
1585
|
+
hasGPU
|
|
1586
|
+
});
|
|
1587
|
+
const foxgloveMessage = {
|
|
1588
|
+
timestamp: (_message$tsDevice = message.tsDevice) !== null && _message$tsDevice !== void 0 ? _message$tsDevice : receiveTime,
|
|
1589
|
+
frame_id: `pointcloud-${topic}-frame`,
|
|
1590
|
+
point_stride: 16,
|
|
1591
|
+
pose: {
|
|
1592
|
+
position: {
|
|
1593
|
+
x: 0,
|
|
1594
|
+
y: 0,
|
|
1595
|
+
z: 0
|
|
1596
|
+
},
|
|
1597
|
+
orientation: {
|
|
1598
|
+
x: 0,
|
|
1599
|
+
y: 0,
|
|
1600
|
+
z: 1,
|
|
1601
|
+
w: 0
|
|
1602
|
+
}
|
|
1603
|
+
},
|
|
1604
|
+
width: depthWidth,
|
|
1605
|
+
height: depthHeight,
|
|
1606
|
+
fields: [{
|
|
1607
|
+
name: "x",
|
|
1608
|
+
offset: 0,
|
|
1609
|
+
type: typescript.NumericType.FLOAT32
|
|
1610
|
+
}, {
|
|
1611
|
+
name: "y",
|
|
1612
|
+
offset: 4,
|
|
1613
|
+
type: typescript.NumericType.FLOAT32
|
|
1614
|
+
}, {
|
|
1615
|
+
name: "z",
|
|
1616
|
+
offset: 8,
|
|
1617
|
+
type: typescript.NumericType.FLOAT32
|
|
1618
|
+
}, {
|
|
1619
|
+
name: "red",
|
|
1620
|
+
offset: 12,
|
|
1621
|
+
type: typescript.NumericType.UINT8
|
|
1622
|
+
}, {
|
|
1623
|
+
name: "green",
|
|
1624
|
+
offset: 13,
|
|
1625
|
+
type: typescript.NumericType.UINT8
|
|
1626
|
+
}, {
|
|
1627
|
+
name: "blue",
|
|
1628
|
+
offset: 14,
|
|
1629
|
+
type: typescript.NumericType.UINT8
|
|
1630
|
+
}, {
|
|
1631
|
+
name: "alpha",
|
|
1632
|
+
offset: 15,
|
|
1633
|
+
type: typescript.NumericType.UINT8
|
|
1634
|
+
}],
|
|
1635
|
+
data: pointCloud[0]
|
|
1636
|
+
};
|
|
1637
|
+
callback({
|
|
1638
|
+
topic,
|
|
1639
|
+
receiveTime,
|
|
1640
|
+
message: foxgloveMessage,
|
|
1641
|
+
sizeInBytes: estimateObjectSize(foxgloveMessage),
|
|
1642
|
+
schemaName: "foxglove.PointCloud.Colored"
|
|
1643
|
+
});
|
|
1644
|
+
if (message.depthImgFrame) {
|
|
1645
|
+
void deserializeDepthFrame({
|
|
1646
|
+
topic,
|
|
1647
|
+
message: message.depthImgFrame,
|
|
1648
|
+
callback,
|
|
1649
|
+
maxStereoDepth: maxStereoDepth / 1000
|
|
1650
|
+
});
|
|
1651
|
+
}
|
|
1652
|
+
} finally {
|
|
1653
|
+
workerSlot.activeJobs = Math.max(0, workerSlot.activeJobs - 1);
|
|
1654
|
+
}
|
|
1655
|
+
}
|
|
1656
|
+
|
|
1453
1657
|
const logger = Logger.getLogger();
|
|
1454
1658
|
function errorInstanceToErrorCode(error) {
|
|
1455
1659
|
if (error instanceof UnsupportedTopicError) {
|
|
@@ -1481,6 +1685,7 @@ function handleMessageToDecode({
|
|
|
1481
1685
|
schema,
|
|
1482
1686
|
buffer,
|
|
1483
1687
|
topic,
|
|
1688
|
+
neuralCameraIntrinsics,
|
|
1484
1689
|
stereoDepthMaxValue
|
|
1485
1690
|
}, configStore, errorCallback) {
|
|
1486
1691
|
const handleDecodingError = error => {
|
|
@@ -1514,6 +1719,7 @@ function handleMessageToDecode({
|
|
|
1514
1719
|
topic,
|
|
1515
1720
|
topicSizes,
|
|
1516
1721
|
topicDecoders,
|
|
1722
|
+
neuralCameraIntrinsics,
|
|
1517
1723
|
message,
|
|
1518
1724
|
callback,
|
|
1519
1725
|
type: protobufSchema.type,
|
|
@@ -1525,7 +1731,6 @@ function handleMessageToDecode({
|
|
|
1525
1731
|
}
|
|
1526
1732
|
}
|
|
1527
1733
|
async function deserializeDepthAiMessage(args) {
|
|
1528
|
-
// eslint-disable-next-line @typescript-eslint/no-shadow
|
|
1529
1734
|
const {
|
|
1530
1735
|
topicDecoders,
|
|
1531
1736
|
topicSizes,
|
|
@@ -1533,6 +1738,7 @@ async function deserializeDepthAiMessage(args) {
|
|
|
1533
1738
|
message,
|
|
1534
1739
|
callback,
|
|
1535
1740
|
topic,
|
|
1741
|
+
neuralCameraIntrinsics,
|
|
1536
1742
|
maxSteroDepth,
|
|
1537
1743
|
onError
|
|
1538
1744
|
} = args;
|
|
@@ -1678,6 +1884,19 @@ async function deserializeDepthAiMessage(args) {
|
|
|
1678
1884
|
});
|
|
1679
1885
|
break;
|
|
1680
1886
|
}
|
|
1887
|
+
case 'rgbd':
|
|
1888
|
+
{
|
|
1889
|
+
void deserializeRGBDFrameToPointCloud({
|
|
1890
|
+
topic,
|
|
1891
|
+
topicDecoders,
|
|
1892
|
+
cameraIntrinsics: neuralCameraIntrinsics,
|
|
1893
|
+
maxStereoDepth: maxSteroDepth,
|
|
1894
|
+
message,
|
|
1895
|
+
callback,
|
|
1896
|
+
onError
|
|
1897
|
+
});
|
|
1898
|
+
break;
|
|
1899
|
+
}
|
|
1681
1900
|
default:
|
|
1682
1901
|
{
|
|
1683
1902
|
logger.warn(`Message decoding failed: unsupported type "${type}"`);
|