-1

I have installed OpenCV 3.2.0 on Ubuntu 16 and am developing using C++ in NetBeans 8.2. I am trying the following code which worked perfectly with 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));
}
}

With OpenCV 3, I get the following errors.

../../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 );

I tried typing cv:: and seeing what functions are available. But I saw nothing similar to CreateSubdivDelaunay2D. I have also done a Google search to see what has replaced cvCreateSubdivDelaunay2D in OpenCV 3 but could not find anything.

OtagoHarbour
  • 3,969
  • 6
  • 43
  • 81

1 Answers1

1

cvCreateSubdivDelaunay2D became legacy (so does the whole c-interface for delauny triangulation) and has been removed. For OpenCV 3 you can refer to the cv::SubDiv class instead.

Marcus
  • 922
  • 6
  • 21
  • That's helpful to know. I found cv::Subdiv2D().initDelaunay(Rect rect); but it is a void function. I could not find any functions that return type CvSubdiv2D* from cv: :Subdiv2D() I was also unable to cast cv::Subdiv2D() to CvSubdiv2D* . Thanks, – OtagoHarbour Mar 12 '17 at 23:57
  • I assume the example code under the linked duplicate may help you? – Marcus Mar 13 '17 at 00:04
  • Yes it does. Thanks, – OtagoHarbour Mar 13 '17 at 00:08