for (int j(0); j < p; j++) { int _x = (int)vPixels.at<float>(j, 0); int _y = (int)vPixels.at<float>(j, 1); float x = vProjPixels.at<float>(j, 0); // x of * float y = vProjPixels.at<float>(j, 1); // y of * /* ----------- | A | B | ----*------ y | C | D | ----------- x */ float x_a = floor(x); float y_a = floor(y); float x_b = ceil(x); float y_b = floor(y); float x_c = floor(x); float y_c = ceil(y); float x_d = ceil(x); float y_d = ceil(y); float weight = 0;定义一些权值
if (IsInImage(x_a, y_a, imGrayAccumulator)) { if (abs(imMinDepth.at<float>(y_a, x_a) - matProjDepth.at<float>(j, 0)) < MIN_DEPTH_THRESHOLD) { weight = Area(x, x_a, y, y_a); imCounter.at<float>(int(y_a), int(x_a)) += weight; imGrayAccumulator.at<float>(int(y_a), int(x_a)) += weight * (float)refFrame.mImGray.at<uchar>(_y, _x); imDepthAccumulator.at<float>(int(y_a), int(x_a)) += weight * matProjDepth.at<float>(j, 0); mask.at<uchar>(int(y_a), int(x_a)) = 1; } else if ((imMinDepth.at<float>(y_a, x_a) - matProjDepth.at<float>(j, 0)) > 0) { weight = Area(x, x_a, y, y_a); imCounter.at<float>(int(y_a), int(x_a)) = weight; imGrayAccumulator.at<float>(int(y_a), int(x_a)) = weight * (float)refFrame.mImGray.at<uchar>(_y, _x); imDepthAccumulator.at<float>(int(y_a), int(x_a)) = weight * matProjDepth.at<float>(j, 0); mask.at<uchar>(int(y_a), int(x_a)) = 1; } imMinDepth.at<float>(y_a, x_a) = min(imMinDepth.at<float>(y_a, x_a), matProjDepth.at<float>(j, 0)); }这段 代码 是根据条件对不同的像素进行处理和更新。让我解释一下每个部分的含义:
总体来说,这段代码通过计算 权重 值并根据一些条件来更新不同图像和变量的值,可能涉及到图像深度处理、像素累积计算和掩码操作等
if (IsInImage(x_b, y_b, imGrayAccumulator) && (x_a != x_b)) { if (abs(imMinDepth.at<float>(y_b, x_b) - matProjDepth.at<float>(j, 0)) < MIN_DEPTH_THRESHOLD) { weight = Area(x, x_b, y, y_b); imCounter.at<float>(int(y_b), int(x_b)) += weight; imGrayAccumulator.at<float>(int(y_b), int(x_b)) += weight * (float)refFrame.mImGray.at<uchar>(_y, _x); imDepthAccumulator.at<float>(int(y_b), int(x_b)) += weight * matProjDepth.at<float>(j, 0); mask.at<uchar>(int(y_b), int(x_b)) = 1; } else if ((imMinDepth.at<float>(y_b, x_b) - matProjDepth.at<float>(j, 0)) > 0) { weight = Area(x, x_b, y, y_b); imCounter.at<float>(int(y_b), int(x_b)) = weight; imGrayAccumulator.at<float>(int(y_b), int(x_b)) = weight * (float)refFrame.mImGray.at<uchar>(_y, _x); imDepthAccumulator.at<float>(int(y_b), int(x_b)) = weight * matProjDepth.at<float>(j, 0); mask.at<uchar>(int(y_b), int(x_b)) = 1; } imMinDepth.at<float>(y_b, x_b) = min(imMinDepth.at<float>(y_b, x_b), matProjDepth.at<float>(j, 0)); }
这段代码与上一段代码 类 似,是根据条件对不同的像素进行处理和更新。让我解释一下每个部分的含义:
这段代码的作用是根据条件将权重值和一些变量更新到不同的图像和变量中。
if (IsInImage(x_c, y_c, imGrayAccumulator) && (y_a != y_c) && (x_b != x_c && y_b != y_c)) { if (abs(imMinDepth.at<float>(y_c, x_c) - matProjDepth.at<float>(j, 0)) < MIN_DEPTH_THRESHOLD) { weight = Area(x, x_c, y, y_c); imCounter.at<float>(int(y_c), int(x_c)) += weight; imGrayAccumulator.at<float>(int(y_c), int(x_c)) += weight * (float)refFrame.mImGray.at<uchar>(_y, _x); imDepthAccumulator.at<float>(int(y_c), int(x_c)) += weight * matProjDepth.at<float>(j, 0); mask.at<uchar>(int(y_c), int(x_c)) = 1; } else if ((imMinDepth.at<float>(y_c, x_c) - matProjDepth.at<float>(j, 0)) > 0) { weight = Area(x, x_c, y, y_c); imCounter.at<float>(int(y_c), int(x_c)) = weight; imGrayAccumulator.at<float>(int(y_c), int(x_c)) = weight * (float)refFrame.mImGray.at<uchar>(_y, _x); imDepthAccumulator.at<float>(int(y_c), int(x_c)) = weight * matProjDepth.at<float>(j, 0); mask.at<uchar>(int(y_c), int(x_c)) = 1; } imMinDepth.at<float>(y_c, x_c) = min(imMinDepth.at<float>(y_c, x_c), matProjDepth.at<float>(j, 0)); }
这段代码与前面类似,在特定的条件下对像素进行处理和更新。让我逐步解释每个部分的含义:
这段代码的作用是根据一系列条件对像素进行处理和更新,将权重值和一些变量更新到不同的图像和变量中。
if (IsInImage(x_d, y_d, imGrayAccumulator) && (x_a != x_d && y_a != y_d) && (y_b != y_d) && (x_d != x_c)) { if (abs(imMinDepth.at<float>(y_d, x_d) - matProjDepth.at<float>(j, 0)) < MIN_DEPTH_THRESHOLD) { weight = Area(x, x_d, y, y_d); imCounter.at<float>(int(y_d), int(x_d)) += weight; imGrayAccumulator.at<float>(int(y_d), int(x_d)) += weight * (float)refFrame.mImGray.at<uchar>(_y, _x); imDepthAccumulator.at<float>(int(y_d), int(x_d)) += weight * matProjDepth.at<float>(j, 0); mask.at<uchar>(int(y_d), int(x_d)) = 1; } else if ((imMinDepth.at<float>(y_d, x_d) - matProjDepth.at<float>(j, 0)) > 0) { weight = Area(x, x_d, y, y_d); imCounter.at<float>(int(y_d), int(x_d)) = weight; imGrayAccumulator.at<float>(int(y_d), int(x_d)) = weight * (float)refFrame.mImGray.at<uchar>(_y, _x); imDepthAccumulator.at<float>(int(y_d), int(x_d)) = weight * matProjDepth.at<float>(j, 0); mask.at<uchar>(int(y_d), int(x_d)) = 1; } imMinDepth.at<float>(y_d, x_d) = min(imMinDepth.at<float>(y_d, x_d), matProjDepth.at<float>(j, 0)); }
这段代码与前面的代码类似,也是在特定条件下对像素进行处理和更新。让我逐步解释每个部分的含义:
这段代码的作用是根据一系列条件对像素进行处理和更新,将权重值和一些变量更新到不同的图像和变量中。
imGrayAccumulator = imGrayAccumulator.mul(1 / imCounter); imDepthAccumulator = imDepthAccumulator.mul(1 / imCounter); imGrayAccumulator.convertTo(imGrayAccumulator, CV_8U); imGray = imGray * 0; imGrayAccumulator.copyTo(imGray, mask); imDepth = imDepth * 0; imDepthAccumulator.copyTo(imDepth, mask);
这段代码是对图像进行计算和复制操作的一部分。让我逐步解释每个部分的含义:
总体来说,这段代码的作用是通过除以 imCounter 图像中的像素值,将累加器图像中的值归一化。然后,将归一化后的结果复制到对应的目标图像 imGray 和 imDepth 上,同时只复制 mask 中对应位置为非零的像素值。这可能是为了根据某种条件选择性地更新目标图像中的像素值,并清空累加器图像以备下一轮计算使用。
免责声明:本文系网络转载或改编,未找到原创作者,版权归原作者所有。如涉及版权,请联系删