From 1de7eb7cc90d62a081378bf64f292d2ac7879861 Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Fri, 24 Apr 2020 19:59:54 +0100 Subject: [PATCH] t/calibration: Add support for XRT_FORMAT_UYVY422 --- src/xrt/auxiliary/tracking/t_calibration.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/xrt/auxiliary/tracking/t_calibration.cpp b/src/xrt/auxiliary/tracking/t_calibration.cpp index 4ee48f060..e7e665f00 100644 --- a/src/xrt/auxiliary/tracking/t_calibration.cpp +++ b/src/xrt/auxiliary/tracking/t_calibration.cpp @@ -1105,6 +1105,24 @@ process_frame_yuyv(class Calibration &c, struct xrt_frame *xf) cv::cvtColor(data_full, c.gray, cv::COLOR_YUV2GRAY_YUYV); } +XRT_NO_INLINE static void +process_frame_uyvy(class Calibration &c, struct xrt_frame *xf) +{ + /* + * Cleverly extract the different channels. + * Cr/Cb are extracted at half width. + */ + int w = (int)xf->width; + int h = (int)xf->height; + + cv::Mat data_full(h, w, CV_8UC2, xf->data, xf->stride); + ensure_buffers_are_allocated(c, data_full.rows, data_full.cols); + c.gui.frame->source_sequence = xf->source_sequence; + + cv::cvtColor(data_full, c.gui.rgb, cv::COLOR_YUV2RGB_UYVY); + cv::cvtColor(data_full, c.gray, cv::COLOR_YUV2GRAY_UYVY); +} + XRT_NO_INLINE static void process_load_image(class Calibration &c, struct xrt_frame *xf) { @@ -1184,6 +1202,7 @@ t_calibration_frame(struct xrt_frame_sink *xsink, struct xrt_frame *xf) switch (xf->format) { case XRT_FORMAT_YUV888: process_frame_yuv(c, xf); break; case XRT_FORMAT_YUYV422: process_frame_yuyv(c, xf); break; + case XRT_FORMAT_UYVY422: process_frame_uyvy(c, xf); break; case XRT_FORMAT_L8: process_frame_l8(c, xf); break; default: P("ERROR: Bad format '%s'", u_format_str(xf->format));