C# Class OpenCvSharp.Blob.CvBlobLib

Functions of cvblob library
Show file Open project: shimat/opencvsharp Class Usage Examples

Public Methods

Method Description
BlobMeanColor ( CvBlobs blobs, CvBlob targetBlob, Mat originalImage ) : Scalar

Calculates mean color of a blob in an image.

CalcAngle ( CvBlob blob ) : double

Calculates angle orientation of a blob. This function uses central moments so cvCentralMoments should have been called before for this blob. (cvAngle)

CalcCentroid ( CvBlob blob ) : Point2d

Calculates centroid. Centroid will be returned and stored in the blob structure. (cvCentroid)

ContourChainCodePerimeter ( CvContourChainCode cc ) : double

Calculates perimeter of a chain code contour.

ContourPolygonArea ( CvContourPolygon polygon ) : double

Calculates area of a polygonal contour.

ContourPolygonCircularity ( CvContourPolygon polygon ) : double

Calculates the circularity of a polygon (compactness measure).

ContourPolygonPerimeter ( CvContourPolygon polygon ) : double

Calculates perimeter of a chain code contour.

ConvertChainCodesToPolygon ( CvContourChainCode cc ) : CvContourPolygon

Convert a chain code contour to a polygon.

FilterByArea ( CvBlobs blobs, int minArea, int maxArea ) : void

Filter blobs by area. Those blobs whose areas are not in range will be erased from the input list of blobs. (cvFilterByArea)

FilterByLabel ( CvBlobs blobs, int label ) : void

Filter blobs by label. Delete all blobs except those with label l.

FilterLabels ( CvBlobs blobs, Mat imgOut ) : void

Draw a binary image with the blobs that have been given. (cvFilterLabels)

GetLabel ( CvBlobs blobs, int x, int y ) : int

Get the label value from a labeled image.

GreaterBlob ( CvBlobs blobs ) : CvBlob

Find greater blob. (cvGreaterBlob)

Label ( Mat img, CvBlobs blobs ) : int

Label the connected parts of a binary image. (cvLabel)

LargestBlob ( CvBlobs blobs ) : CvBlob

Find the largest blob. (cvLargestBlob)

PolygonContourConvexHull ( CvContourPolygon polygon ) : CvContourPolygon

Calculates convex hull of a contour. Uses the Melkman Algorithm. Code based on the version in http://w3.impa.br/~rdcastan/Cgeometry/.

RenderBlob ( LabelData labels, CvBlob blob, Mat imgSource, Mat imgDest ) : void

Draws or prints information about a blob.

RenderBlob ( LabelData labels, CvBlob blob, Mat imgSource, Mat imgDest, RenderBlobsMode mode ) : void

Draws or prints information about a blob.

RenderBlob ( LabelData labels, CvBlob blob, Mat imgSource, Mat imgDest, RenderBlobsMode mode, Scalar color, double alpha = 1.0 ) : void

Draws or prints information about a blob.

RenderBlobs ( CvBlobs blobs, Mat imgSource, Mat imgDest ) : void

Draws or prints information about blobs. (cvRenderBlobs)

RenderBlobs ( CvBlobs blobs, Mat imgSource, Mat imgDest, RenderBlobsMode mode, double alpha = 1.0 ) : void

Draws or prints information about blobs. (cvRenderBlobs)

RenderContourChainCode ( CvContourChainCode contour, Mat img ) : void

Draw a contour.

RenderContourChainCode ( CvContourChainCode contour, Mat img, Scalar color ) : void

Draw a contour.

RenderContourPolygon ( CvContourPolygon contour, Mat img ) : void

Draw a polygon.

RenderContourPolygon ( CvContourPolygon contour, Mat img, Scalar color ) : void

Draw a polygon.

RenderTracks ( CvTracks tracks, Mat imgSource, Mat imgDest ) : void

Prints tracks information.

RenderTracks ( CvTracks tracks, Mat imgSource, Mat imgDest, RenderTracksMode mode ) : void

