当前位置: 首页>>代码示例>>C#>>正文


C# IplImage类代码示例

本文整理汇总了C#中IplImage的典型用法代码示例。如果您正苦于以下问题:C# IplImage类的具体用法?C# IplImage怎么用?C# IplImage使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


IplImage类属于命名空间,在下文中一共展示了IplImage类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Absolute

        public void Absolute(IplImage imgNow)
        {
            imgDiff = cvlib.cvCreateImage(cvlib.cvGetSize( imgNow), imgNow.depth, imgNow.nChannels);

            if (!sudah_ambil)
            {
                imgLast = cvlib.cvCreateImage(cvlib.cvGetSize( imgNow), imgNow.depth, imgNow.nChannels);
                imgLast = cvlib.cvCloneImage( imgNow);
                sudah_ambil = true;
            }
            else
                sudah_ambil = false;

            cvlib.cvAbsDiff( imgNow,  imgLast,  imgDiff);

            cvlib.cvSmooth( imgDiff,  imgDiff);
            cvlib.cvSmooth( imgDiff,  imgDiff);

            if (form.showAbs)
                cvlib.cvShowImage("Motion",  imgDiff);

            countWhitePix(imgDiff);

            if (!sudah_ambil)
                cvlib.cvReleaseImage( imgLast);

            cvlib.cvReleaseImage( imgNow);
            cvlib.cvReleaseImage( imgDiff);
        }
开发者ID:rahulgarg1994,项目名称:empower_talk2,代码行数:29,代码来源:AbsDiff.cs

示例2: cariX

        public void cariX(IplImage imgSrc, ref int min, ref int max)
        {
            bool minTemu = false;

            data = new CvMat();

            CvScalar maxVal = cvlib.cvRealScalar(imgSrc.width * 255);
            CvScalar val = cvlib.cvRealScalar(0);

            //For each column sum, if sum <width * 255 then we find min
            //then proceed to the end of me to find max, if sum <width * 255 then found a new max
            for (int i = 0; i < imgSrc.width; i++)
            {
                cvlib.cvGetCol( imgSrc,  data, i); //col
                val = cvlib.cvSum( data);
                if (val.Val < maxVal.Val)
                {
                    max = i;
                    if (!minTemu)
                    {
                        min = i;
                        minTemu = true;
                    }
                }
            }
        }
开发者ID:rahulgarg1994,项目名称:empower_talk2,代码行数:26,代码来源:preprocessing.cs

示例3: cariY

        public void cariY(IplImage imgSrc, ref int min, ref int max)
        {
            bool minFound = false;

            data = new CvMat();

            CvScalar maxVal = cvlib.cvRealScalar(imgSrc.width * 255);
            CvScalar val = cvlib.cvRealScalar(0);

            //For each row sum, if sum <width * 255 then we find min
            //then proceed to the end of me to find max, if sum <width * 255 then found a new max
            for (int i = 0; i < imgSrc.height; i++)
            {
                cvlib.cvGetRow( imgSrc,  data, i); //row
                val = cvlib.cvSum( data);
                if (val.val1 < maxVal.val1)
                {
                    max = i;
                    if (!minFound)
                    {
                        min = i;
                        minFound = true;
                    }
                }
            }
        }
开发者ID:rahulgarg1994,项目名称:empower_talk2,代码行数:26,代码来源:preprocessing.cs

示例4: cariY

        public void cariY(IplImage imgSrc, ref int min, ref int max)
        {
            bool minFound = false;

            data = new CvMat();

            CvScalar maxVal = cxtypes.cvRealScalar(imgSrc.width * 255);
            CvScalar val = cxtypes.cvRealScalar(0);

            //utk setiap baris sum, jika sum < width*255 maka kita temukan min
            //kemudian lanjutkan hingga akhir utk menemukan max, jika sum < width*255 maka ditemukan max baru
            for (int i = 0; i < imgSrc.height; i++)
            {
                cxcore.CvGetRow(ref imgSrc, ref data, i); //row
                val = cxcore.CvSum(ref data);
                if (val.val1 < maxVal.val1)
                {
                    max = i;
                    if (!minFound)
                    {
                        min = i;
                        minFound = true;
                    }
                }
            }
        }
开发者ID:Juniar-Rakhman,项目名称:OpenCV_ASL_Recognition,代码行数:26,代码来源:preprocessing.cs

