EstervQrCode 1.1.1
Library for qr code manipulation
Classes | Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
cv::Subdiv2D Class Reference

#include <imgproc.hpp>

Classes

struct  QuadEdge
 
struct  Vertex
 

Public Types

enum  {
  PTLOC_ERROR = -2 , PTLOC_OUTSIDE_RECT = -1 , PTLOC_INSIDE = 0 , PTLOC_VERTEX = 1 ,
  PTLOC_ON_EDGE = 2
}
 
enum  {
  NEXT_AROUND_ORG = 0x00 , NEXT_AROUND_DST = 0x22 , PREV_AROUND_ORG = 0x11 , PREV_AROUND_DST = 0x33 ,
  NEXT_AROUND_LEFT = 0x13 , NEXT_AROUND_RIGHT = 0x31 , PREV_AROUND_LEFT = 0x20 , PREV_AROUND_RIGHT = 0x02
}
 

Public Member Functions

CV_WRAP Subdiv2D ()
 
CV_WRAP Subdiv2D (Rect rect)
 
CV_WRAP void initDelaunay (Rect rect)
 Creates a new empty Delaunay subdivision. More...
 
CV_WRAP int insert (Point2f pt)
 Insert a single point into a Delaunay triangulation. More...
 
CV_WRAP void insert (const std::vector< Point2f > &ptvec)
 Insert multiple points into a Delaunay triangulation. More...
 
CV_WRAP int locate (Point2f pt, CV_OUT int &edge, CV_OUT int &vertex)
 Returns the location of a point within a Delaunay triangulation. More...
 
CV_WRAP int findNearest (Point2f pt, CV_OUT Point2f *nearestPt=0)
 Finds the subdivision vertex closest to the given point. More...
 
CV_WRAP void getEdgeList (CV_OUT std::vector< Vec4f > &edgeList) const
 Returns a list of all edges. More...
 
CV_WRAP void getLeadingEdgeList (CV_OUT std::vector< int > &leadingEdgeList) const
 Returns a list of the leading edge ID connected to each triangle. More...
 
CV_WRAP void getTriangleList (CV_OUT std::vector< Vec6f > &triangleList) const
 Returns a list of all triangles. More...
 
CV_WRAP void getVoronoiFacetList (const std::vector< int > &idx, CV_OUT std::vector< std::vector< Point2f > > &facetList, CV_OUT std::vector< Point2f > &facetCenters)
 Returns a list of all Voronoi facets. More...
 
CV_WRAP Point2f getVertex (int vertex, CV_OUT int *firstEdge=0) const
 Returns vertex location from vertex ID. More...
 
CV_WRAP int getEdge (int edge, int nextEdgeType) const
 Returns one of the edges related to the given edge. More...
 
CV_WRAP int nextEdge (int edge) const
 Returns next edge around the edge origin. More...
 
CV_WRAP int rotateEdge (int edge, int rotate) const
 Returns another edge of the same quad-edge. More...
 
CV_WRAP int symEdge (int edge) const
 
CV_WRAP int edgeOrg (int edge, CV_OUT Point2f *orgpt=0) const
 Returns the edge origin. More...
 
CV_WRAP int edgeDst (int edge, CV_OUT Point2f *dstpt=0) const
 Returns the edge destination. More...
 

Protected Member Functions

int newEdge ()
 
void deleteEdge (int edge)
 
int newPoint (Point2f pt, bool isvirtual, int firstEdge=0)
 
void deletePoint (int vtx)
 
void setEdgePoints (int edge, int orgPt, int dstPt)
 
void splice (int edgeA, int edgeB)
 
int connectEdges (int edgeA, int edgeB)
 
void swapEdges (int edge)
 
int isRightOf (Point2f pt, int edge) const
 
void calcVoronoi ()
 
void clearVoronoi ()
 
void checkSubdiv () const
 

Protected Attributes

std::vector< Vertexvtx
 All of the vertices. More...
 
std::vector< QuadEdgeqedges
 All of the edges. More...
 
int freeQEdge
 
int freePoint
 
bool validGeometry
 
int recentEdge
 
Point2f topLeft
 Top left corner of the bounding rect. More...
 
Point2f bottomRight
 Bottom right corner of the bounding rect. More...
 

Member Enumeration Documentation

◆ anonymous enum

anonymous enum

Subdiv2D point location cases

Enumerator
PTLOC_ERROR 

Point location error.

PTLOC_OUTSIDE_RECT 

Point outside the subdivision bounding rect.

PTLOC_INSIDE 

Point inside some facet.

PTLOC_VERTEX 

Point coincides with one of the subdivision vertices.

PTLOC_ON_EDGE 

Point on some edge.

◆ anonymous enum

anonymous enum

Subdiv2D edge type navigation (see: getEdge())

Enumerator
NEXT_AROUND_ORG 
NEXT_AROUND_DST 
PREV_AROUND_ORG 
PREV_AROUND_DST 
NEXT_AROUND_LEFT 
NEXT_AROUND_RIGHT 
PREV_AROUND_LEFT 
PREV_AROUND_RIGHT 