Prints tracks information.

RenderTracks ( CvTracks tracks, Mat imgSource, Mat imgDest, RenderTracksMode mode, Scalar textColor, HersheyFonts fontFace = HersheyFonts.HersheySimplex, double fontScale = 1d, int thickness = 1 ) : void

Prints tracks information.

SaveImageBlob ( string fileName, Mat img, CvBlob blob ) : void

Save the image of a blob to a file. The function uses an image (that can be the original pre-processed image or a processed one, or even the result of cvRenderBlobs, for example) and a blob structure. Then the function saves a copy of the part of the image where the blob is.

SimplifyPolygon ( CvContourPolygon polygon ) : CvContourPolygon

Simplify a polygon reducing the number of vertex according the distance "delta". Uses a version of the Ramer-Douglas-Peucker algorithm (http://en.wikipedia.org/wiki/Ramer-Douglas-Peucker_algorithm).

SimplifyPolygon ( CvContourPolygon polygon, double delta ) : CvContourPolygon

Simplify a polygon reducing the number of vertex according the distance "delta". Uses a version of the Ramer-Douglas-Peucker algorithm (http://en.wikipedia.org/wiki/Ramer-Douglas-Peucker_algorithm).

UpdateTracks ( CvBlobs blobs, CvTracks tracks, double thDistance, int thInactive ) : void

Updates list of tracks based on current blobs.

UpdateTracks ( CvBlobs blobs, CvTracks tracks, double thDistance, int thInactive, int thActive ) : void

Updates list of tracks based on current blobs.

Tracking based on: A. Senior, A. Hampapur, Y-L Tian, L. Brown, S. Pankanti, R. Bolle. Appearance Models for Occlusion Handling. Second International workshop on Performance Evaluation of Tracking and Surveillance Systems & CVPR'01. December, 2001. (http://www.research.ibm.com/peoplevision/PETS2001.pdf)

WriteContourPolygonCsv ( CvContourPolygon polygon, string filename ) : void

Write a contour to a CSV (Comma-separated values) file.

WriteContourPolygonSvg ( CvContourPolygon polygon, string fileName ) : void

Write a contour to a SVG file.

WriteContourPolygonSvg ( CvContourPolygon polygon, string fileName, Scalar stroke, Scalar fill ) : void

Write a contour to a SVG file.

Method Details

BlobMeanColor() public static method

Calculates mean color of a blob in an image.
public static BlobMeanColor ( CvBlobs blobs, CvBlob targetBlob, Mat originalImage ) : Scalar
blobs CvBlobs Blob list
targetBlob CvBlob The target blob
originalImage Mat Original image.
return Scalar

CalcAngle() public static method

Calculates angle orientation of a blob. This function uses central moments so cvCentralMoments should have been called before for this blob. (cvAngle)
public static CalcAngle ( CvBlob blob ) : double
blob CvBlob Blob.
return double

CalcCentroid() public static method

Calculates centroid. Centroid will be returned and stored in the blob structure. (cvCentroid)
public static CalcCentroid ( CvBlob blob ) : Point2d
blob CvBlob Blob whose centroid will be calculated.
return Point2d

ContourChainCodePerimeter() public static method

Calculates perimeter of a chain code contour.
public static ContourChainCodePerimeter ( CvContourChainCode cc ) : double
cc CvContourChainCode Contour (chain code type).
return double

ContourPolygonArea() public static method

Calculates area of a polygonal contour.
public static ContourPolygonArea ( CvContourPolygon polygon ) : double
polygon CvContourPolygon Contour (polygon type).
return double

ContourPolygonCircularity() public static method

Calculates the circularity of a polygon (compactness measure).
public static ContourPolygonCircularity ( CvContourPolygon polygon ) : double
polygon CvContourPolygon Contour (polygon type).
return double

ContourPolygonPerimeter() public static method

Calculates perimeter of a chain code contour.
public static ContourPolygonPerimeter ( CvContourPolygon polygon ) : double
polygon CvContourPolygon Contour (polygon type).
return double

ConvertChainCodesToPolygon() public static method

Convert a chain code contour to a polygon.
public static ConvertChainCodesToPolygon ( CvContourChainCode cc ) : CvContourPolygon
cc CvContourChainCode Chain code contour.
return CvContourPolygon

FilterByArea() public static method

Filter blobs by area. Those blobs whose areas are not in range will be erased from the input list of blobs. (cvFilterByArea)
public static FilterByArea ( CvBlobs blobs, int minArea, int maxArea ) : void
blobs CvBlobs List of blobs.
minArea int Minimun area.
maxArea int Maximun area.
return void

FilterByLabel() public static method

Filter blobs by label. Delete all blobs except those with label l.
public static FilterByLabel ( CvBlobs blobs, int label ) : void
blobs CvBlobs List of blobs.
label int Label to leave.
return void

FilterLabels() public static method

Draw a binary image with the blobs that have been given. (cvFilterLabels)
public static FilterLabels ( CvBlobs blobs, Mat imgOut ) : void
blobs CvBlobs List of blobs to be drawn.
imgOut Mat Output binary image (depth=IPL_DEPTH_8U and nchannels=1).
return void

GetLabel() public static method

Get the label value from a labeled image.
public static GetLabel ( CvBlobs blobs, int x, int y ) : int
blobs CvBlobs Blob data.
x int X coordenate.
y int Y coordenate.
return int

GreaterBlob() public static method

Find greater blob. (cvGreaterBlob)
public static GreaterBlob ( CvBlobs blobs ) : CvBlob
blobs CvBlobs List of blobs.
return CvBlob

Label() public static method

Label the connected parts of a binary image. (cvLabel)
public static Label ( Mat img, CvBlobs blobs ) : int
img Mat Input binary image (depth=IPL_DEPTH_8U and num. channels=1).
blobs CvBlobs List of blobs.
return int

LargestBlob() public static method

Find the largest blob. (cvLargestBlob)
public static LargestBlob ( CvBlobs blobs ) : CvBlob
blobs CvBlobs List of blobs.
return CvBlob

PolygonContourConvexHull() public static method

Calculates convex hull of a contour. Uses the Melkman Algorithm. Code based on the version in http://w3.impa.br/~rdcastan/Cgeometry/.
public static PolygonContourConvexHull ( CvContourPolygon polygon ) : CvContourPolygon
polygon CvContourPolygon Contour (polygon type).
return CvContourPolygon

RenderBlob() public static method

Draws or prints information about a blob.
public static RenderBlob ( LabelData labels, CvBlob blob, Mat imgSource, Mat imgDest ) : void
labels LabelData Label data.
blob CvBlob Blob.
imgSource Mat Input image (depth=IPL_DEPTH_8U and num. channels=3).
imgDest Mat Output image (depth=IPL_DEPTH_8U and num. channels=3).
return void

RenderBlob() public static method

Draws or prints information about a blob.
public static RenderBlob ( LabelData labels, CvBlob blob, Mat imgSource, Mat imgDest, RenderBlobsMode mode ) : void
labels LabelData Label data.
blob CvBlob Blob.
imgSource Mat Input image (depth=IPL_DEPTH_8U and num. channels=3).
imgDest Mat Output image (depth=IPL_DEPTH_8U and num. channels=3).
mode RenderBlobsMode Render mode. By default is CV_BLOB_RENDER_COLOR|CV_BLOB_RENDER_CENTROID|CV_BLOB_RENDER_BOUNDING_BOX|CV_BLOB_RENDER_ANGLE.
return void

RenderBlob() public static method

Draws or prints information about a blob.
public static RenderBlob ( LabelData labels, CvBlob blob, Mat imgSource, Mat imgDest, RenderBlobsMode mode, Scalar color, double alpha = 1.0 ) : void
labels LabelData Label data.
blob CvBlob Blob.
imgSource Mat Input image (depth=IPL_DEPTH_8U and num. channels=3).
imgDest Mat Output image (depth=IPL_DEPTH_8U and num. channels=3).
mode RenderBlobsMode Render mode. By default is CV_BLOB_RENDER_COLOR|CV_BLOB_RENDER_CENTROID|CV_BLOB_RENDER_BOUNDING_BOX|CV_BLOB_RENDER_ANGLE.
color Scalar Color to render (if CV_BLOB_RENDER_COLOR is used).
alpha double If mode CV_BLOB_RENDER_COLOR is used. 1.0 indicates opaque and 0.0 translucent (1.0 by default).
return void

RenderBlobs() public static method

Draws or prints information about blobs. (cvRenderBlobs)
public static RenderBlobs ( CvBlobs blobs, Mat imgSource, Mat imgDest ) : void
blobs CvBlobs List of blobs.
imgSource Mat Input image (depth=IPL_DEPTH_8U and num. channels=3).
imgDest Mat Output image (depth=IPL_DEPTH_8U and num. channels=3).
return void

RenderBlobs() public static method

Draws or prints information about blobs. (cvRenderBlobs)
public static RenderBlobs ( CvBlobs blobs, Mat imgSource, Mat imgDest, RenderBlobsMode mode, double alpha = 1.0 ) : void
blobs CvBlobs List of blobs.
imgSource Mat Input image (depth=IPL_DEPTH_8U and num. channels=3).
imgDest Mat Output image (depth=IPL_DEPTH_8U and num. channels=3).
mode RenderBlobsMode Render mode. By default is CV_BLOB_RENDER_COLOR|CV_BLOB_RENDER_CENTROID|CV_BLOB_RENDER_BOUNDING_BOX|CV_BLOB_RENDER_ANGLE.
alpha double If mode CV_BLOB_RENDER_COLOR is used. 1.0 indicates opaque and 0.0 translucent (1.0 by default).
return void

RenderContourChainCode() public static method

Draw a contour.
public static RenderContourChainCode ( CvContourChainCode contour, Mat img ) : void
contour CvContourChainCode Chain code contour.
img Mat Image to draw on.
return void

RenderContourChainCode() public static method

Draw a contour.
public static RenderContourChainCode ( CvContourChainCode contour, Mat img, Scalar color ) : void
contour CvContourChainCode Chain code contour.
img Mat Image to draw on.
color Scalar Color to draw (default, white).
return void

RenderContourPolygon() public static method

Draw a polygon.
public static RenderContourPolygon ( CvContourPolygon contour, Mat img ) : void
contour CvContourPolygon Polygon contour.
img Mat Image to draw on.
return void

RenderContourPolygon() public static method

Draw a polygon.
public static RenderContourPolygon ( CvContourPolygon contour, Mat img, Scalar color ) : void
contour CvContourPolygon Polygon contour.
img Mat Image to draw on.
color Scalar Color to draw (default, white).
return void

RenderTracks() public static method

Prints tracks information.
public static RenderTracks ( CvTracks tracks, Mat imgSource, Mat imgDest ) : void
tracks CvTracks List of tracks.
imgSource Mat Input image (depth=IPL_DEPTH_8U and num. channels=3).
imgDest Mat Output image (depth=IPL_DEPTH_8U and num. channels=3).
return void

RenderTracks() public static method

Prints tracks information.
public static RenderTracks ( CvTracks tracks, Mat imgSource, Mat imgDest, RenderTracksMode mode ) : void
tracks CvTracks List of tracks.
imgSource Mat Input image (depth=IPL_DEPTH_8U and num. channels=3).
imgDest Mat Output image (depth=IPL_DEPTH_8U and num. channels=3).
mode RenderTracksMode Render mode. By default is CV_TRACK_RENDER_ID.
return void

RenderTracks() public static method

Prints tracks information.
public static RenderTracks ( CvTracks tracks, Mat imgSource, Mat imgDest, RenderTracksMode mode, Scalar textColor, HersheyFonts fontFace = HersheyFonts.HersheySimplex, double fontScale = 1d, int thickness = 1 ) : void
tracks CvTracks List of tracks.
imgSource Mat Input image (depth=IPL_DEPTH_8U and num. channels=3).
imgDest Mat Output image (depth=IPL_DEPTH_8U and num. channels=3).
mode RenderTracksMode Render mode. By default is CV_TRACK_RENDER_ID.
textColor Scalar
fontFace HersheyFonts
fontScale double
thickness int
return void

SaveImageBlob() public static method

Save the image of a blob to a file. The function uses an image (that can be the original pre-processed image or a processed one, or even the result of cvRenderBlobs, for example) and a blob structure. Then the function saves a copy of the part of the image where the blob is.
public static SaveImageBlob ( string fileName, Mat img, CvBlob blob ) : void
fileName string Name of the file.
img Mat Image.
blob CvBlob Blob.
return void

SimplifyPolygon() public static method

Simplify a polygon reducing the number of vertex according the distance "delta". Uses a version of the Ramer-Douglas-Peucker algorithm (http://en.wikipedia.org/wiki/Ramer-Douglas-Peucker_algorithm).
public static SimplifyPolygon ( CvContourPolygon polygon ) : CvContourPolygon
polygon CvContourPolygon Contour (polygon type).
return CvContourPolygon

SimplifyPolygon() public static method

Simplify a polygon reducing the number of vertex according the distance "delta". Uses a version of the Ramer-Douglas-Peucker algorithm (http://en.wikipedia.org/wiki/Ramer-Douglas-Peucker_algorithm).
public static SimplifyPolygon ( CvContourPolygon polygon, double delta ) : CvContourPolygon
polygon CvContourPolygon Contour (polygon type).
delta double Minimun distance.
return CvContourPolygon

UpdateTracks() public static method

Updates list of tracks based on current blobs.
public static UpdateTracks ( CvBlobs blobs, CvTracks tracks, double thDistance, int thInactive ) : void
blobs CvBlobs List of blobs.
tracks CvTracks List of tracks.
thDistance double Max distance to determine when a track and a blob match.
thInactive int Max number of frames a track can be inactive.
return void

UpdateTracks() public static method

Updates list of tracks based on current blobs.
Tracking based on: A. Senior, A. Hampapur, Y-L Tian, L. Brown, S. Pankanti, R. Bolle. Appearance Models for Occlusion Handling. Second International workshop on Performance Evaluation of Tracking and Surveillance Systems & CVPR'01. December, 2001. (http://www.research.ibm.com/peoplevision/PETS2001.pdf)
public static UpdateTracks ( CvBlobs blobs, CvTracks tracks, double thDistance, int thInactive, int thActive ) : void
blobs CvBlobs List of blobs.
tracks CvTracks List of tracks.
thDistance double Max distance to determine when a track and a blob match.
thInactive int Max number of frames a track can be inactive.
thActive int If a track becomes inactive but it has been active less than thActive frames, the track will be deleted.
return void

WriteContourPolygonCsv() public static method

Write a contour to a CSV (Comma-separated values) file.
public static WriteContourPolygonCsv ( CvContourPolygon polygon, string filename ) : void
polygon CvContourPolygon Polygon contour.
filename string File name.
return void

WriteContourPolygonSvg() public static method

Write a contour to a SVG file.
public static WriteContourPolygonSvg ( CvContourPolygon polygon, string fileName ) : void
polygon CvContourPolygon Polygon contour.
fileName string File name.
return void

WriteContourPolygonSvg() public static method

Write a contour to a SVG file.
public static WriteContourPolygonSvg ( CvContourPolygon polygon, string fileName, Scalar stroke, Scalar fill ) : void
polygon CvContourPolygon Polygon contour.
fileName string File name.
stroke Scalar Stroke color (black by default).
fill Scalar Fill color (white by default).
return void