示例5: Absolute

        public void Absolute(IplImage imgNow)
        {
            imgDiff = cxcore.CvCreateImage(cxcore.CvGetSize(ref imgNow), imgNow.depth, imgNow.nChannels);

            if (!sudah_ambil)
            {
                imgLast = cxcore.CvCreateImage(cxcore.CvGetSize(ref imgNow), imgNow.depth, imgNow.nChannels);
                imgLast = cxcore.CvCloneImage(ref imgNow);
                sudah_ambil = true;
            }
            else
                sudah_ambil = false;

            cxcore.CvAbsDiff(ref imgNow, ref imgLast, ref imgDiff);

            cv.CvSmooth(ref imgDiff, ref imgDiff);
            cv.CvSmooth(ref imgDiff, ref imgDiff);

            if(form.showAbs)
                highgui.CvShowImage("Motion", ref imgDiff);

            countWhitePix(imgDiff);

            if (!sudah_ambil)
                cxcore.CvReleaseImage(ref imgLast);

            cxcore.CvReleaseImage(ref imgNow);
            cxcore.CvReleaseImage(ref imgDiff);
        }
开发者ID:Juniar-Rakhman,项目名称:OpenCV_ASL_Recognition,代码行数:29,代码来源:AbsDiff.cs

示例6: adaBlackPix

        public bool adaBlackPix(IplImage image)
        {
            int p, black = 0;

            byte pix;

            byte[] data = image.ImageData;

            for (int x = 0; x < image.widthStep; x++)
            {
                for (int y = 0; y < image.height; y++)
                {
                    p = y * image.widthStep + x;

                    pix = data[p];

                    if (pix == 0)
                        black++;
                }
            }

            if (black < 1000)
                return false;
            else
                return true;
        }
开发者ID:rahulgarg1994,项目名称:empower_talk2,代码行数:26,代码来源:MainForm.cs

示例7: skin_hsv

        public IplImage skin_hsv(IplImage image)
        {
            int xi, x, y, p;
            IplImage img_hsv;
            img_hsv = cvlib.cvCreateImage(cvlib.cvGetSize( image), 8, 3);
            cvlib.cvCvtColor( image,  img_hsv, cvlib.CV_BGR2HSV);

            num[,] bmpdata;
            bmpdata = new num[image.height, image.width];

            byte[] dataIn = img_hsv.ImageData;

            for (y = 0; y < image.height; y++)
            {
                for (xi = 0, x = 0; xi < image.widthStep; xi += 3, x++)
                {
                    //column position
                    p = y * image.widthStep + xi;

                    //grab the pixel data
                    bmpdata[y, x].H = dataIn[p];
                    bmpdata[y, x].S = dataIn[p + 1];
                    bmpdata[y, x].V = dataIn[p + 2];
                }
            }

            for (y = 0; y < image.height; y++)
            {
                for (x = 0; x < image.width; x++)
                {
                    if (bmpdata[y, x].H <= 19 && bmpdata[y, x].S >= 48) //jika kondisi cocok maka jgn d hitamkan
                        bmpdata[y, x].H += 0;
                    else
                        bmpdata[y, x].H = bmpdata[y, x].S = bmpdata[y, x].V = 0;
                }
            }

            for (y = 0; y < image.height; y++)
            {
                for (xi = 0, x = 0; xi < image.widthStep; xi += 3, x++)
                {
                    //column position
                    p = y * image.widthStep + xi;

                    //grab the pixel data
                    dataIn[p] = bmpdata[y, x].H;
                    dataIn[p + 1] = bmpdata[y, x].S;
                    dataIn[p + 2] = bmpdata[y, x].V;
                }
            }

            img_hsv.ImageData = dataIn;

            IplImage res = cvlib.cvCreateImage(cvlib.cvGetSize( image), 8, 3);
            cvlib.cvCvtColor( img_hsv,  res, cvlib.CV_HSV2BGR);

            cvlib.cvReleaseImage( img_hsv);
            return res;
        }
开发者ID:rahulgarg1994,项目名称:empower_talk2,代码行数:59,代码来源:SkinDetect.cs

示例8: NewEqualsOld3

 public void NewEqualsOld3()
 {
     using (var img = new IplImage(@"Image\Blob\shapes3.png", LoadMode.GrayScale))
     {
         CompareBlob(img);
         CompareRendering(img);
         CompareLabelImage(img);
     }
 }
开发者ID:neoxeo,项目名称:opencvsharp,代码行数:9,代码来源:BlobTest.cs

示例9: CentralMoments

        /// <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);
        }
开发者ID:neoxeo,项目名称:opencvsharp,代码行数:15,代码来源:CvBlobLib.cs

