From ae6b0ad44528b2dbebf8be6e4d092f4ab97418c8 Mon Sep 17 00:00:00 2001 From: Ryan Pavlik Date: Tue, 16 May 2023 16:59:05 -0500 Subject: [PATCH] st/p,t/common: Protect tracker-creation calls --- src/xrt/state_trackers/prober/p_tracking.c | 10 ++++++---- src/xrt/targets/common/target_builder_rgb_tracking.c | 6 ++++-- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/xrt/state_trackers/prober/p_tracking.c b/src/xrt/state_trackers/prober/p_tracking.c index a0efe7599..6b100af90 100644 --- a/src/xrt/state_trackers/prober/p_tracking.c +++ b/src/xrt/state_trackers/prober/p_tracking.c @@ -170,11 +170,13 @@ p_factory_ensure_frameserver(struct p_factory *fact) struct xrt_colour_rgb_f32 rgb[2] = {{1.f, 0.f, 0.f}, {1.f, 0.f, 1.f}}; // We create the two psmv trackers up front, but don't start them. - // clang-format off +#if defined(XRT_HAVE_OPENCV) && defined(XRT_BUILD_DRIVER_PSMV) t_psmv_create(&fact->xfctx, &rgb[0], fact->data, &fact->xtmv[0], &xsinks[0]); t_psmv_create(&fact->xfctx, &rgb[1], fact->data, &fact->xtmv[1], &xsinks[1]); +#endif +#if defined(XRT_HAVE_OPENCV) && defined(XRT_BUILD_DRIVER_PSVR) t_psvr_create(&fact->xfctx, fact->data, &fact->xtvr, &xsinks[2]); - // clang-format on +#endif // Setup origin to the common one. fact->xtvr->origin = &fact->origin; @@ -318,7 +320,7 @@ p_factory_ensure_slam_frameserver(struct p_factory *fact) static int p_factory_create_tracked_psmv(struct xrt_tracking_factory *xfact, struct xrt_tracked_psmv **out_xtmv) { -#ifdef XRT_HAVE_OPENCV +#if defined(XRT_HAVE_OPENCV) && defined(XRT_BUILD_DRIVER_PSMV) struct p_factory *fact = p_factory(xfact); struct xrt_tracked_psmv *xtmv = NULL; @@ -347,7 +349,7 @@ p_factory_create_tracked_psmv(struct xrt_tracking_factory *xfact, struct xrt_tra static int p_factory_create_tracked_psvr(struct xrt_tracking_factory *xfact, struct xrt_tracked_psvr **out_xtvr) { -#ifdef XRT_HAVE_OPENCV +#if defined(XRT_HAVE_OPENCV) && defined(XRT_BUILD_DRIVER_PSVR) struct p_factory *fact = p_factory(xfact); struct xrt_tracked_psvr *xtvr = NULL; diff --git a/src/xrt/targets/common/target_builder_rgb_tracking.c b/src/xrt/targets/common/target_builder_rgb_tracking.c index 0cfbc2a82..0fdca3a86 100644 --- a/src/xrt/targets/common/target_builder_rgb_tracking.c +++ b/src/xrt/targets/common/target_builder_rgb_tracking.c @@ -130,11 +130,13 @@ setup_pipeline(struct xrt_prober *xp, struct build_state *build) struct xrt_colour_rgb_f32 rgb[2] = {{1.f, 0.f, 0.f}, {1.f, 0.f, 1.f}}; // We create the two psmv trackers up front, but don't start them. - // clang-format off +#if defined(XRT_HAVE_OPENCV) && defined(XRT_BUILD_DRIVER_PSMV) t_psmv_create(build->xfctx, &rgb[0], data, &build->psmv_red, &xsinks[0]); t_psmv_create(build->xfctx, &rgb[1], data, &build->psmv_purple, &xsinks[1]); +#endif +#if defined(XRT_HAVE_OPENCV) && defined(XRT_BUILD_DRIVER_PSVR) t_psvr_create(build->xfctx, data, &build->psvr, &xsinks[2]); - // clang-format on +#endif // No longer needed. t_stereo_camera_calibration_reference(&data, NULL);