Constructor & Destructor Documentation

◆ Subdiv2D() [1/2]

CV_WRAP cv::Subdiv2D::Subdiv2D ( )

creates an empty Subdiv2D object. To create a new empty Delaunay subdivision you need to use the initDelaunay function.

◆ Subdiv2D() [2/2]

CV_WRAP cv::Subdiv2D::Subdiv2D ( Rect  rect)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Parameters
rectRectangle that includes all of the 2D points that are to be added to the subdivision.

The function creates an empty Delaunay subdivision where 2D points can be added using the function insert() . All of the points to be added must be within the specified rectangle, otherwise a runtime error is raised.

Member Function Documentation

◆ calcVoronoi()

void cv::Subdiv2D::calcVoronoi ( )
protected

◆ checkSubdiv()

void cv::Subdiv2D::checkSubdiv ( ) const
protected

◆ clearVoronoi()

void cv::Subdiv2D::clearVoronoi ( )
protected

◆ connectEdges()

int cv::Subdiv2D::connectEdges ( int  edgeA,
int  edgeB 
)
protected

◆ deleteEdge()

void cv::Subdiv2D::deleteEdge ( int  edge)
protected

◆ deletePoint()

void cv::Subdiv2D::deletePoint ( int  vtx)
protected

◆ edgeDst()

CV_WRAP int cv::Subdiv2D::edgeDst ( int  edge,
CV_OUT Point2f dstpt = 0 
) const

Returns the edge destination.

Parameters
edgeSubdivision edge ID.
dstptOutput vertex location.
Returns
vertex ID.

◆ edgeOrg()

CV_WRAP int cv::Subdiv2D::edgeOrg ( int  edge,
CV_OUT Point2f orgpt = 0 
) const

Returns the edge origin.

Parameters
edgeSubdivision edge ID.
orgptOutput vertex location.
Returns
vertex ID.

◆ findNearest()

CV_WRAP int cv::Subdiv2D::findNearest ( Point2f  pt,
CV_OUT Point2f nearestPt = 0 
)

Finds the subdivision vertex closest to the given point.

Parameters
ptInput point.
nearestPtOutput subdivision vertex point.

The function is another function that locates the input point within the subdivision. It finds the subdivision vertex that is the closest to the input point. It is not necessarily one of vertices of the facet containing the input point, though the facet (located using locate() ) is used as a starting point.

Returns
vertex ID.

◆ getEdge()

CV_WRAP int cv::Subdiv2D::getEdge ( int  edge,
int  nextEdgeType 
) const

Returns one of the edges related to the given edge.

Parameters
edgeSubdivision edge ID.
nextEdgeTypeParameter specifying which of the related edges to return. The following values are possible:
  • NEXT_AROUND_ORG next around the edge origin ( eOnext on the picture below if e is the input edge)
  • NEXT_AROUND_DST next around the edge vertex ( eDnext )
  • PREV_AROUND_ORG previous around the edge origin (reversed eRnext )
  • PREV_AROUND_DST previous around the edge destination (reversed eLnext )
  • NEXT_AROUND_LEFT next around the left facet ( eLnext )
  • NEXT_AROUND_RIGHT next around the right facet ( eRnext )
  • PREV_AROUND_LEFT previous around the left facet (reversed eOnext )
  • PREV_AROUND_RIGHT previous around the right facet (reversed eDnext )

sample output

Returns
edge ID related to the input edge.

◆ getEdgeList()

CV_WRAP void cv::Subdiv2D::getEdgeList ( CV_OUT std::vector< Vec4f > &  edgeList) const

Returns a list of all edges.

Parameters
edgeListOutput vector.

The function gives each edge as a 4 numbers vector, where each two are one of the edge vertices. i.e. org_x = v[0], org_y = v[1], dst_x = v[2], dst_y = v[3].

◆ getLeadingEdgeList()

CV_WRAP void cv::Subdiv2D::getLeadingEdgeList ( CV_OUT std::vector< int > &  leadingEdgeList) const

Returns a list of the leading edge ID connected to each triangle.

Parameters
leadingEdgeListOutput vector.

The function gives one edge ID for each triangle.

◆ getTriangleList()

CV_WRAP void cv::Subdiv2D::getTriangleList ( CV_OUT std::vector< Vec6f > &  triangleList) const

Returns a list of all triangles.

Parameters
triangleListOutput vector.

The function gives each triangle as a 6 numbers vector, where each two are one of the triangle vertices. i.e. p1_x = v[0], p1_y = v[1], p2_x = v[2], p2_y = v[3], p3_x = v[4], p3_y = v[5].

◆ getVertex()

CV_WRAP Point2f cv::Subdiv2D::getVertex ( int  vertex,
CV_OUT int *  firstEdge = 0 
) const

Returns vertex location from vertex ID.

Parameters
vertexvertex ID.
firstEdgeOptional. The first edge ID which is connected to the vertex.
Returns
vertex (x,y)

◆ getVoronoiFacetList()