示例10: Process

 /// <summary>
 /// 
 /// </summary>
 /// <param name="inputBgrImage"></param>
 /// <param name="outputHueMask"></param>
 public virtual void Process(IplImage inputBgrImage, IplImage outputHueMask)
 {
     if (disposed)
         throw new ObjectDisposedException("CvAdaptiveSkinDetector");
     if (inputBgrImage == null)
         throw new ArgumentNullException("inputBgrImage");
     if (outputHueMask == null)
         throw new ArgumentNullException("outputHueMask");
     inputBgrImage.ThrowIfDisposed();
     outputHueMask.ThrowIfDisposed();
     NativeMethods.contrib_CvAdaptiveSkinDetector_process(ptr, inputBgrImage.CvPtr, outputHueMask.CvPtr);
 }
开发者ID:0sv,项目名称:opencvsharp,代码行数:17,代码来源:CvAdaptiveSkinDetector.cs

示例11: ConvexityDefect

        public ConvexityDefect()
        {
            using (IplImage imgSrc = new IplImage(@"img\hand_p.jpg", LoadMode.Color))
            using (IplImage imgHSV = new IplImage(imgSrc.Size, BitDepth.U8, 3))
            using (IplImage imgH = new IplImage(imgSrc.Size, BitDepth.U8, 1))
            using (IplImage imgS = new IplImage(imgSrc.Size, BitDepth.U8, 1))
            using (IplImage imgV = new IplImage(imgSrc.Size, BitDepth.U8, 1))
            using (IplImage imgBackProjection = new IplImage(imgSrc.Size, BitDepth.U8, 1))
            using (IplImage imgFlesh = new IplImage(imgSrc.Size, BitDepth.U8, 1))
            using (IplImage imgHull = new IplImage(imgSrc.Size, BitDepth.U8, 1))
            using (IplImage imgDefect = new IplImage(imgSrc.Size, BitDepth.U8, 3))
            using (IplImage imgContour = new IplImage(imgSrc.Size, BitDepth.U8, 3))
            using (CvMemStorage storage = new CvMemStorage())
            {
                // RGB -> HSV
                Cv.CvtColor(imgSrc, imgHSV, ColorConversion.BgrToHsv);
                Cv.CvtPixToPlane(imgHSV, imgH, imgS, imgV, null);
                IplImage[] hsvPlanes = {imgH, imgS, imgV};

                // 肌色領域を求める
                RetrieveFleshRegion(imgSrc, hsvPlanes, imgBackProjection);
                // 最大の面積の領域を残す
                FilterByMaximalBlob(imgBackProjection, imgFlesh);
                Interpolate(imgFlesh);

                // 輪郭を求める
                CvSeq<CvPoint> contours = FindContours(imgFlesh, storage);
                if (contours != null)
                {
                    Cv.DrawContours(imgContour, contours, CvColor.Red, CvColor.Green, 0, 3, LineType.AntiAlias);

                    // 凸包を求める
                    int[] hull;
                    Cv.ConvexHull2(contours, out hull, ConvexHullOrientation.Clockwise);
                    Cv.Copy(imgFlesh, imgHull);
                    DrawConvexHull(contours, hull, imgHull);

                    // 凹状欠損を求める
                    Cv.Copy(imgContour, imgDefect);
                    CvSeq<CvConvexityDefect> defect = Cv.ConvexityDefects(contours, hull);
                    DrawDefects(imgDefect, defect);
                }

                using (new CvWindow("src", imgSrc))
                using (new CvWindow("back projection", imgBackProjection))
                using (new CvWindow("hull", imgHull))
                using (new CvWindow("defect", imgDefect))
                {
                    Cv.WaitKey();
                }
            }
        }
开发者ID:qxp1011,项目名称:opencvsharp,代码行数:52,代码来源:Program.cs

示例12: countWhitePix

        public void countWhitePix(IplImage image)
        {
            int p, white = 0 ;

            byte pix;

            byte[] data = image.ImageDataUChar;

            for (int x = 0; x < image.widthStep; x++)
            {
                for (int y = 0; y < image.height; y++)
                {
                    p = y * image.widthStep + x;

                    pix = data[p];

                    if (pix == 255)
                        white++;
                }
            }

            if (white < 50 && white < 5)
                diam++;
            else
                diam = 0;

            if (white > 100)
            {
                gerak++;
                if (white > 500)
                    wave++;
            }

            if (diam > 10)
            {
                gerak = 0;
                wave = 0;
                diam = 0;
                form.match = true;
            }

            if (wave > 10)
            {
                form.reset = true;
                wave = 0;
                gerak = 0;
                diam = 0;
            }

            cxcore.CvReleaseImage(ref image);
        }
