【发布时间】:2019-08-15 15:56:52
【问题描述】:
我想通过使用 warpPerspective 使用 haarcascade 分类器将图像叠加在先前检测到的项目上。图像似乎已正确缩放,但图像的其余部分变为黑色。
我曾尝试修改源图像和目标图像的透明度,但不知道是否成功。
Rect r = boundingRects.carRects.at(i).rect; // points of the object in the image.
vector<Point2d> imagePoints;
imagePoints.push_back(Point2d(r.x, r.y));
imagePoints.push_back(Point2d(r.x + r.width, r.y));
imagePoints.push_back(Point2d(r.x + r.width, r.y+ r.height));
imagePoints.push_back(Point2d(r.x, r.y + r.height));
dimensions.push_back(Point2d(0, 0)); // dimensions of the source image
dimensions.push_back(Point2d(899, 0));
dimensions.push_back(Point2d(899, 539));
dimensions.push_back(Point2d(0, 539));
H = findHomography(carAlertObject.dimensions, imagePoints); // get homography matrix
warpPerspective(carAlertObject.img, img, H,img.size()); // carAlertObject contains the source image and dimensions, img is the destination image
【问题讨论】:
-
可以添加图片吗?
-
我添加了使用和不使用 warpPerspective() 的图像。
标签: c++ opencv homography