我想通过使用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
答案 0 :(得分:0)
问题是我必须使用蒙版图像应用warpPerspective函数,然后对该图像与目标图像进行求和才能得到正确的结果。