开发者ID:Juniar-Rakhman,项目名称:OpenCV_ASL_Recognition,代码行数:51,代码来源:AbsDiff.cs

示例13: Niblack

        /// <summary>
        /// Niblackの手法による二値化処理を行う。
        /// </summary>
        /// <param name="imgSrc">入力画像</param>
        /// <param name="imgDst">出力画像</param>
        /// <param name="kernelSize">局所領域のサイズ</param>
        /// <param name="k">係数</param>
#else
        /// <summary>
        /// Binarizes by Niblack's method
        /// </summary>
        /// <param name="src">Input image</param>
        /// <param name="dst">Output image</param>
        /// <param name="kernelSize">Window size</param>
        /// <param name="k">Adequate coefficient</param>
#endif
        public static void Niblack(IplImage src, IplImage dst, int kernelSize, double k)
        {
            if (src == null)
                throw new ArgumentNullException("src");
            if (dst == null)
                throw new ArgumentNullException("dst");

            // グレースケールのみ
            if (src.NChannels != 1)
                throw new ArgumentException("src must be gray scale image");
            if (dst.NChannels != 1)
                throw new ArgumentException("dst must be gray scale image");

            // サイズのチェック
            if (kernelSize < 3)
                throw new ArgumentOutOfRangeException("kernelSize", "size must be 3 and above");
            if (kernelSize % 2 == 0)
                throw new ArgumentOutOfRangeException("kernelSize", "size must be odd number");

            CvRect roi = src.ROI;
            int width = roi.Width;
            int height = roi.Height;
            if (width != dst.Width || height != dst.Height)
                throw new ArgumentException("src.Size == dst.Size");

            unsafe
            {
                byte* pSrc = src.ImageDataPtr;
                byte* pDst = dst.ImageDataPtr;
                int stepSrc = src.WidthStep;
                int stepDst = dst.WidthStep;
                //for (int y = 0; y < gray.Height; y++)
                MyParallel.For(0, height, delegate(int y)
                {
                    for (int x = 0; x < width; x++)
                    {
                        double m, s;
                        MeanStddev(src, x + roi.X, y + roi.Y, kernelSize, out m, out s);
                        double threshold = m + k * s;
                        int offsetSrc = stepSrc * (y + roi.Y) + (x + roi.X);
                        int offsetDst = stepDst * y + x;
                        if (pSrc[offsetSrc] < threshold)
                            pDst[offsetDst] = 0;
                        else
                            pDst[offsetDst] = 255;
                    }
                }
                );
            }
        }
开发者ID:0sv,项目名称:opencvsharp,代码行数:66,代码来源:Binarizer.cs

示例14: SimpleTest

        public void SimpleTest()
        {
            using (var src = new IplImage(@"Image\Blob\shapes2.png", LoadMode.GrayScale))
            using (var binary = new IplImage(src.Size, BitDepth.U8, 1))
            using (var render = new IplImage(src.Size, BitDepth.U8, 3))
            {
                Cv.Threshold(src, binary, 0, 255, ThresholdType.Otsu);

                var blobs = new CvBlobs(binary);
                blobs.RenderBlobs(src, render);
                using (new CvWindow(render))
                {
                    Cv.WaitKey();
                }
            }
        }
开发者ID:neoxeo,项目名称:opencvsharp,代码行数:16,代码来源:BlobTest.cs

示例15: RetrieveFleshRegion

        /// <summary>
        /// バックプロジェクションにより肌色領域を求める
        /// </summary>
        /// <param name="imgSrc"></param>
        /// <param name="hsvPlanes"></param>
        /// <param name="imgRender"></param>
        private void RetrieveFleshRegion(IplImage imgSrc, IplImage[] hsvPlanes, IplImage imgDst)
        {
            int[] histSize = new int[] {30, 32};
            float[] hRanges = {0.0f, 20f};
            float[] sRanges = {50f, 255f};
            float[][] ranges = {hRanges, sRanges};

            imgDst.Zero();
            using (CvHistogram hist = new CvHistogram(histSize, HistogramFormat.Array, ranges, true))
            {
                hist.Calc(hsvPlanes, false, null);
                float minValue, maxValue;
                hist.GetMinMaxValue(out minValue, out maxValue);
                hist.Normalize(imgSrc.Width * imgSrc.Height * 255 / maxValue);
                hist.CalcBackProject(hsvPlanes, imgDst);
            }
        }
开发者ID:qxp1011,项目名称:opencvsharp,代码行数:23,代码来源:Program.cs


注:本文中的IplImage类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。