From 7b4ac89a8f4faf1e52c29eb1136928adc2b32435 Mon Sep 17 00:00:00 2001 From: Christoph Haag Date: Tue, 1 Dec 2020 00:34:50 +0100 Subject: [PATCH] t/hand: warn when rectification matrix doesn't match image matrix --- src/xrt/auxiliary/tracking/t_tracker_hand.cpp | 21 +++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/src/xrt/auxiliary/tracking/t_tracker_hand.cpp b/src/xrt/auxiliary/tracking/t_tracker_hand.cpp index 199203721..a40e502c7 100644 --- a/src/xrt/auxiliary/tracking/t_tracker_hand.cpp +++ b/src/xrt/auxiliary/tracking/t_tracker_hand.cpp @@ -155,16 +155,29 @@ process(TrackerHand &t, struct xrt_frame *xf) return; } + + int cols = xf->width / 2; + int rows = xf->height; + int stride = xf->stride; + + int rect_cols = t.view[0].undistort_rectify_map_x.cols; + int rect_rows = t.view[0].undistort_rectify_map_x.rows; + + if (cols != rect_cols || rows != rect_rows) { + fprintf(stderr, + "Error: %dx%d rectification matrix does not fit %dx%d " + "Image\n", + rect_cols, rect_rows, cols, rows); + return; + } + + // Create the debug frame if needed. t.debug.refresh(xf); t.view[0].keypoints.clear(); t.view[1].keypoints.clear(); - int cols = xf->width / 2; - int rows = xf->height; - int stride = xf->stride; - #if 0 cv::Mat l_grey(rows, cols, CV_8UC1, xf->data, stride); cv::Mat r_grey(rows, cols, CV_8UC1, xf->data + cols, stride);