在目标 c opencv 中没有可行的重载"="



我正在尝试使用此 openCV 文档在图像轮廓上查找边界框,但收到此错误

No viable overloaded '='

boundRect[i] = cv::boundingRect( contours_poly[i] )

cv::Mat mat;
UIImageToMat(image, mat);
cv::Mat gray;
printf("number of channels = %d",mat.channels());
cv::cvtColor(mat, gray, cv::COLOR_BGRA2BGR);
cv::Mat bin;
cv::threshold(gray, bin, 0, 1, cv::THRESH_BINARY);
std::vector<std::vector<Point> > contours;
std::vector<std::vector<Point> > hierarchy;
cv::findContours(bin, contours, hierarchy, cv::RETR_TREE, cv::CHAIN_APPROX_SIMPLE);
std::vector<std::vector<Point> > contours_poly( contours.size() );
std::vector<Rect> boundRect( contours.size() );

for( size_t i = 0; i < contours.size(); i++ )
{
cv::approxPolyDP( contours[i], contours_poly[i], 3, true );
boundRect[i] = cv::boundingRect( contours_poly[i] );//Getting Error here

}

函数cv::boundingRect()返回cv::Rect值。改变

std::vector<Rect> boundRect( contours.size() );

std::vector<cv::Rect> boundRect( contours.size() );

最新更新