在OPENCV 3中找不到OpenCV 2 Delaunay三角剖分功能

Cannot find OpenCV 2 Delaunay triangulation functions in OpenCV 3

本文关键字:Delaunay 三角剖分 功能 OpenCV 找不到 OPENCV      更新时间:2023-10-16

我已经在Ubuntu 16上安装了OpenCV 3.2.0,并在NetBeans 8.2中使用C 开发。我正在尝试以下与OpenCV 2完美搭配的代码。

#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <cv.hpp>
#include <highgui.h>
#include <opencv2/core.hpp>
#include <opencv2/highgui.hpp>
#include <opencv2/imgproc.hpp>
#include <opencv2/imgcodecs.hpp>
#include <opencv2/videoio.hpp>
#include <opencv2/imgproc/imgproc_c.h>
#include <vector>
#include <set>
#include <map>
vector< Triangle > CTwoDTriangulation::delaunayDiv(const vector< Point_<T> > & vP, cv::Rect boundRect,
vector<Triangle>& triangles, int& numTriangles, bool lookRight)
{
CvSubdiv2D* subdiv;
int numPts=vP.size();
CvPoint newPoint;
CvMemStorage *storage;
storage = cvCreateMemStorage(0);
subdiv =  cvCreateSubdivDelaunay2D( boundRect, storage );
for (size_t e = 0; e<numPts; e++)
{
    newPoint=vP.at(e);
    if (newPoint.x<(boundRect.x + boundRect.width) && newPoint.y<(boundRect.y + boundRect.height))
                cvSubdivDelaunay2DInsert(subdiv, vP.at(e));
}
}

使用OpenCV 3,我会得到以下错误。

../../DraculaFiles/TwoDTriangulation.cpp:4278:60: error: there are no arguments to ‘cvCreateSubdivDelaunay2D’ that depend on a template parameter, so a declaration of ‘cvCreateSubdivDelaunay2D’ must be available [-fpermissive]
 subdiv =  cvCreateSubdivDelaunay2D( boundRect, storage );

我尝试键入cv ::,并查看可用的功能。但是我没有看到类似于CreateSubdivDelaunay2D。我还进行了Google搜索,以查看OpenCV 3中的CvCreateSubdivDelaunay2D的替换是什么,但找不到任何东西。

cvCreateSubdivDelaunay2D变成了遗产(delauny三角剖分的整个c-接口也是如此),并且已被删除。对于OPENCV 3,您可以参考cv::SubDiv类。