Exemplo n.º 1
0
        /// <summary>
        /// Calculates centroid.
        /// Centroid will be returned and stored in the blob structure. (cvCentroid)
        /// </summary>
        /// <param name="blob">Blob whose centroid will be calculated.</param>
        /// <returns>Centroid.</returns>
        public static CvPoint2D64f Centroid(CvBlob blob)
        {
            if (blob == null)
            {
                throw new ArgumentNullException("blob");
            }

            return CvBlobInvoke.cvb_cvCentroid(blob.CvPtr);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Calculates angle orientation of a blob.
        /// This function uses central moments so cvCentralMoments should have been called before for this blob. (cvAngle)
        /// </summary>
        /// <param name="blob">Blob.</param>
        /// <returns>Angle orientation in radians.</returns>
        public static double Angle(CvBlob blob)
        {
            if (blob == null)
            {
                throw new ArgumentNullException("blob");
            }

            return CvBlobInvoke.cvb_cvAngle(blob.CvPtr);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Calculates central moment for a blob.
        /// Central moments will be stored in blob structure. (cvCentralMoments)
        /// </summary>
        /// <param name="blob">Blob.</param>
        /// <param name="img">Label image (depth=IPL_DEPTH_LABEL and num. channels=1).</param>
        public static void CentralMoments(CvBlob blob, IplImage img)
        {
            if (blob == null)
                throw new ArgumentNullException("blob");
            if (img == null)
                throw new ArgumentNullException("img");

            CvBlobInvoke.cvb_cvCentralMoments(blob.CvPtr, img.CvPtr);
        }
Exemplo n.º 4
0
 /// <summary>
 /// Set the ROI of an image to the bounding box of a blob.
 /// </summary>
 /// <param name="img">Image.</param>
 /// <param name="blob">Blob.</param>
 public static void SetImageROItoBlob(IplImage img, CvBlob blob)
 {
     if (img == null)
         throw new ArgumentNullException("img");
     if (blob == null)
         throw new ArgumentNullException("blob");
     CvBlobInvoke.cvb_cvSetImageROItoBlob(img.CvPtr, blob.CvPtr);
 }
Exemplo n.º 5
0
        /// <summary>
        /// Draws or prints information about a blob.
        /// </summary>
        /// <param name="imgLabel">Label image (depth=IPL_DEPTH_LABEL and num. channels=1).</param>
        /// <param name="blob">Blob.</param>
        /// <param name="imgSource">Input image (depth=IPL_DEPTH_8U and num. channels=3).</param>
        /// <param name="imgDest">Output image (depth=IPL_DEPTH_8U and num. channels=3).</param>
        /// <param name="mode">Render mode. By default is CV_BLOB_RENDER_COLOR|CV_BLOB_RENDER_CENTROID|CV_BLOB_RENDER_BOUNDING_BOX|CV_BLOB_RENDER_ANGLE.</param>
        /// <param name="color">Color to render (if CV_BLOB_RENDER_COLOR is used).</param>
        /// <param name="alpha">If mode CV_BLOB_RENDER_COLOR is used. 1.0 indicates opaque and 0.0 translucent (1.0 by default).</param>
        public static void RenderBlob(IplImage imgLabel, CvBlob blob, IplImage imgSource, IplImage imgDest, RenderBlobsMode mode, CvScalar color, double alpha)
        {
            if (imgLabel == null)
                throw new ArgumentNullException("imgLabel");
            if (blob == null)
                throw new ArgumentNullException("blob");
            if (imgSource == null)
                throw new ArgumentNullException("imgSource");
            if (imgDest == null)
                throw new ArgumentNullException("imgDest");

            CvBlobInvoke.cvb_cvRenderBlob(imgLabel.CvPtr, blob.CvPtr, imgSource.CvPtr, imgDest.CvPtr, mode, color, alpha);
        }
Exemplo n.º 6
0
 /// <summary>
 /// Draws or prints information about a blob.
 /// </summary>
 /// <param name="imgLabel">Label image (depth=IPL_DEPTH_LABEL and num. channels=1).</param>
 /// <param name="blob">Blob.</param>
 /// <param name="imgSource">Input image (depth=IPL_DEPTH_8U and num. channels=3).</param>
 /// <param name="imgDest">Output image (depth=IPL_DEPTH_8U and num. channels=3).</param>
 /// <param name="mode">Render mode. By default is CV_BLOB_RENDER_COLOR|CV_BLOB_RENDER_CENTROID|CV_BLOB_RENDER_BOUNDING_BOX|CV_BLOB_RENDER_ANGLE.</param>
 /// <param name="color">Color to render (if CV_BLOB_RENDER_COLOR is used).</param>
 public static void RenderBlob(IplImage imgLabel, CvBlob blob, IplImage imgSource, IplImage imgDest, RenderBlobsMode mode, CvScalar color)
 {
     RenderBlob(imgLabel, blob, imgSource, imgDest, mode, color, 1.0);
 }
Exemplo n.º 7
0
 /// <summary>
 /// Draws or prints information about a blob.
 /// </summary>
 /// <param name="imgLabel">Label image (depth=IPL_DEPTH_LABEL and num. channels=1).</param>
 /// <param name="blob">Blob.</param>
 /// <param name="imgSource">Input image (depth=IPL_DEPTH_8U and num. channels=3).</param>
 /// <param name="imgDest">Output image (depth=IPL_DEPTH_8U and num. channels=3).</param>
 /// <param name="mode">Render mode. By default is CV_BLOB_RENDER_COLOR|CV_BLOB_RENDER_CENTROID|CV_BLOB_RENDER_BOUNDING_BOX|CV_BLOB_RENDER_ANGLE.</param>
 public static void RenderBlob(IplImage imgLabel, CvBlob blob, IplImage imgSource, IplImage imgDest, RenderBlobsMode mode)
 {
     RenderBlob(imgLabel, blob, imgSource, imgDest, mode, CvColor.White, 1.0);
 }
Exemplo n.º 8
0
        /// <summary>
        /// Calculates mean color of a blob in an image.
        /// </summary>
        /// <param name="blob">Blob</param>
        /// <param name="imgLabel">Image of labels.</param>
        /// <param name="img">Original image.</param>
        /// <returns>Average color.</returns>
        public static CvScalar BlobMeanColor(CvBlob blob, IplImage imgLabel, IplImage img)
        {
            if (blob == null)
                throw new ArgumentNullException("blob");
            if (imgLabel == null)
                throw new ArgumentNullException("imgLabel");
            if (img == null)
                throw new ArgumentNullException("img");
            if (blob.IsDisposed)
                throw new ObjectDisposedException("CvBlob");

            return CvBlobInvoke.cvb_cvBlobMeanColor(blob.CvPtr, imgLabel.CvPtr, img.CvPtr);
        }