CV_WRAP void cv::Subdiv2D::getVoronoiFacetList ( const std::vector< int > &  idx,
CV_OUT std::vector< std::vector< Point2f > > &  facetList,
CV_OUT std::vector< Point2f > &  facetCenters 
)

Returns a list of all Voronoi facets.

Parameters
idxVector of vertices IDs to consider. For all vertices you can pass empty vector.
facetListOutput vector of the Voronoi facets.
facetCentersOutput vector of the Voronoi facets center points.

◆ initDelaunay()

CV_WRAP void cv::Subdiv2D::initDelaunay ( Rect  rect)

Creates a new empty Delaunay subdivision.

Parameters
rectRectangle that includes all of the 2D points that are to be added to the subdivision.

◆ insert() [1/2]

CV_WRAP void cv::Subdiv2D::insert ( const std::vector< Point2f > &  ptvec)

Insert multiple points into a Delaunay triangulation.

Parameters
ptvecPoints to insert.

The function inserts a vector of points into a subdivision and modifies the subdivision topology appropriately.

◆ insert() [2/2]

CV_WRAP int cv::Subdiv2D::insert ( Point2f  pt)

Insert a single point into a Delaunay triangulation.

Parameters
ptPoint to insert.

The function inserts a single point into a subdivision and modifies the subdivision topology appropriately. If a point with the same coordinates exists already, no new point is added.

Returns
the ID of the point.
Note
If the point is outside of the triangulation specified rect a runtime error is raised.

◆ isRightOf()

int cv::Subdiv2D::isRightOf ( Point2f  pt,
int  edge 
) const
protected

◆ locate()

CV_WRAP int cv::Subdiv2D::locate ( Point2f  pt,
CV_OUT int &  edge,
CV_OUT int &  vertex 
)

Returns the location of a point within a Delaunay triangulation.

Parameters
ptPoint to locate.
edgeOutput edge that the point belongs to or is located to the right of it.
vertexOptional output vertex the input point coincides with.

The function locates the input point within the subdivision and gives one of the triangle edges or vertices.

Returns
an integer which specify one of the following five cases for point location:
  • The point falls into some facet. The function returns PTLOC_INSIDE and edge will contain one of edges of the facet.
  • The point falls onto the edge. The function returns PTLOC_ON_EDGE and edge will contain this edge.
  • The point coincides with one of the subdivision vertices. The function returns PTLOC_VERTEX and vertex will contain a pointer to the vertex.
  • The point is outside the subdivision reference rectangle. The function returns PTLOC_OUTSIDE_RECT and no pointers are filled.
  • One of input arguments is invalid. A runtime error is raised or, if silent or "parent" error processing mode is selected, PTLOC_ERROR is returned.

◆ newEdge()

int cv::Subdiv2D::newEdge ( )
protected

◆ newPoint()

int cv::Subdiv2D::newPoint ( Point2f  pt,
bool  isvirtual,
int  firstEdge = 0 
)
protected

◆ nextEdge()

CV_WRAP int cv::Subdiv2D::nextEdge ( int  edge) const

Returns next edge around the edge origin.

Parameters
edgeSubdivision edge ID.
Returns
an integer which is next edge ID around the edge origin: eOnext on the picture above if e is the input edge).

◆ rotateEdge()

CV_WRAP int cv::Subdiv2D::rotateEdge ( int  edge,
int  rotate 
) const

Returns another edge of the same quad-edge.

Parameters
edgeSubdivision edge ID.
rotateParameter specifying which of the edges of the same quad-edge as the input one to return. The following values are possible:
  • 0 - the input edge ( e on the picture below if e is the input edge)
  • 1 - the rotated edge ( eRot )
  • 2 - the reversed edge (reversed e (in green))
  • 3 - the reversed rotated edge (reversed eRot (in green))
Returns
one of the edges ID of the same quad-edge as the input edge.

◆ setEdgePoints()

void cv::Subdiv2D::setEdgePoints ( int  edge,
int  orgPt,
int  dstPt 
)
protected

◆ splice()

void cv::Subdiv2D::splice ( int  edgeA,
int  edgeB 
)
protected

◆ swapEdges()

void cv::Subdiv2D::swapEdges ( int  edge)
protected

◆ symEdge()

CV_WRAP int cv::Subdiv2D::symEdge ( int  edge) const

Member Data Documentation

◆ bottomRight

Point2f cv::Subdiv2D::bottomRight
protected

Bottom right corner of the bounding rect.

◆ freePoint

int cv::Subdiv2D::freePoint
protected

◆ freeQEdge

int cv::Subdiv2D::freeQEdge
protected

◆ qedges

std::vector<QuadEdge> cv::Subdiv2D::qedges
protected

All of the edges.

◆ recentEdge

int cv::Subdiv2D::recentEdge
protected

◆ topLeft

Point2f cv::Subdiv2D::topLeft
protected

Top left corner of the bounding rect.

◆ validGeometry

bool cv::Subdiv2D::validGeometry
protected

◆ vtx

std::vector<Vertex> cv::Subdiv2D::vtx
protected

All of the vertices.


The documentation for this class was generated from the following file: