【问题标题】:OpenCV: can projectPoints return negative values?OpenCV:projectPoints 可以返回负值吗?
【发布时间】:2013-08-14 03:25:38
【问题描述】:

我正在使用 cv::projectPoints 来获取 3D 点向量的对应像素。

这些点都彼此靠近。

问题在于,对于某些点,我得到了正确的像素坐标,但对于其他点,我得到了奇怪的负值,例如 -22599...

cv::projectPoints 返回负值是正常的还是我的代码中的错误?

void SingleCameraTriangulator::projectPointsToImage2(const std::vector< cv::Vec3d >& pointsGroup, const double scale, std::vector< Pixel >& pixels)
{
    cv::Vec3d 
        t2, r2;

    decomposeTransformation(*g_12_, r2, t2);

    cv::Mat imagePoints2;

    cv::projectPoints(pointsGroup, r2, t2, *camera_matrix_, *distortion_coefficients_, imagePoints2);

    for (std::size_t i = 0; i < imagePoints2.rows; i++)
    {
        cv::Vec2d pixel = imagePoints2.at<cv::Vec2d>(i);
        Pixel p;
        p.x_ = pixel[0];
        p.y_ = pixel[1];
        if ( (p.x_ < 0) || (p.x_ > ((1 / scale) * img_1_->cols)) || (p.y_ < 0) || (p.y_ > ((1/scale) * img_1_->rows)))
        {
            cv::Vec3d point = pointsGroup[i];
            std::cout << point << " - " << pixel << " - " << pixel*scale << "problema" << std::endl;
        }
        p.i_ = getBilinearInterpPix32f(*img_2_, scale * p.x_, scale * p.y_);

        pixels.push_back(p);
    }
}

提前感谢您的任何建议。

【问题讨论】:

    标签: c++ opencv triangulation projection-matrix


    【解决方案1】:

    reprojectImageTo3D(你用它来获取 3D 点吗?)为异常点提供大的 z 坐标(10000),所以我认为你的问题就在这里。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-02-23
      • 2021-09-21
      • 2018-09-05
      • 2012-02-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多