ACMP,二维狄洛尼三角剖分

ACMP.cpp

std::vector<Triangle> ACMP::DelaunayTriangulation(const cv::Rect boundRC, const std::vector<cv::Point>& points)
{
    if (points.empty()) {
        return std::vector<Triangle>();
    }

    std::vector<Triangle> results;

    std::vector<cv::Vec6f> temp_results;
    cv::Subdiv2D subdiv2d(boundRC);
    for (const auto point : points) {
        subdiv2d.insert(cv::Point2f((float)point.x, (float)point.y));
    }
    subdiv2d.getTriangleList(temp_results);

    for (const auto temp_vec : temp_results) {
        cv::Point pt1((int)temp_vec[0], (int)temp_vec[1]);
        cv::Point pt2((int)temp_vec[2], (int)temp_vec[3]);
        cv::Point pt3((int)temp_vec[4], (int)temp_vec[5]);
        results.push_back(Triangle(pt1, pt2, pt3));
    }
    return results;
}

ACMP\main.h

struct Camera {
    float K[9];
    float R[9];
    float t[3];
    int height;
    int width;
    float depth_min;
    float depth_max;
};

struct Problem {
    int ref_image_id;
    std::vector<int> src_image_ids;
};
与COLMAP相似的组织方式,一张影像的PM过程就是ref_ID和众多邻域影像src_ID

struct Triangle {
    cv::Point pt1, pt2, pt3;
    Triangle (const cv::Point _pt1, const cv::Point _pt2, const cv::Point _pt3) : pt1(_pt1) , pt2(_pt2), pt3(_pt3) {}
};

struct PointList {
    float3 coord;
    float3 normal;
    float3 color;
};

cv::Rect矩形类参数设置

typedef struct CvRect 
  { 
  int x; /* 方形的左上角的x-坐标 */ 
  int y; /* 方形的左上角的y-坐标*/ 
  int width; /* 宽 */ 
  int height; /* 高 */ 
  }

example

int x = 50;
int y = 50;
int width = 50;
int height = 50;
cv::Rect rect(x, y, width, height);

注意四个参数不是矩形的左上角和右下角的坐标,矩形的大小为 ( width - x + 1 ) * (height - y + 1 ),即矩形内左上角坐标为(x,y),而右下角坐标为(height-1,width-1)。

猜你喜欢

转载自blog.csdn.net/rdw1246010462/article/details/115918809