错误:使用未声明的标识符'groupRectangles'

error: use of undeclared identifier 'groupRectangles'

本文关键字:groupRectangles 标识符 未声明 错误      更新时间:2023-10-16

我正在尝试在opencv中对多个矩形进行分组。以下是我正在做的

void groups_draw(Mat &src, vector<Rect> &groups)
{
    vector<Rect> rects;
    for (int i=(int)groups.size()-1; i>=0; i--)
     {
        rects.push_back(groups.at(i));
    }
    groupRectangles(rects, 1, 0.2);
}

但我得到以下错误:

错误:使用未声明的标识符"groupRectangles"

我文件中的标题是:

#include "opencv2/core/core.hpp"
#include  "opencv2/text.hpp"
#include  "opencv2/highgui.hpp"
#include  "opencv2/imgproc.hpp"
#include  <vector>
#include  <iostream>
#include  <iomanip>
using namespace std;
using namespace cv;
using namespace cv::text;

函数组Rectangles在opencv2/objdetect/objdetect.hpp中声明。

但是,您可以使用包含所有opencv2/opencv.hpp