Skip to content

Free Motion Capture for Everyone πŸ’€βœ¨

TypeScript

some blinky bs :-/

jonmatthis240d65ff9b7f
diff --git a/freemocap-ui/src/components/viewport3d/ThreeJSCanvas3d.tsx b/freemocap-ui/src/components/viewport3d/ThreeJSCanvas3d.tsx
index 6c1c826c..90ee31b0 100644
--- a/freemocap-ui/src/components/viewport3d/ThreeJSCanvas3d.tsx
+++ b/freemocap-ui/src/components/viewport3d/ThreeJSCanvas3d.tsx
@@ -12,13 +12,18 @@ export function ThreeJSCanvas3d() {
const numPoints = Object.keys(latestPoints3d || {}).length
useEffect(() => {
- if (sphereRef.current) {
+ if (sphereRef.current && latestPoints3d) {
let index = 0;
- Object.entries(latestPoints3d || {}).forEach(([key, [x, y, z]]) => {
- const matrix = new Matrix4();
- matrix.setPosition(x, y, z);
- sphereRef.current?.setMatrixAt(index, matrix);
- index++
+ Object.entries(latestPoints3d).forEach(([key, point]) => {
+ if (point && point.length === 3) {
+ const [x, y, z] = point;
+ if (x !== null && y !== null && z !== null) {
+ const matrix = new Matrix4();
+ matrix.setPosition(x, y, z);
+ sphereRef.current?.setMatrixAt(index, matrix);
+ index++;
+ }
+ }
});
sphereRef.current.instanceMatrix.needsUpdate = true;
}
diff --git a/freemocap-ui/src/models/FrontendFramePayloadSchema.ts b/freemocap-ui/src/models/FrontendFramePayloadSchema.ts
index c57a3e39..cf11e94a 100644
--- a/freemocap-ui/src/models/FrontendFramePayloadSchema.ts
+++ b/freemocap-ui/src/models/FrontendFramePayloadSchema.ts
@@ -10,10 +10,10 @@ export const JpegImagesSchema = z.record(
export const Points3dSchema = z.record(
z.string(), // The keys are strings
z.tuple([
- z.number(), // X
- z.number(), // Y
- z.number() // Z
- ])
+ z.number().nullable(), // X can be a number or null
+ z.number().nullable(), // Y can be a number or null
+ z.number().nullable() // Z can be a number or null
+ ]).nullable() // The tuple itself can be null
);
// Update the FrontendFramePayloadSchema to use the defined schemas
diff --git a/freemocap/pipelines/mocap_pipeline/mocap_aggregation_node.py b/freemocap/pipelines/mocap_pipeline/mocap_aggregation_node.py
index 18e31f97..c717ebd8 100644
--- a/freemocap/pipelines/mocap_pipeline/mocap_aggregation_node.py
+++ b/freemocap/pipelines/mocap_pipeline/mocap_aggregation_node.py
@@ -18,6 +18,7 @@ logger = logging.getLogger(__name__)
class MocapAggregationLayerOutputData(BaseAggregationLayerOutputData):
pass
+
@dataclass
class MocapAggregationNodeConfig(BasePipelineStageConfig):
param2: int = 2
@@ -96,10 +97,21 @@ class MocapAggregationProcessNode(BaseAggregationNode):
raise ValueError(f"Frame numbers from camera nodes do not match! got {frame_numbers}")
latest_frame_number = frame_numbers.pop()
- points2d_by_camera = {camera_id: camera_node_output.mediapipe_observation.all_points_2d() for
- camera_id, camera_node_output in camera_node_incoming_data.items()}
- points3d: dict[str, tuple] = point_triangulator.triangulate(points2d_by_camera=points2d_by_camera,
- scale_by=0.001)
+ # TODO: Fix triangulation, until then just return the single camera 3d estimates
+ # points2d_by_camera = {camera_id: camera_node_output.mediapipe_observation.all_points(dimensions=2) for
+ # camera_id, camera_node_output in camera_node_incoming_data.items()}
+ # points3d: dict[str, tuple] = point_triangulator.triangulate(points2d_by_camera=points2d_by_camera,
+ # scale_by=0.001)
+
+ points3d = {}
+ for camera_id, camera_node_output in camera_node_incoming_data.items():
+ if camera_node_output is None:
+ raise ValueError(f"Camera {camera_id} did not send any data!")
+
+ points3d.update({f"Cam{camera_id}.{name}": tuple(point_xyz) for name, point_xyz in
+ camera_node_output.mediapipe_observation.all_points(dimensions=3, scale_by=0.001).items()})
+
+
output = MocapPipelineOutputData(camera_node_output=camera_node_incoming_data, # type: ignore
aggregation_layer_output=MocapAggregationLayerOutputData(
diff --git a/uv.lock b/uv.lock
index 2f03a110..9091c0f5 100644
--- a/uv.lock
+++ b/uv.lock
@@ -1513,7 +1513,7 @@ dependencies = [
[[package]]
name = "skellytracker"
version = "2024.9.1019"
-source = { git = "https://github.com/freemocap/skellytracker?branch=jon%2Fdevelopment#5a6cfe06ffc4cd4350769b11eb3789e9b27b90ee" }
+source = { git = "https://github.com/freemocap/skellytracker?branch=jon%2Fdevelopment#7016c3b7b9cbeda4a618b4f77a8f0e4285ea8105" }
dependencies = [
{ name = "mediapipe" },
{ name = "numpy" },