在我的一段代码中,如下的else分支无法调试也无法编译运行到。 else {
//qDebug() << "#### crop d x " << depth_color.cols << " d y " << depth_color.rows << " r x " << rgb_x << " r y" << rgb_y;
//640 * 400 或者 320* 200 与 rgb 640 * 480的对齐会走到这个分支
/*步骤1:将深度图按照rate的比例放大*/
Size dsize(depth_x * rate, depth_y * rate);
cv::resize(depth_color, depth_color, dsize);
cv::resize(depth_clone, depth_clone, dsize);
/*将640*400的depth copy到640*480 的rgb,并且将depth_color 与decodeRgb规整为一样大*/
Rect rect(0, 0, depth_x * rate, depth_y * rate);
cv::Mat depth_color_new(rgb_y, rgb_x, CV_8UC3, Scalar(0, 0, 0));
cv::Mat depth_clone_new(rgb_y, rgb_x, CV_16UC1, Scalar(0));
depth_color.copyTo(depth_color_new);
depth_clone.copyTo(depth_clone_new);
depth_color = depth_color_new.clone();
depth_clone = depth_clone_new.clone();
}
将上面代码修改为如下代码后:
else {
//qDebug() << "#### crop d x " << depth_color.cols << " d y " << depth_color.rows << " r x " << rgb_x << " r y" << rgb_y;
//640 * 400 或者 320* 200 与 rgb 640 * 480的对齐会走到这个分支
//步骤1:将深度图按照rate的比例放大 --------------------将注释语句从/**/修改为//
Size dsize(depth_x * rate, depth_y * rate);
cv::resize(depth_color, depth_color, dsize);
cv::resize(depth_clone, depth_clone, dsize);
//将640*400的depth copy到640*480 的rgb,并且将depth_color 与decodeRgb规整为一样大将注释语句从/**/修改为//
Rect rect(0, 0, depth_x * rate, depth_y * rate);
cv::Mat depth_color_new(rgb_y, rgb_x, CV_8UC3, Scalar(0, 0, 0));
cv::Mat depth_clone_new(rgb_y, rgb_x, CV_16UC1, Scalar(0));
depth_color.copyTo(depth_color_new);
depth_clone.copyTo(depth_clone_new);
depth_color = depth_color_new.clone();
depth_clone = depth_clone_new.clone();
}