gab.opencv
Class Contour

java.lang.Object
  extended by gab.opencv.Contour

public class Contour
extends Object


Field Summary
 MatOfPoint pointMat
           
 
Constructor Summary
Contour(PApplet parent, MatOfPoint mat)
           
Contour(PApplet parent, MatOfPoint2f mat)
           
 
Method Summary
 float area()
          The area of the Contour's bounding box.
 boolean containsPoint(int x, int y)
          Check if the Contour contains a given x-y point.
 void draw()
          Draw the Contour as a closed shape with one vertex per-point.
 Rectangle getBoundingBox()
          Get the bounding box for the Contour.
 Contour getConvexHull()
          Calculate a convex hull from the current Contour.
 ArrayList<PVector> getPoints()
          Get the points that make up the Contour.
 Contour getPolygonApproximation()
          Get a new Contour that results from calculating the polygon approximation of the current Contour.
 double getPolygonApproximationFactor()
          Access the current polygonApproximationFactor.
 void loadPoints(Point[] pts)
           
 int numPoints()
          The number of points in the Contour.
 void setPolygonApproximationFactor(double polygonApproximationFactor)
          The polygonApproximationFactor is used to determine how strictly to follow a curvy polygon when converting it into a simpler polygon with getPolygonApproximation().
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

pointMat

public MatOfPoint pointMat
Constructor Detail

Contour

public Contour(PApplet parent,
               MatOfPoint mat)

Contour

public Contour(PApplet parent,
               MatOfPoint2f mat)
Method Detail

loadPoints

public void loadPoints(Point[] pts)

containsPoint

public boolean containsPoint(int x,
                             int y)
Check if the Contour contains a given x-y point. Particularly, useful for interaction via mouseX and mouseY.

Parameters:
x -
y -
Returns:
boolean

setPolygonApproximationFactor

public void setPolygonApproximationFactor(double polygonApproximationFactor)
The polygonApproximationFactor is used to determine how strictly to follow a curvy polygon when converting it into a simpler polygon with getPolygonApproximation(). For advanced use only. Set to a sane value by default.

Parameters:
polygonApproximationFactor, - a double

getPolygonApproximationFactor

public double getPolygonApproximationFactor()
Access the current polygonApproximationFactor. The polygonApproximationFactor is used to determine how strictly to follow a curvy polygon when converting it into a simpler polygon with getPolygonApproximation().

Returns:
polygonApproximationFactor, a double

getPolygonApproximation

public Contour getPolygonApproximation()
Get a new Contour that results from calculating the polygon approximation of the current Contour. The tightness of the approximation is set by the polygonApproximationFactor, See setPolygonApproximationFactor() and getPolygonApproximationFactor().

Returns:

getConvexHull

public Contour getConvexHull()
Calculate a convex hull from the current Contour. Returns a new Contour representing the convex hull.

Returns:
Contour

draw

public void draw()
Draw the Contour as a closed shape with one vertex per-point.


getPoints

public ArrayList<PVector> getPoints()
Get the points that make up the Contour.

Returns:
ArrayList points

numPoints

public int numPoints()
The number of points in the Contour.

Returns:
int

getBoundingBox

public Rectangle getBoundingBox()
Get the bounding box for the Contour.

Returns:
A java.awt.Rectangle

area

public float area()
The area of the Contour's bounding box. In most cases, this is a good approximation for the Contour's area.

Returns:
float area


Processing library opencv_processing by Greg Borenstein. (c) 2013