@luxonis/depthai-viewer-common 0.0.6 → 0.0.7
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/fonts/inter/UcC73FwrK3iLTeHuS_fvQtMwCp50KnMa0ZL7W0Q5n-wU.woff2 +0 -0
- package/dist/fonts/inter/UcC73FwrK3iLTeHuS_fvQtMwCp50KnMa1ZL7W0Q5nw.woff2 +0 -0
- package/dist/fonts/inter/UcC73FwrK3iLTeHuS_fvQtMwCp50KnMa1pL7W0Q5n-wU.woff2 +0 -0
- package/dist/fonts/inter/UcC73FwrK3iLTeHuS_fvQtMwCp50KnMa25L7W0Q5n-wU.woff2 +0 -0
- package/dist/fonts/inter/UcC73FwrK3iLTeHuS_fvQtMwCp50KnMa2JL7W0Q5n-wU.woff2 +0 -0
- package/dist/fonts/inter/UcC73FwrK3iLTeHuS_fvQtMwCp50KnMa2ZL7W0Q5n-wU.woff2 +0 -0
- package/dist/fonts/inter/UcC73FwrK3iLTeHuS_fvQtMwCp50KnMa2pL7W0Q5n-wU.woff2 +0 -0
- package/dist/fonts/inter.css +252 -0
- package/dist/fonts/jetbrains-mono.css +7 -0
- package/dist/fonts/jetbrains-mono.woff2 +0 -0
- package/dist/index.css +2 -0
- package/package.json +2 -2
- package/src/components/ButtonLink.tsx +0 -12
- package/src/components/CTASubLabel.tsx +0 -39
- package/src/components/DepthAIEntrypoint.tsx +0 -20
- package/src/components/Link.tsx +0 -10
- package/src/components/Pipeline.tsx +0 -35
- package/src/components/Resizable.tsx +0 -56
- package/src/components/Streams.tsx +0 -261
- package/src/constants/connection.ts +0 -45
- package/src/constants/streams.ts +0 -12
- package/src/constants/url.ts +0 -6
- package/src/dai-connection/connection.ts +0 -409
- package/src/dai-connection/decoder.worker.ts +0 -58
- package/src/hooks/connection.ts +0 -204
- package/src/hooks/navigation.ts +0 -25
- package/src/hooks/search.ts +0 -45
- package/src/index.ts +0 -30
- package/src/models/device-configuration.ts +0 -27
- package/src/providers/ConnectionProvider.tsx +0 -39
- package/src/providers/DataProvider.tsx +0 -71
- package/src/utils/arrays.ts +0 -10
- package/src/utils/dynamic-base-worker.ts +0 -21
- package/src/utils/functions.ts +0 -3
- package/src/utils/sorting.ts +0 -42
- package/src/utils/url.ts +0 -8
- package/src/window.d.ts +0 -7
- package/tsconfig.json +0 -37
|
@@ -1,261 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Button,
|
|
3
|
-
DropdownMenu,
|
|
4
|
-
DropdownMenuCheckboxItem,
|
|
5
|
-
DropdownMenuContent,
|
|
6
|
-
DropdownMenuTrigger,
|
|
7
|
-
Flex,
|
|
8
|
-
Header,
|
|
9
|
-
Input,
|
|
10
|
-
NormalText,
|
|
11
|
-
SubHeader,
|
|
12
|
-
Tooltip,
|
|
13
|
-
} from '@luxonis/common-fe-components';
|
|
14
|
-
import { ImagePanel, PanelLayout, PointCloudPanel } from '@luxonis/visualizer-protobuf';
|
|
15
|
-
import React from 'react';
|
|
16
|
-
|
|
17
|
-
import { ResizableLayout, type Topic } from '@luxonis/depthai-viewer-common';
|
|
18
|
-
import { StreamTypes } from '../constants/streams.js';
|
|
19
|
-
import { useConnection } from '../providers/ConnectionProvider.js';
|
|
20
|
-
import { useData } from '../providers/DataProvider.js';
|
|
21
|
-
import { makeColumns } from '../utils/arrays.js';
|
|
22
|
-
import { CTASubLabel } from './CTASubLabel.js';
|
|
23
|
-
import { FaUsersViewfinder as VisualizerIcon } from 'react-icons/fa6';
|
|
24
|
-
import { sortStreamsDefault } from '../utils/sorting.js';
|
|
25
|
-
import type { DeviceConfiguration } from '../models/device-configuration.js';
|
|
26
|
-
|
|
27
|
-
const EnabledStreamsView: React.FC<{
|
|
28
|
-
topics: Topic[][];
|
|
29
|
-
targetFps?: number;
|
|
30
|
-
isRawSteamEnabledManually?: boolean;
|
|
31
|
-
setIsRawSteamEnabledManually?: (value: boolean) => void;
|
|
32
|
-
triggerToast?: () => void;
|
|
33
|
-
deviceOptions?: DeviceConfiguration | null;
|
|
34
|
-
}> = ({
|
|
35
|
-
topics,
|
|
36
|
-
targetFps,
|
|
37
|
-
triggerToast,
|
|
38
|
-
isRawSteamEnabledManually,
|
|
39
|
-
setIsRawSteamEnabledManually,
|
|
40
|
-
}) => {
|
|
41
|
-
const { toggleTopic, topics: allTopics } = useConnection();
|
|
42
|
-
|
|
43
|
-
const items = React.useMemo(() => {
|
|
44
|
-
return topics.map((row) => {
|
|
45
|
-
let filteredRow = row.filter((topic) => !topic.name.startsWith('_'));
|
|
46
|
-
|
|
47
|
-
if (
|
|
48
|
-
filteredRow.some((topic) => topic.name === StreamTypes.PointCloud) &&
|
|
49
|
-
filteredRow.some((topic) => topic.name !== StreamTypes.Encoded) &&
|
|
50
|
-
!isRawSteamEnabledManually
|
|
51
|
-
) {
|
|
52
|
-
filteredRow = filteredRow.filter((topic) => topic.name !== StreamTypes.Encoded);
|
|
53
|
-
}
|
|
54
|
-
return filteredRow.map(({ name, annotations, extraAnnotations, kind }) => ({
|
|
55
|
-
component:
|
|
56
|
-
kind === 'pointCloud' || name === StreamTypes.PointCloud ? (
|
|
57
|
-
<PointCloudPanel
|
|
58
|
-
key={name}
|
|
59
|
-
toggleTopic={(topic) => {
|
|
60
|
-
if (allTopics.find((t) => t.name === StreamTypes._PointCloudColor)) {
|
|
61
|
-
toggleTopic(StreamTypes._PointCloudColor);
|
|
62
|
-
} else if (allTopics.find((t) => t.name === StreamTypes.Encoded)) {
|
|
63
|
-
toggleTopic(StreamTypes.Encoded);
|
|
64
|
-
}
|
|
65
|
-
toggleTopic(topic);
|
|
66
|
-
}}
|
|
67
|
-
topic={name}
|
|
68
|
-
/>
|
|
69
|
-
) : name !== StreamTypes.Raw &&
|
|
70
|
-
name !== StreamTypes.LeftRaw &&
|
|
71
|
-
name !== StreamTypes.RightRaw &&
|
|
72
|
-
!navigator.userAgent.includes('Chrome') ? (
|
|
73
|
-
<PanelLayout>
|
|
74
|
-
<Flex
|
|
75
|
-
full
|
|
76
|
-
justify="center"
|
|
77
|
-
align="center"
|
|
78
|
-
direction="column"
|
|
79
|
-
gap="sm"
|
|
80
|
-
textAlign="center"
|
|
81
|
-
>
|
|
82
|
-
<SubHeader text={`${name} is only supported in Google Chrome.`} />
|
|
83
|
-
<SubHeader text="Please switch to Chrome for the best experience." />
|
|
84
|
-
</Flex>
|
|
85
|
-
</PanelLayout>
|
|
86
|
-
) : (
|
|
87
|
-
<ImagePanel
|
|
88
|
-
key={name}
|
|
89
|
-
toggleTopic={(topic) => {
|
|
90
|
-
if (isRawSteamEnabledManually && topic === StreamTypes.Encoded) {
|
|
91
|
-
setIsRawSteamEnabledManually?.(false);
|
|
92
|
-
}
|
|
93
|
-
toggleTopic(topic);
|
|
94
|
-
}}
|
|
95
|
-
topic={name}
|
|
96
|
-
annotationTopics={annotations}
|
|
97
|
-
extraAnnotationTopics={extraAnnotations}
|
|
98
|
-
targetFps={targetFps}
|
|
99
|
-
triggerToast={triggerToast}
|
|
100
|
-
disableAnnotations={
|
|
101
|
-
name === StreamTypes.LeftRaw ||
|
|
102
|
-
name === StreamTypes.RightRaw ||
|
|
103
|
-
name === StreamTypes.LeftEncoded ||
|
|
104
|
-
name === StreamTypes.RightEncoded
|
|
105
|
-
}
|
|
106
|
-
/>
|
|
107
|
-
),
|
|
108
|
-
}));
|
|
109
|
-
});
|
|
110
|
-
}, [topics, targetFps, triggerToast, isRawSteamEnabledManually, setIsRawSteamEnabledManually]);
|
|
111
|
-
|
|
112
|
-
return <ResizableLayout items={items} />;
|
|
113
|
-
};
|
|
114
|
-
|
|
115
|
-
export const Streams: React.FC<{
|
|
116
|
-
targetFps?: number;
|
|
117
|
-
triggerToast?: () => void;
|
|
118
|
-
setIsRawSteamEnabledManually?: (value: boolean) => void;
|
|
119
|
-
isRawSteamEnabledManually?: boolean;
|
|
120
|
-
deviceOptions?: DeviceConfiguration | null;
|
|
121
|
-
}> = ({
|
|
122
|
-
targetFps,
|
|
123
|
-
triggerToast,
|
|
124
|
-
isRawSteamEnabledManually = true,
|
|
125
|
-
setIsRawSteamEnabledManually,
|
|
126
|
-
deviceOptions,
|
|
127
|
-
}) => {
|
|
128
|
-
const { changeWsUrl, columns, connectionType, wsUrl } = useData();
|
|
129
|
-
const { connected, topics, toggleTopic } = useConnection();
|
|
130
|
-
const [shouldDisplayHelper, setShouldDisplayHelper] = React.useState(false);
|
|
131
|
-
const [connecting, setConnecting] = React.useState(false);
|
|
132
|
-
|
|
133
|
-
const enabledTopics = React.useMemo(
|
|
134
|
-
() =>
|
|
135
|
-
makeColumns(
|
|
136
|
-
topics.filter((topic) => !topic.name.startsWith('_')).filter((topic) => topic.enabled),
|
|
137
|
-
columns,
|
|
138
|
-
),
|
|
139
|
-
[columns, topics],
|
|
140
|
-
);
|
|
141
|
-
|
|
142
|
-
const wsUrlRef = React.useRef<HTMLInputElement>(null);
|
|
143
|
-
|
|
144
|
-
const handleChangeUrl = React.useCallback(
|
|
145
|
-
() => wsUrlRef.current?.value && changeWsUrl(wsUrlRef.current.value),
|
|
146
|
-
[changeWsUrl],
|
|
147
|
-
);
|
|
148
|
-
|
|
149
|
-
const shouldSuggestUrlChange = React.useMemo(
|
|
150
|
-
() => window.location.hostname === 'localhost' || window.location.hostname === '127.0.0.1',
|
|
151
|
-
[],
|
|
152
|
-
);
|
|
153
|
-
|
|
154
|
-
React.useEffect(() => {
|
|
155
|
-
if (!shouldDisplayHelper && !shouldSuggestUrlChange) {
|
|
156
|
-
setTimeout(() => {
|
|
157
|
-
setShouldDisplayHelper(true);
|
|
158
|
-
}, 10_000);
|
|
159
|
-
}
|
|
160
|
-
}, [shouldDisplayHelper, shouldSuggestUrlChange]);
|
|
161
|
-
|
|
162
|
-
const sortedTopics = React.useMemo(
|
|
163
|
-
() => sortStreamsDefault(topics.filter((topic) => !topic.name.startsWith('_'))),
|
|
164
|
-
[topics],
|
|
165
|
-
);
|
|
166
|
-
|
|
167
|
-
// TODO: Store detections in url or global provider
|
|
168
|
-
// to persist on re-renders
|
|
169
|
-
return (
|
|
170
|
-
<PanelLayout>
|
|
171
|
-
{enabledTopics.length === 0 || enabledTopics[0].length === 0 ? (
|
|
172
|
-
<Flex full justify="center" align="center" direction="column" gap="sm">
|
|
173
|
-
<Header
|
|
174
|
-
text={
|
|
175
|
-
connected ? (
|
|
176
|
-
sortedTopics.length === 0 ? (
|
|
177
|
-
'DepthAI connected, awaiting device...'
|
|
178
|
-
) : (
|
|
179
|
-
<p>
|
|
180
|
-
To view stream(s), select it with Streams Button{' '}
|
|
181
|
-
<DropdownMenu>
|
|
182
|
-
<Tooltip content="Streams">
|
|
183
|
-
<DropdownMenuTrigger>
|
|
184
|
-
<Button icon={VisualizerIcon} variant="outline" colorVariant="white" />
|
|
185
|
-
</DropdownMenuTrigger>
|
|
186
|
-
</Tooltip>
|
|
187
|
-
<DropdownMenuContent>
|
|
188
|
-
{sortedTopics.map((topic, i) => (
|
|
189
|
-
<DropdownMenuCheckboxItem key={i} onClick={() => toggleTopic(topic.name)}>
|
|
190
|
-
{topic.name}
|
|
191
|
-
</DropdownMenuCheckboxItem>
|
|
192
|
-
))}
|
|
193
|
-
</DropdownMenuContent>
|
|
194
|
-
</DropdownMenu>{' '}
|
|
195
|
-
either here or in the top right corner
|
|
196
|
-
</p>
|
|
197
|
-
)
|
|
198
|
-
) : // TODO: connection details (state, errors, retries, webrtc stage)
|
|
199
|
-
connectionType === 'ws' ? (
|
|
200
|
-
'Connecting to DepthAI via WebSocket...'
|
|
201
|
-
) : (
|
|
202
|
-
'Connecting to DepthAI via WebRTC...'
|
|
203
|
-
)
|
|
204
|
-
}
|
|
205
|
-
/>
|
|
206
|
-
|
|
207
|
-
{!connected &&
|
|
208
|
-
(shouldSuggestUrlChange ? (
|
|
209
|
-
<>
|
|
210
|
-
<SubHeader
|
|
211
|
-
text={connectionType === 'ws' ? 'Use another URL?' : 'Connect via WebSocket?'}
|
|
212
|
-
/>
|
|
213
|
-
<form
|
|
214
|
-
onSubmit={(event) => {
|
|
215
|
-
event.stopPropagation();
|
|
216
|
-
event.preventDefault();
|
|
217
|
-
|
|
218
|
-
setConnecting(true);
|
|
219
|
-
|
|
220
|
-
handleChangeUrl();
|
|
221
|
-
}}
|
|
222
|
-
>
|
|
223
|
-
<Flex>
|
|
224
|
-
<Input
|
|
225
|
-
type="text"
|
|
226
|
-
ref={wsUrlRef}
|
|
227
|
-
placeholder={wsUrl}
|
|
228
|
-
roundedRight={0}
|
|
229
|
-
onChange={() => setConnecting(false)}
|
|
230
|
-
/>
|
|
231
|
-
<Button
|
|
232
|
-
type="submit"
|
|
233
|
-
label={connecting ? 'Connecting...' : 'Connect'}
|
|
234
|
-
style={{
|
|
235
|
-
borderTopLeftRadius: 0,
|
|
236
|
-
borderBottomLeftRadius: 0,
|
|
237
|
-
}}
|
|
238
|
-
/>
|
|
239
|
-
</Flex>
|
|
240
|
-
</form>
|
|
241
|
-
</>
|
|
242
|
-
) : (
|
|
243
|
-
shouldDisplayHelper && (
|
|
244
|
-
<NormalText text="Please check that you have the correct link to DepthAI Visualizer and that your device is running. You need a new link after any app or device restart." />
|
|
245
|
-
)
|
|
246
|
-
))}
|
|
247
|
-
<CTASubLabel />
|
|
248
|
-
</Flex>
|
|
249
|
-
) : (
|
|
250
|
-
<EnabledStreamsView
|
|
251
|
-
topics={enabledTopics}
|
|
252
|
-
targetFps={targetFps}
|
|
253
|
-
triggerToast={triggerToast}
|
|
254
|
-
isRawSteamEnabledManually={isRawSteamEnabledManually}
|
|
255
|
-
setIsRawSteamEnabledManually={setIsRawSteamEnabledManually}
|
|
256
|
-
deviceOptions={deviceOptions}
|
|
257
|
-
/>
|
|
258
|
-
)}
|
|
259
|
-
</PanelLayout>
|
|
260
|
-
);
|
|
261
|
-
};
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
|
|
2
|
-
export type DAIResponse<T = any> = {
|
|
3
|
-
data: T;
|
|
4
|
-
error: Error | string | null;
|
|
5
|
-
message: string | null;
|
|
6
|
-
status: number;
|
|
7
|
-
};
|
|
8
|
-
|
|
9
|
-
export const DAI_SERVICE_NAME = {
|
|
10
|
-
topicGroups: 'topicGroups',
|
|
11
|
-
pipelineSchema: 'pipelineSchema',
|
|
12
|
-
keyPressed: 'keyPressed',
|
|
13
|
-
// Devices
|
|
14
|
-
getDevices: 'getDevices',
|
|
15
|
-
startDevice: 'startDevice',
|
|
16
|
-
stopDevice: 'stopDevice',
|
|
17
|
-
getDeviceOptions: 'getDeviceOptions',
|
|
18
|
-
getFpsRange: 'getFpsRange',
|
|
19
|
-
// Configs
|
|
20
|
-
getSensors: 'getSensors',
|
|
21
|
-
setSensors: 'setSensors',
|
|
22
|
-
getStereoDepth: 'getStereoDepth',
|
|
23
|
-
setStereoDepth: 'setStereoDepth',
|
|
24
|
-
getStereoDepthPreset: 'getStereoDepthPreset',
|
|
25
|
-
setStereoDepthPreset: 'setStereoDepthPreset',
|
|
26
|
-
getStereoDepthCalibration: 'getStereoDepthCalibration',
|
|
27
|
-
setStereoDepthCalibration: 'setStereoDepthCalibration',
|
|
28
|
-
setIr: 'setIr',
|
|
29
|
-
setPointCloud: 'setPointCloud',
|
|
30
|
-
setThermal: 'setThermal',
|
|
31
|
-
getCameraIntrinsics: 'getCameraIntrinsics',
|
|
32
|
-
// Neural networks
|
|
33
|
-
getNeuralNetworks: 'getNeuralNetworks',
|
|
34
|
-
setNeuralNetwork: 'setNeuralNetwork',
|
|
35
|
-
getNeuralNetworkConfiguration: 'getNeuralNetworkConfiguration',
|
|
36
|
-
setNeuralNetworkConfiguration: 'setNeuralNetworkConfiguration',
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
export const SIGNALING_SERVER_URL = 'wss://signal.cloud.luxonis.com/session/';
|
|
40
|
-
export const ICE_SERVERS_API_ENDPOINT =
|
|
41
|
-
'https://signal.cloud-stg.luxonis.com/api/v1/turn-credentials';
|
|
42
|
-
|
|
43
|
-
export const DEFAULT_ICE_SERVERS: RTCIceServer[] = [
|
|
44
|
-
{ urls: ['stun:stun.l.google.com:19302', 'stun:stun1.l.google.com:19302'] },
|
|
45
|
-
];
|
package/src/constants/streams.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
export const StreamTypes = {
|
|
2
|
-
Encoded: 'H.264 Stream',
|
|
3
|
-
LeftEncoded: 'Left H.264 Stream',
|
|
4
|
-
RightEncoded: 'Right H.264 Stream',
|
|
5
|
-
Disparity: 'Disparity Stream',
|
|
6
|
-
Raw: 'Raw Stream',
|
|
7
|
-
LeftRaw: 'Left Raw Stream',
|
|
8
|
-
RightRaw: 'Right Raw Stream',
|
|
9
|
-
PointCloud: 'Point Cloud',
|
|
10
|
-
NeuralNetwork: 'Neural Network Stream',
|
|
11
|
-
_PointCloudColor: '_Point Cloud Color',
|
|
12
|
-
} as const;
|
package/src/constants/url.ts
DELETED