【发布时间】:2018-01-15 14:19:05
【问题描述】:
我想要鸟瞰我用相机拍摄的图像,以便只显示白色车道。分辨率为 640x480。这是图片 - 我所做的是首先应用直方图均衡器和二进制阈值,然后定义我将在 getPerspectiveTransform 中使用的 4 个坐标和结果坐标。
int bottom_leftx = 110;
int bottom_lefty = 480;
int upper_leftx = 260;
int upper_lefty = 120;
int upper_rightx = 410;
int upper_righty = 120;
int bottom_rightx = 560;
int bottom_righty = 480;
Point2f src_vertices[4];
src_vertices[0] = Point(bottom_leftx, bottom_lefty);
src_vertices[1] = Point(upper_leftx, upper_lefty);
src_vertices[2] = Point(upper_righty, upper_righty);
src_vertices[3] = Point(bottom_rightx, bottom_righty);
Point2f dst_vertices[4];
dst_vertices[0] = Point(0, 480);
dst_vertices[1] = Point(0, 0);
dst_vertices[2] = Point(640, 0);
dst_vertices[3] = Point(640, 480);
然后应用warpPerspective -
void getBirdView(Point2f *p1, Point2f *p2, const Mat& src, Mat& dst) {
Mat warpMatrix = getPerspectiveTransform(p1, p2);
warpPerspective(src, dst, warpMatrix, dst.size(), INTER_LINEAR, BORDER_CONSTANT);
}
那么白色是如何产生我的结果的呢?我哪里错了?
【问题讨论】: