diff --git a/src/xrt/auxiliary/tracking/t_calibration.cpp b/src/xrt/auxiliary/tracking/t_calibration.cpp index 8957d7007..84fb1f652 100644 --- a/src/xrt/auxiliary/tracking/t_calibration.cpp +++ b/src/xrt/auxiliary/tracking/t_calibration.cpp @@ -138,6 +138,8 @@ public: //! Is the camera fisheye. bool use_fisheye = false; + //! From parameters. + bool stereo_sbs = false; //! Should we clear the frame. bool clear_frame = false; @@ -572,7 +574,6 @@ process_stereo_samples(class Calibration &c, int cols, int rows) flags); // flags } - // Validate that nothing has been re-allocated. assert(wrapped.isDataStorageValid()); @@ -1117,9 +1118,9 @@ process_load_image(class Calibration &c, struct xrt_frame *xf) refresh_gui_frame(c, c.gray.rows, c.gray.cols); cv::cvtColor(c.gray, c.gui.rgb, cv::COLOR_GRAY2RGB); -#if 0 - xf->stereo_format = XRT_STEREO_FORMAT_SBS; -#endif + if (c.stereo_sbs) { + xf->stereo_format = XRT_STEREO_FORMAT_SBS; + } // Call the normal frame processing now. make_calibration_frame(c, xf); @@ -1202,6 +1203,7 @@ t_calibration_stereo_create(struct xrt_frame_context *xfctx, // Copy the parameters. c.use_fisheye = params->use_fisheye; + c.stereo_sbs = params->stereo_sbs; c.board.pattern = params->pattern; switch (params->pattern) { case T_BOARD_CHECKERS: diff --git a/src/xrt/auxiliary/tracking/t_tracking.h b/src/xrt/auxiliary/tracking/t_tracking.h index dac7112f3..5d492fb67 100644 --- a/src/xrt/auxiliary/tracking/t_tracking.h +++ b/src/xrt/auxiliary/tracking/t_tracking.h @@ -327,7 +327,8 @@ struct t_calibration_params { //! Should we use fisheye version of the calibration functions. bool use_fisheye; - + //! Is the camera a stereo sbs camera, mostly for image loading. + bool stereo_sbs; //! What type of pattern are we using for calibration. enum t_board_pattern pattern; @@ -382,7 +383,11 @@ struct t_calibration_params static inline void t_calibration_params_default(struct t_calibration_params *p) { - p->use_fisheye = true; + // Camera config. + p->use_fisheye = false; + p->stereo_sbs = true; + + // Which board should we calibrate against. p->pattern = T_BOARD_CHECKERS; // Checker board. diff --git a/src/xrt/drivers/v4l2/v4l2_driver.c b/src/xrt/drivers/v4l2/v4l2_driver.c index ac736a416..fbd2682f2 100644 --- a/src/xrt/drivers/v4l2/v4l2_driver.c +++ b/src/xrt/drivers/v4l2/v4l2_driver.c @@ -410,29 +410,6 @@ v4l2_setup_userptr_buffer(struct v4l2_fs *vid, * */ -static void -v4l2_quirk_apply_ps4(struct v4l2_fs *vid, struct v4l2_source_descriptor *desc) -{ - desc->offset = 32 + 64; - desc->base.stereo_format = XRT_STEREO_FORMAT_SBS; - - switch (desc->stream.width) { - case 3448: - desc->base.width = 1280 * 2; - desc->base.height = 800; - break; - case 1748: - desc->base.width = 640 * 2; - desc->base.height = 400; - break; - case 898: - desc->base.width = 320 * 2; - desc->base.height = 192; - break; - default: break; - } -} - static struct v4l2_source_descriptor * v4l2_add_descriptor(struct v4l2_fs *vid) { @@ -524,14 +501,6 @@ v4l2_list_modes_size(struct v4l2_fs *vid, desc->base.format = format; desc->base.width = desc->stream.width; desc->base.height = desc->stream.height; - - /* - * Apply any quirks to the modes. - */ - - if (vid->quirks.ps4_cam) { - v4l2_quirk_apply_ps4(vid, desc); - } } static void diff --git a/src/xrt/state_trackers/gui/gui_scene_calibrate.c b/src/xrt/state_trackers/gui/gui_scene_calibrate.c index 9bfd4c12d..eb7277ed3 100644 --- a/src/xrt/state_trackers/gui/gui_scene_calibrate.c +++ b/src/xrt/state_trackers/gui/gui_scene_calibrate.c @@ -39,6 +39,8 @@ struct calibration_scene struct xrt_frame_context *xfctx; struct xrt_fs *xfs; size_t mode; + + bool ps4_cam; }; @@ -168,14 +170,22 @@ scene_render_select(struct gui_scene *scene, struct gui_program *p) igBegin("Params", NULL, 0); // clang-format off - igCheckbox("Fisheye Camera", &cs->params.use_fisheye); + if (!cs->ps4_cam) { + igCheckbox("Fisheye Camera", &cs->params.use_fisheye); + igCheckbox("Stereo (Side-By-Side) Camera", &cs->params.stereo_sbs); + } + igCheckbox("PS4 Camera", &cs->ps4_cam); + if (cs->ps4_cam) { + cs->params.use_fisheye = false; + cs->params.stereo_sbs = true; + } igSeparator(); igCheckbox("Mirror on-screen preview", &cs->params.mirror_rgb_image); igCheckbox("Save images", &cs->params.save_images); igSeparator(); - igCheckbox("Load images (mono only)", &cs->params.load.enabled); + igCheckbox("Load images", &cs->params.load.enabled); if (cs->params.load.enabled) { igInputInt("# images", &cs->params.load.num_images, 1, 5, 0); } @@ -239,6 +249,8 @@ scene_render_select(struct gui_scene *scene, struct gui_program *p) u_sink_create_to_yuv_or_yuyv(cs->xfctx, cali, &cali); u_sink_queue_create(cs->xfctx, cali, &cali); u_sink_split_create(cs->xfctx, raw, cali, &cali); + u_sink_quirk_create(cs->xfctx, cali, cs->params.stereo_sbs, cs->ps4_cam, + &cali); // Now that we have setup a node graph, start it. xrt_fs_stream_start(cs->xfs, cali, cs->mode); @@ -283,6 +295,26 @@ gui_scene_calibrate(struct gui_program *p, #ifdef XRT_HAVE_OPENCV t_calibration_params_default(&cs->params); + + /* + * Pre-quirk some known cameras. + */ + + // PS4 Camera. + if (strcmp(xfs->name, "USB Camera-OV580: USB Camera-OV") == 0) { + // It's one speedy camera. :) + cs->params.num_cooldown_frames = 240; + cs->params.num_wait_for = 10; + cs->params.stereo_sbs = true; + cs->ps4_cam = true; + } + + // Valve Index and ELP Stereo Camera. + if (strcmp(xfs->name, "3D Camera: eTronVideo") == 0 || + strcmp(xfs->name, "3D USB Camera: 3D USB Camera") == 0) { + cs->params.stereo_sbs = true; + cs->params.use_fisheye = true; + } #endif gui_scene_push_front(p, &cs->base); } diff --git a/src/xrt/state_trackers/prober/p_tracking.c b/src/xrt/state_trackers/prober/p_tracking.c index fdd70cc61..79cdf1bc3 100644 --- a/src/xrt/state_trackers/prober/p_tracking.c +++ b/src/xrt/state_trackers/prober/p_tracking.c @@ -148,6 +148,9 @@ p_factory_ensure_frameserver(struct p_factory *fact) // Put a queue before it to multi-thread the filter. u_sink_queue_create(&fact->xfctx, xsink, &xsink); + // Hardcoded quirk sink. + u_sink_quirk_create(&fact->xfctx, xsink, true, true, &xsink); + // Start the stream now. xrt_fs_stream_start(fact->xfs, xsink, 1); }